I know that there exists a package that supports handling biological information such as Biojava , but I want to make a simple code which will convert a DNA sequence into a complement sequence of it
Here is my code...
public class SeqComplement{
    static String sequence ;
    String Complement(String sequence){
        // this.sequence = sequence;
        // String complement;
        // complement = "N";
        // for(int i = 0 ; i< sequence.length() ; i++){
        String[] raw = new String[sequence.length()];
        String[] complement = new String[sequence.length()];
        String ComplementSeq = "N";
        for(int i = 0 ; i <sequence.length() ; i++){
            String sub = sequence.substring(i,i+1);
            raw[i] = sub;
            }
        for(int j = 0 ; j < sequence.length();j++){
            if(raw[j] == "A"){
                complement[j] = "T";
                }
            else if (raw[j] == "T"){
                complement[j] = "A";
                }
            else if (raw[j] == "G"){
                complement[j] = "C";
                }
            else if (raw[j] == "C"){
                complement[j] = "G";
                }
            else{
                complement[j] = "N";
                }
            }
        for(int k = 0 ; k < complement.length ; k++){
            ComplementSeq+=complement[k];
            }
        return ComplementSeq.substring(1);
        }
    public static void main(String[] args){
        SeqComplement.sequence = "ATCG";
        SeqComplement ob = new SeqComplement();
        System.out.println(ob.Complement(ob.sequence));
    }
}
This code gave result as NNNN
I already tried using String.concat() method, but it gave me nothing.
 
     
     
     
    