int gapExtend = 20;
- float[][] lookup;
-
- int gapIndex = 23;
-
StringBuffer output = new StringBuffer();
String type; // AlignSeq.PEP or AlignSeq.DNA
private ScoreMatrix scoreModel;
+ private static final int GAP_INDEX = -1;
+
/**
* Creates a new AlignSeq object.
*
return;
}
- seq1 = new int[s1str.length()];
-
- seq2 = new int[s2str.length()];
-
score = new float[s1str.length()][s2str.length()];
E = new float[s1str.length()][s2str.length()];
type = moleculeType;
scoreModel = ScoreModels.getInstance().getDefaultModel(
PEP.equals(type));
- lookup = scoreModel.getMatrix();
- gapIndex = scoreModel.getMatrixIndex(' ');
}
/**
else if (trace == 1)
{
j--;
- aseq1[count] = gapIndex;
+ aseq1[count] = GAP_INDEX;
sb1.replace(sb1.length() - 1, sb1.length(), "-");
}
else if (trace == -1)
{
i--;
- aseq2[count] = gapIndex;
+ aseq2[count] = GAP_INDEX;
sb2.replace(sb2.length() - 1, sb2.length(), "-");
}
seq1start = i + 1;
seq2start = j + 1;
- if (aseq1[count] != gapIndex)
+ if (aseq1[count] != GAP_INDEX)
{
aseq1[count] = seq1[i];
sb1.append(s1str.charAt(i));
}
- if (aseq2[count] != gapIndex)
+ if (aseq2[count] != GAP_INDEX)
{
aseq2[count] = seq2[j];
sb2.append(s2str.charAt(j));
public int findTrace(int i, int j)
{
int t = 0;
- float max = score[i - 1][j - 1] + (lookup[seq1[i]][seq2[j]] * 10);
+ // float pairwiseScore = lookup[seq1[i]][seq2[j]];
+ float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i),
+ s2str.charAt(j));
+ float max = score[i - 1][j - 1] + (pairwiseScore * 10);
if (F[i][j] > max)
{
int m = seq2.length;
// top left hand element
- score[0][0] = lookup[seq1[0]][seq2[0]] * 10;
+ score[0][0] = scoreModel.getPairwiseScore(s1str.charAt(0),
+ s2str.charAt(0)) * 10;
E[0][0] = -gapExtend;
F[0][0] = 0;
E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend);
F[0][j] = -gapExtend;
- score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, -gapExtend);
+ float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(0),
+ s2str.charAt(j));
+ score[0][j] = max(pairwiseScore * 10, -gapOpen, -gapExtend);
traceback[0][j] = 1;
}
E[i][0] = -gapOpen;
F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend);
- score[i][0] = max(lookup[seq1[i]][seq2[0]] * 10, E[i][0], F[i][0]);
+ float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i),
+ s2str.charAt(0));
+ score[i][0] = max(pairwiseScore * 10, E[i][0], F[i][0]);
traceback[i][0] = -1;
}
E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend);
F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - gapExtend);
+ float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i),
+ s2str.charAt(j));
score[i][j] = max(score[i - 1][j - 1]
- + (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]);
+ + (pairwiseScore * 10), E[i][j], F[i][j]);
traceback[i][j] = findTrace(i, j);
}
}
public static void displayMatrix(Graphics g, int[][] mat, int n, int m,
int psize)
{
- // TODO method dosen't seem to be referenced anywhere delete??
+ // TODO method doesn't seem to be referenced anywhere delete??
int max = -1000;
int min = 1000;
bestm = msq;
}
}
- System.out.println("Best Score for " + (matches.size() + 1) + " :"
- + bestscore);
+ // System.out.println("Best Score for " + (matches.size() + 1) + " :"
+ // + bestscore);
matches.add(bestm);
aligns.add(bestaseq);
al.deleteSequence(bestm);