package jalview.analysis;
import jalview.analysis.scoremodels.ScoreModels;
+import jalview.analysis.scoremodels.SimilarityParams;
import jalview.api.analysis.DistanceScoreModelI;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityScoreModelI;
{
this.sequence = sqs;
this.node = new Vector<SequenceNode>();
+ if (!(treeType.equals(NEIGHBOUR_JOINING)))
+ {
+ treeType = AVERAGE_DISTANCE;
+ }
this.type = treeType;
this.pwtype = modelType;
if (seqView != null)
sdata.addOperation(CigarArray.M, end - start + 1);
this.seqData = new AlignmentView(sdata, start);
}
- // System.err.println("Made seqData");// dbg
- if (!(treeType.equals(NEIGHBOUR_JOINING)))
- {
- treeType = AVERAGE_DISTANCE;
- }
if (sm == null && !(modelType.equals("PID")))
{
noseqs = i++;
+ // TODO pass choice of params from GUI in constructo
if (sm instanceof DistanceScoreModelI)
{
- distance = ((DistanceScoreModelI) sm).findDistances(seqData);
+ distance = ((DistanceScoreModelI) sm).findDistances(seqData,
+ SimilarityParams.Jalview);
}
else if (sm instanceof SimilarityScoreModelI)
{
/*
* compute similarity and invert it to give a distance measure
*/
- MatrixI result = ((SimilarityScoreModelI) sm)
- .findSimilarities(seqData);
+ MatrixI result = ((SimilarityScoreModelI) sm).findSimilarities(
+ seqData, SimilarityParams.Jalview);
result.reverseRange(true);
distance = result;
}
- // System.err.println("Made distances");// dbg
makeLeaves();
- // System.err.println("Made leaves");// dbg
noClus = cluster.size();
cluster();
- // System.err.println("Made clusters");// dbg
-
}
/**
{
jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode());
- return fout.print(isHasBootstrap(), isHasDistances(),
- isHasRootDistance()); // output all data available for tree
+ return fout.print(hasBootstrap(), hasDistances(),
+ hasRootDistance()); // output all data available for tree
}
/**
* @param list
* Sequence set to be associated with tree nodes
*/
- public void UpdatePlaceHolders(List<SequenceI> list)
+ public void updatePlaceHolders(List<SequenceI> list)
{
Vector<SequenceNode> leaves = findLeaves(top);
/**
* DOCUMENT ME!
*/
- public void cluster()
+ void cluster()
{
while (noClus > 2)
{
*
* @return DOCUMENT ME!
*/
- public Cluster joinClusters(int i, int j)
+ Cluster joinClusters(int i, int j)
{
double dist = distance.getValue(i, j);
* @param dist
* DOCUMENT ME!
*/
- public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj,
+ void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj,
double dist)
{
* @param dist
* DOCUMENT ME!
*/
- public void findNewDistances(SequenceNode tmpi, SequenceNode tmpj,
+ void findNewDistances(SequenceNode tmpi, SequenceNode tmpj,
double dist)
{
double ih = 0;
* @param j
* DOCUMENT ME!
*/
- public void findClusterDistance(int i, int j)
+ void findClusterDistance(int i, int j)
{
int noi = cluster.elementAt(i).value.length;
int noj = cluster.elementAt(j).value.length;
* @param j
* DOCUMENT ME!
*/
- public void findClusterNJDistance(int i, int j)
+ void findClusterNJDistance(int i, int j)
{
// New distances from cluster to others
*
* @return DOCUMENT ME!
*/
- public double findr(int i, int j)
+ double findr(int i, int j)
{
double tmp = 1;
*
* @return DOCUMENT ME!
*/
- public double findMinNJDistance()
+ double findMinNJDistance()
{
double min = Double.MAX_VALUE;
*
* @return DOCUMENT ME!
*/
- public double findMinDistance()
+ double findMinDistance()
{
double min = Double.MAX_VALUE;
}
/**
- * Calculate a distance matrix given the sequence input data and score model
- *
- * @return
- */
- public MatrixI findDistances(ScoreModelI scoreModel)
- {
- MatrixI result = null;
-
- if (scoreModel == null)
- {
- // Resolve substitution model
- scoreModel = ScoreModels.getInstance().forName(pwtype);
- if (scoreModel == null)
- {
- scoreModel = ScoreModels.getInstance().forName("BLOSUM62");
- }
- }
- if (scoreModel instanceof DistanceScoreModelI)
- {
- result = ((DistanceScoreModelI) scoreModel).findDistances(seqData);
- }
- else if (scoreModel instanceof SimilarityScoreModelI)
- {
- /*
- * compute similarity and invert it to give a distance measure
- */
- result = ((SimilarityScoreModelI) scoreModel)
- .findSimilarities(seqData);
- result.reverseRange(true);
- }
- else
- {
- System.err
- .println("Unexpected type of score model, can't compute distances");
- }
-
- return result;
- }
-
- /**
* DOCUMENT ME!
*/
- public void makeLeaves()
+ void makeLeaves()
{
cluster = new Vector<Cluster>();
}
/**
- * Find the leaf node with a particular ycount
- *
- * @param nd
- * initial point on tree to search from
- * @param count
- * value to search for
- *
- * @return null or the node with ycound=count
- */
- public Object findLeaf(SequenceNode nd, int count)
- {
- found = _findLeaf(nd, count);
-
- return found;
- }
-
- /*
- * #see findLeaf(SequenceNode node, count)
- */
- public Object _findLeaf(SequenceNode nd, int count)
- {
- if (nd == null)
- {
- return null;
- }
-
- if (nd.ycount == count)
- {
- found = nd.element();
-
- return found;
- }
- else
- {
- _findLeaf((SequenceNode) nd.left(), count);
- _findLeaf((SequenceNode) nd.right(), count);
- }
-
- return found;
- }
-
- /**
* printNode is mainly for debugging purposes.
*
* @param nd
* SequenceNode
*/
- public void printNode(SequenceNode nd)
+ void printNode(SequenceNode nd)
{
if (nd == null)
{
* @param nd
* DOCUMENT ME!
*/
- public void findMaxDist(SequenceNode nd)
+ void findMaxDist(SequenceNode nd)
{
if (nd == null)
{
*
* @return DOCUMENT ME!
*/
- public SequenceNode reRoot()
+ SequenceNode reRoot()
{
+ // TODO not used - remove?
if (maxdist != null)
{
ycount = 0;
* @param nd
* DOCUMENT ME!
*/
- public void printN(SequenceNode nd)
+ void printN(SequenceNode nd)
{
if (nd == null)
{
* @param nd
* DOCUMENT ME!
*/
- public void _reCount(SequenceNode nd)
+ void _reCount(SequenceNode nd)
{
// if (_lycount<_lylimit)
// {
* @param dir
* DOCUMENT ME!
*/
- public void changeDirection(SequenceNode nd, SequenceNode dir)
+ void changeDirection(SequenceNode nd, SequenceNode dir)
{
if (nd == null)
{
*
* @return true if tree has real distances
*/
- public boolean isHasDistances()
+ public boolean hasDistances()
{
return hasDistances;
}
*
* @return true if tree has real bootstrap values
*/
- public boolean isHasBootstrap()
+ public boolean hasBootstrap()
{
return hasBootstrap;
}
- public boolean isHasRootDistance()
+ public boolean hasRootDistance()
{
return hasRootDistance;
}