so if Sequence 1 :CAG and Sequence 2 :AG, i am supposed to get the response
"Best alignment score :2 CAG AG"
but instead i am getting "Best alignment score :0 CAG AG"
I believe my issue is in the 2nd if statement, as that what it seems like with the debugger.
when using the debugger it shows that the computer not going into the if statement.
can anyone please tell me how to fix this issue? thanks
can anyone please tell me how i can make my question clearer? thanks
public static int allignment (String dnaSequence1 , String dnaSequence2 /*,int offset*/){
int newScore = 0;
int bestScore = 0;
int newOffset = 0;
int bestOffset = 0;
for(int offset =0; offset<=(dnaSequence1.length()-dnaSequence2.length());offset++){
//newOffset ++;
newScore = 0;
for(int place =0; place<dnaSequence2.length();place++ ){
if(dnaSequence1.charAt(place) == dnaSequence2.charAt(place/*+offset*/)){
newScore ++;
if(newScore>bestScore){
bestScore = newScore;
bestOffset = newOffset;
}
}else{ continue;}
}
newOffset ++;
}
String space = " ";
System.out.println("Best alignment score :"+bestScore);
System.out.println(dnaSequence1);
System.out.print( space(bestOffset) + dnaSequence2);
int alignmentScore = dnaSequence1.compareToIgnoreCase(dnaSequence2);
return alignmentScore;
}
public static String space (int bestOffset){
String space = " ";
String offsetScaces = "";
for(int i = 0; i<bestOffset; i++){
offsetScaces+=space;
return offsetScaces;
}
return offsetScaces;
}
Aucun commentaire:
Enregistrer un commentaire