/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.datamodel.SequenceNode;
import jalview.io.NewickFile;
import jalview.schemes.ResidueProperties;
+import jalview.util.Format;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
/**
- * DOCUMENT ME!
+ * NeighborJoining tree
*
* @author $author$
* @version $Revision$
}
/*
* sequenceString = new String[odata.length]; char gapChar =
- * jalview.util.Comparison.GapChars.charAt(0); for (int i = 0; i <
+ * Comparison.GapChars.charAt(0); for (int i = 0; i <
* odata.length; i++) { SequenceI oseq_aligned = odata[i].getSeq(gapChar);
* sequenceString[i] = oseq_aligned.getSequence(); }
*/
if (one2many.contains(nam))
{
countOne2Many++;
- // if (jalview.bin.Cache.log.isDebugEnabled())
- // jalview.bin.Cache.log.debug("One 2 many relationship for
+ // if (Cache.log.isDebugEnabled())
+ // Cache.log.debug("One 2 many relationship for
// "+nam.getName());
}
else
j.setPlaceholder(true);
}
}
- // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) {
- // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment
+ // if (Cache.log.isDebugEnabled() && countOne2Many>0) {
+ // Cache.log.debug("There were "+countOne2Many+" alignment
// sequence ids (out of "+one2many.size()+" unique ids) linked to two or
// more leaves.");
// }
* DOCUMENT ME!
*/
public NJTree(SequenceI[] sequence, AlignmentView seqData, String type,
- String pwtype, int start, int end)
+ String pwtype, ScoreModelI sm, int start, int end)
{
this.sequence = sequence;
this.node = new Vector();
type = "AV";
}
- if (!(pwtype.equals("PID")))
+ if (sm == null && !(pwtype.equals("PID")))
{
if (ResidueProperties.getScoreMatrix(pwtype) == null)
{
noseqs = i++;
- distance = findDistances();
+ distance = findDistances(sm);
// System.err.println("Made distances");// dbg
makeLeaves();
// System.err.println("Made leaves");// dbg
*/
public String toString()
{
- jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode());
+ NewickFile fout = new NewickFile(getTopNode());
return fout.print(isHasBootstrap(), isHasDistances(),
isHasRootDistance()); // output all data available for tree
for (int j = 0; j < seqs.length; j++)
{
- seqs[j] = (SequenceI) list.get(j);
+ seqs[j] = list.get(j);
}
seqmatcher = new SequenceIdMatcher(seqs);
*
* @return similarity matrix used to compute tree
*/
- public float[][] findDistances()
+ public float[][] findDistances(ScoreModelI _pwmatrix)
{
float[][] distance = new float[noseqs][noseqs];
-
- // Pairwise substitution score (with no gap penalties)
- ScoreModelI _pwmatrix = ResidueProperties.getScoreModel(pwtype);
if (_pwmatrix == null)
{
- _pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
+ // Resolve substitution model
+ _pwmatrix = ResidueProperties.getScoreModel(pwtype);
+ if (_pwmatrix == null)
+ {
+ _pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
+ }
}
distance = _pwmatrix.findDistances(seqData);
return distance;
{
System.out
.println("Leaf = " + ((SequenceI) node.element()).getName());
- System.out.println("Dist " + ((SequenceNode) node).dist);
+ System.out.println("Dist " + node.dist);
System.out.println("Boot " + node.getBootstrap());
}
else
{
- System.out.println("Dist " + ((SequenceNode) node).dist);
+ System.out.println("Dist " + node.dist);
printNode((SequenceNode) node.left());
printNode((SequenceNode) node.right());
}
if ((node.left() == null) && (node.right() == null))
{
- float dist = ((SequenceNode) node).dist;
+ float dist = node.dist;
if (dist > maxDistValue)
{
- maxdist = (SequenceNode) node;
+ maxdist = node;
maxDistValue = dist;
}
}
String[] seqdatas = seqData.getSequenceStrings(gapChar);
for (int i = 0; i < seqdatas.length; i++)
{
- sb.append(new jalview.util.Format("%-" + 15 + "s").form(sequence[i]
- .getName()));
+ sb.append(new Format("%-" + 15 + "s").form(sequence[i].getName()));
sb.append(" " + seqdatas[i] + "\n");
}
return sb.toString();
+ ((SequenceI) node.element()).getName());
}
- System.out.println(" dist = " + ((SequenceNode) node).dist + " "
- + ((SequenceNode) node).count + " "
- + ((SequenceNode) node).height);
+ System.out.println(" dist = " + node.dist + " "
+ + node.count + " "
+ + node.height);
}
/**
SequenceNode l = (SequenceNode) node.left();
SequenceNode r = (SequenceNode) node.right();
- ((SequenceNode) node).count = l.count + r.count;
- ((SequenceNode) node).ycount = (l.ycount + r.ycount) / 2;
+ node.count = l.count + r.count;
+ node.ycount = (l.ycount + r.ycount) / 2;
}
else
{
- ((SequenceNode) node).count = 1;
- ((SequenceNode) node).ycount = ycount++;
+ node.count = 1;
+ node.ycount = ycount++;
}
_lycount--;
}
{
for (Enumeration nodes = node.elements(); nodes.hasMoreElements(); nodeTransformI
.transform((BinaryNode) nodes.nextElement()))
+ {
;
+ }
}
}