java - How to build the scoring matrix for global sequence alignment? -


i have tried global sequence alignment between 2 strings. gives me wrong answer. way of generating scoring matrix below.

public void makescoringmatrix(string v,string w) {     int ar[][]=new int[v.length()+1][w.length()+1];     for(int i=v.length()-1;i>=0;i--)     {         for(int j=w.length()-1;j>=0;j--)         {             if(v.charat(i)==w.charat(j))                 ar[i][j]=ar[i+1][j+1]+1;             else if(v.charat(i)!=w.charat(j))                 ar[i][j]=ar[i+1][j+1]+0;             else                 ar[i][j]=math.max(ar[i][j+1],math.max(ar[i+1][j],ar[i+1][j+1]));         }     }     //printarray(ar);     getglobalalignment(ar,v,w); }  public void getglobalalignment(int ar[][],string v,string w) {     int i=0,j=0,index=0;     while(i<v.length() && j<w.length())     {         if(v.charat(i)==w.charat(j))         {             system.out.print(v.charat(i));             i++;             j++;             index++;          }         else if(ar[i+1][j]>ar[i][j+1])         {             i++;         }         else         {             j++;         }     }  } 

someone please me...!

try code...

public void makematrix(string v,string w) {     int[][] maxdist=new int[v.length()+1][w.length()+1];     for(int i=0;i<=v.length();i++)     {         for(int j=0;j<=w.length();j++)         {             if(i==0)                 maxdist[i][j]=-j;             else if(j==0)                 maxdist[i][j]=-i;             else                 maxdist[i][j]=0;         }     }     fillmatrix(maxdist, v, w); }  public int weight(string v,string w,int i,int j) {     if(v.charat(i-1)==w.charat(j-1))         return 1;     else         return -1; }  public void fillmatrix(int[][] ar,string v,string w) {     for(int i=1;i<=v.length();i++)     {         for(int j=1;j<=w.length();j++)         {             int scorediagonal=ar[i-1][j-1]+weight(v, w, i, j);             int scoreleft=ar[i][j-1]-1;             int scoreup=ar[i-1][j]-1;              ar[i][j]=math.max(scorediagonal, math.max(scoreleft, scoreup));         }     } } 

hope code looking for...


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -