import jalview.io.NewickFile;
import jalview.schemes.ResidueProperties;
+import jalview.schemes.ScoreMatrix;
import jalview.util.*;
if (!(pwtype.equals("PID")))
{
- type = "BL";
+ if (ResidueProperties.getScoreMatrix(pwtype)==null) {
+ type = "BLOSUM62";
+ }
}
int i = 0;
if (nam != null)
{
+ if (!leaf.isPlaceholder()) {
+ // remapping the node to a new sequenceI - should remove any refs to old one.
+ // TODO - make many sequenceI to one leaf mappings possible! (JBPNote)
+ }
leaf.setPlaceholder(false);
leaf.setElement(nam);
}
else
{
+ if (!leaf.isPlaceholder()) {
+ // Construct a new placeholder sequence object for this leaf
+ leaf.setElement(new Sequence(leaf.getName(), "THISISAPLACEHLDER"));
+ }
leaf.setPlaceholder(true);
+
}
}
}
}
}
}
- else if (pwtype.equals("BL"))
- {
- int maxscore = 0;
- int end = sequenceString[0].length();
- for (int i = 0; i < (noseqs - 1); i++)
+ else {
+ // Pairwise substitution score (with no gap penalties)
+ ScoreMatrix pwmatrix=ResidueProperties.getScoreMatrix(pwtype);
+ if (pwmatrix==null) {
+ pwmatrix=ResidueProperties.getScoreMatrix("BLOSUM62");
+ }
+ int maxscore = 0;
+ int end = sequenceString[0].length();
+ for (int i = 0; i < (noseqs - 1); i++)
+ {
+ for (int j = i; j < noseqs; j++)
{
- for (int j = i; j < noseqs; j++)
+ int score = 0;
+
+ for (int k = 0; k < end; k++)
+ {
+ try
{
- int score = 0;
-
- for (int k = 0; k < end; k++)
- {
- try
- {
- score += ResidueProperties.getBLOSUM62(
- sequenceString[i].substring(k, k + 1),
- sequenceString[j].substring(k, k + 1));
- }
- catch (Exception ex)
- {
- System.err.println("err creating BLOSUM62 tree");
- ex.printStackTrace();
- }
- }
-
- distance[i][j] = (float) score;
-
- if (score > maxscore)
- {
- maxscore = score;
- }
+ score += pwmatrix.getPairwiseScore(sequenceString[i].charAt(k),
+ sequenceString[j].charAt(k));
}
- }
-
- for (int i = 0; i < (noseqs - 1); i++)
- {
- for (int j = i; j < noseqs; j++)
+ catch (Exception ex)
{
- distance[i][j] = (float) maxscore - distance[i][j];
- distance[j][i] = distance[i][j];
+ System.err.println("err creating BLOSUM62 tree");
+ ex.printStackTrace();
}
+ }
+
+ distance[i][j] = (float) score;
+
+ if (score > maxscore)
+ {
+ maxscore = score;
+ }
+ }
+ }
+
+ for (int i = 0; i < (noseqs - 1); i++)
+ {
+ for (int j = i; j < noseqs; j++)
+ {
+ distance[i][j] = (float) maxscore - distance[i][j];
+ distance[j][i] = distance[i][j];
}
+ }
+
}
+ return distance;
+
+ // else
/* else if (pwtype.equals("SW"))
{
float max = -1;
}
}
}/*/
-
- return distance;
}
/**