From 88eaada36951276cf8b2863bb95aa37148166ea2 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 18 Jul 2006 15:29:35 +0000 Subject: [PATCH] Works on strings, not seqs --- src/jalview/analysis/AlignSeq.java | 30 +++++++-- src/jalview/analysis/AlignmentSorter.java | 3 +- src/jalview/analysis/NJTree.java | 95 +++++++++++++++++------------ 3 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index d3dfc9b..464abb0 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -98,7 +98,6 @@ public class AlignSeq String type; Runtime rt; - /** * Creates a new AlignSeq object. * @@ -109,7 +108,24 @@ public class AlignSeq public AlignSeq(SequenceI s1, SequenceI s2, String type) { rt = Runtime.getRuntime(); - SeqInit(s1, s2, type); + SeqInit(s1, s1.getSequence(), s2, s2.getSequence(), type); + } + + /** + * Creates a new AlignSeq object. + * + * @param s1 DOCUMENT ME! + * @param s2 DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public AlignSeq(SequenceI s1, + String string1, + SequenceI s2, + String string2, + String type) + { + rt = Runtime.getRuntime(); + SeqInit(s1, string1, s2, string2, type); } /** @@ -239,10 +255,14 @@ public class AlignSeq * @param s2 DOCUMENT ME! * @param type DOCUMENT ME! */ - public void SeqInit(SequenceI s1, SequenceI s2, String type) + public void SeqInit(SequenceI s1, + String string1, + SequenceI s2, + String string2, + String type) { - s1str = extractGaps(jalview.util.Comparison.GapChars, s1.getSequence()); - s2str = extractGaps(jalview.util.Comparison.GapChars, s2.getSequence()); + s1str = extractGaps(jalview.util.Comparison.GapChars, string1); + s2str = extractGaps(jalview.util.Comparison.GapChars, string2); this.s1 = s1; this.s2 = s2; diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index c2814b8..27d1e7b 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -52,7 +52,8 @@ public class AlignmentSorter for (int i = 0; i < nSeq; i++) { - scores[i] = Comparison.PID(align.getSequenceAt(i), s); + scores[i] = Comparison.PID(align.getSequenceAt(i).getSequence(), + s.getSequence()); seqs[i] = align.getSequenceAt(i); } diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java index 40dfc9b..be3b96d 100755 --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -39,6 +39,11 @@ public class NJTree { Vector cluster; SequenceI[] sequence; + + //SequenceData is a string representation of what the user + //sees. The display may contain hidden columns. + String [] sequenceString; + int[] done; int noseqs; int noClus; @@ -58,23 +63,12 @@ public class NJTree String pwtype; Object found = null; Object leaves = null; - int start; - int end; + boolean hasDistances = true; // normal case for jalview trees - boolean hasBootstrap = false; // normal case for jalview trees + boolean hasBootstrap = false; // normal case for jalview trees private boolean hasRootDistance = true; - /** - * Creates a new NJTree object. - * - * @param node DOCUMENT ME! - */ - public NJTree(SequenceNode node) - { - top = node; - maxheight = findHeight(top); - } /** * Creates a new NJTree object. @@ -82,10 +76,20 @@ public class NJTree * @param seqs DOCUMENT ME! * @param treefile DOCUMENT ME! */ - public NJTree(SequenceI[] seqs, NewickFile treefile) + public NJTree(SequenceI[] seqs, NewickFile treefile) { top = treefile.getTree(); + if (sequenceString == null) + { + sequenceString = new String[sequence.length]; + for (int i = 0; i < sequence.length; i++) + { + sequenceString[i] = sequence[i].getSequence(); + } + } + + hasDistances = treefile.HasDistances(); hasBootstrap = treefile.HasBootstrap(); hasRootDistance = treefile.HasRootDistance(); @@ -132,32 +136,33 @@ public class NJTree * Creates a new NJTree object. * * @param sequence DOCUMENT ME! - * @param start DOCUMENT ME! - * @param end DOCUMENT ME! - */ - public NJTree(SequenceI[] sequence, int start, int end) - { - this(sequence, "NJ", "BL", start, end); - } - - /** - * Creates a new NJTree object. - * - * @param sequence DOCUMENT ME! * @param type DOCUMENT ME! * @param pwtype DOCUMENT ME! * @param start DOCUMENT ME! * @param end DOCUMENT ME! */ - public NJTree(SequenceI[] sequence, String type, String pwtype, int start, - int end) + public NJTree(SequenceI[] sequence, + String [] sequenceString, + String type, + String pwtype, + int start, int end) { this.sequence = sequence; this.node = new Vector(); this.type = type; this.pwtype = pwtype; - this.start = start; - this.end = end; + + if (sequenceString == null) + { + this.sequenceString = new String[sequence.length]; + for(int i=0; i