X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=f255ab5394923aa85dbdf2fae447ed95c377fd66;hb=d8412f9b4ca9533eb56dc48e1d2273ee0e45bf3f;hp=288c28a76f54e9f61be0cf3a0b7cc4d4e29b720b;hpb=fbb18baad3919cbf94fcb5159bbd5269d6af18b4;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 288c28a..f255ab5 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,9 @@ 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) ); + seq.setSequence( seq.getSequenceAsString().replace('-', gc) ); + seq.setSequence( seq.getSequenceAsString().replace(' ', gc) ); } } @@ -464,15 +470,53 @@ public class Alignment implements AlignmentI } - public void adjustSequenceAnnotations() + public void adjustSequenceAnnotations(int position, + int number, + boolean insert) { if(annotations!=null) { + int aSize, tSize; + Annotation [] temp; for (int a = 0; a < annotations.length; a++) { - if (annotations[a].sequenceRef != null) + if(annotations[a].autoCalculated) + { + System.out.println("ignore "+annotations[a].label); + continue; + } + aSize = annotations[a].annotations.length; + if(insert) + tSize = aSize + number; + else + tSize = aSize - number; + + temp = new Annotation[tSize]; + + if(insert) + { + System.arraycopy(annotations[a].annotations, + 0, temp, 0, position); + + System.arraycopy(annotations[a].annotations, + position, temp, position+number, aSize - position); + } + else { - annotations[a].adjustForAlignment(); + System.arraycopy(annotations[a].annotations, + 0, temp, 0, position); + + System.arraycopy(annotations[a].annotations, + position + number, temp, position, + aSize - position - number); + } + + annotations[a].annotations = temp; + + + // if (annotations[a].sequenceRef != null) + { + // annotations[a].adjustForAlignment(); } } } @@ -579,7 +623,7 @@ public class Alignment implements AlignmentI seqs[i] = new Sequence(currentSeq.getName(), AlignSeq.extractGaps( jalview.util.Comparison.GapChars, - currentSeq.getSequence() + currentSeq.getSequenceAsString() ), currentSeq.getStart(), currentSeq.getEnd()); @@ -652,34 +696,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