X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=8b159a63de117095db79ad5bbb7d6c22e784d88c;hb=51bbc79eee43d019f9fcb14b7aa6e0a0c2c99f76;hp=713cb0d04c918103753e01b5ae73f43f83d0d16a;hpb=52f42d57f0f08942ce54e3a739f1c9936cc5f293;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 713cb0d..8b159a6 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -20,8 +20,6 @@ package jalview.datamodel; import jalview.analysis.*; -import jalview.util.*; - import java.util.*; /** Data structure to hold and manipulate a multiple sequence alignment @@ -137,7 +135,7 @@ public class Alignment implements AlignmentI { Sequence ds = new Sequence(snew.getName(), AlignSeq.extractGaps("-. ", - snew.getSequence()), + snew.getSequenceAsString()), snew.getStart(), snew.getEnd()); @@ -205,7 +203,7 @@ public class Alignment implements AlignmentI { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if (sg.getSequences(false).contains(s)) + if (sg.getSequences(null).contains(s)) { return sg; } @@ -229,14 +227,14 @@ public class Alignment implements AlignmentI for (int i = 0; i < gSize; i++) { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if(sg==null || sg.getSequences(false)==null) + if(sg==null || sg.getSequences(null)==null) { this.deleteGroup(sg); gSize--; continue; } - if (sg.getSequences(false).contains(s)) + if (sg.getSequences(null).contains(s)) { temp.addElement(sg); } @@ -259,7 +257,24 @@ public class Alignment implements AlignmentI { if (!groups.contains(sg)) { - groups.addElement(sg); + if(hiddenSequences.getSize()>0) + { + int i, iSize = sg.getSize(); + for (i = 0; i < iSize; i++) + { + if (!sequences.contains(sg.getSequenceAt(i))) + { + sg.deleteSequence(sg.getSequenceAt(i), false); + iSize--; + i--; + } + } + + if (sg.getSize() < 1) + return; + } + + groups.addElement(sg); } } @@ -269,15 +284,6 @@ public class Alignment implements AlignmentI public void deleteAllGroups() { groups.removeAllElements(); - - int i = 0; - - while (i < sequences.size()) - { - SequenceI s = getSequenceAt(i); - s.setColor(java.awt.Color.white); - i++; - } } /** */ @@ -391,9 +397,11 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { Sequence seq = (Sequence) sequences.elementAt(i); - seq.setSequence( seq.getSequence().replace('.', gc) ); - seq.setSequence( seq.getSequence().replace('-', gc) ); - seq.setSequence( seq.getSequence().replace(' ', gc) ); + seq.setSequence(seq.getSequenceAsString() + .replace('.', gc) + .replace('-', gc) + .replace(' ', gc) + ); } } @@ -442,6 +450,9 @@ public class Alignment implements AlignmentI aSize = annotations.length; } + if(aSize<1) + return; + AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1]; int tIndex = 0; @@ -461,20 +472,6 @@ public class Alignment implements AlignmentI } - public void adjustSequenceAnnotations() - { - if(annotations!=null) - { - for (int a = 0; a < annotations.length; a++) - { - if (annotations[a].sequenceRef != null) - { - annotations[a].adjustForAlignment(); - } - } - } - } - /** * DOCUMENT ME! * @@ -563,22 +560,25 @@ public class Alignment implements AlignmentI // Can only be done once, if dataset is not null // This will not be performed Sequence[] seqs = new Sequence[getHeight()]; + SequenceI currentSeq; for (int i = 0; i < getHeight(); i++) { - if(getSequenceAt(i).getDatasetSequence()!=null) + currentSeq = getSequenceAt(i); + if(currentSeq.getDatasetSequence()!=null) { - seqs[i] = (Sequence)getSequenceAt(i).getDatasetSequence(); + seqs[i] = (Sequence)currentSeq.getDatasetSequence(); } else { - seqs[i] = new Sequence(getSequenceAt(i).getName(), + seqs[i] = new Sequence(currentSeq.getName(), AlignSeq.extractGaps( jalview.util.Comparison.GapChars, - getSequenceAt(i).getSequence() + currentSeq.getSequenceAsString() ), - getSequenceAt(i).getStart(), - getSequenceAt(i).getEnd()); - seqs[i].sequenceFeatures = getSequenceAt(i).getSequenceFeatures(); + currentSeq.getStart(), + currentSeq.getEnd()); + seqs[i].sequenceFeatures = currentSeq.getSequenceFeatures(); + seqs[i].setDescription(currentSeq.getDescription()); getSequenceAt(i).setSequenceFeatures(null); getSequenceAt(i).setDatasetSequence(seqs[i]); } @@ -646,34 +646,6 @@ public class Alignment implements AlignmentI { return hiddenSequences; } - SequenceI [] getVisibleAndRepresentedSeqs() - { - if(hiddenSequences==null || hiddenSequences.getSize()<1) - return getSequencesArray(); - - Vector seqs = new Vector(); - SequenceI seq; - SequenceGroup hidden; - for (int i = 0; i < sequences.size(); i++) - { - seq = (SequenceI) sequences.elementAt(i); - seqs.addElement(seq); - hidden = seq.getHiddenSequences(); - if(hidden!=null) - { - for(int j=0; j