X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=5f0bf6884fc9fabbb7acdec470c31a9e0c50bf10;hb=d6e1bbede5adc04f34c969213ac6a4c6d9e5d34a;hp=00d1be8ce452ddae2132c82a52afcc684a5efadb;hpb=f14d234620501b7b5024a9f98e94c520641e7a09;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 00d1be8..5f0bf68 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -31,7 +31,6 @@ public class Alignment implements AlignmentI protected Alignment dataset; protected Vector sequences; protected Vector groups = new Vector(); - protected Vector superGroup = new Vector(); protected char gapCharacter = '-'; protected int type = NUCLEOTIDE; public static final int PROTEIN = 0; @@ -61,19 +60,7 @@ public class Alignment implements AlignmentI for (i = 0; i < seqs.length; i++) { sequences.addElement(seqs[i]); - - if(seqs[i].getDatasetSequence()!=null - && seqs[i].getDatasetSequence().getAnnotation()!=null) - { - - for(int a=0; a= threshold) - { - // Delete the shortest one - if (((SequenceI) sel.elementAt(j)).getSequence().length() > ((SequenceI) sel - .elementAt( - i)).getSequence().length()) - { - del.addElement(sel.elementAt(i)); - } - else - { - del.addElement(sel.elementAt(i)); - } - } - } - } - } - - // Now delete the sequences - for (int i = 0; i < del.size(); i++) - { - deleteSequence((SequenceI) del.elementAt(i)); - } - - return del; - } - - /** */ - public SequenceGroup findGroup(int i) - { - return findGroup(getSequenceAt(i)); - } /** */ public SequenceGroup findGroup(SequenceI s) @@ -345,7 +285,7 @@ public class Alignment implements AlignmentI { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if (sg.sequences.contains(s)) + if (sg.getSequences(false).contains(s)) { return sg; } @@ -369,14 +309,14 @@ public class Alignment implements AlignmentI for (int i = 0; i < gSize; i++) { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if(sg==null || sg.sequences==null) + if(sg==null || sg.getSequences(false)==null) { this.deleteGroup(sg); gSize--; continue; } - if (sg.sequences.contains(s)) + if (sg.getSequences(false).contains(s)) { temp.addElement(sg); } @@ -409,7 +349,6 @@ public class Alignment implements AlignmentI public void deleteAllGroups() { groups.removeAllElements(); - superGroup.removeAllElements(); int i = 0; @@ -536,9 +475,9 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { Sequence seq = (Sequence) sequences.elementAt(i); - seq.sequence = seq.sequence.replace('.', gc); - seq.sequence = seq.sequence.replace('-', gc); - seq.sequence = seq.sequence.replace(' ', gc); + seq.setSequence( seq.getSequence().replace('.', gc) ); + seq.setSequence( seq.getSequence().replace('-', gc) ); + seq.setSequence( seq.getSequence().replace(' ', gc) ); } } @@ -614,70 +553,6 @@ public class Alignment implements AlignmentI annotations = temp; } - /** - * - * @param aa AlignmentAnnotation - * @param seqRef The sequence to associate this annotation with - * @return The adjusted AlignmentAnnotation, with dataset sequence and annotation added - */ - public AlignmentAnnotation addAnnotation(AlignmentAnnotation aa, SequenceI seqRef) - { - if(seqRef!=null) - { - //We can only add Annotations to the dataset sequences - if(seqRef.getDatasetSequence()==null) - { - setDataset(null); - } - - AlignmentAnnotation [] old = seqRef.getDatasetSequence().getAnnotation(); - - //First check if this is a new annotation or not. If it is new, - //we must add the annotation to the dataset - boolean newAnnotation = true; - if(seqRef.getDatasetSequence().getAnnotation()!=null) - { - for(int a=0; a 0) - copy = new AlignmentAnnotation( - aa.label, aa.description, aa.annotations, aa.graphMin, - aa.graphMax, aa.graph - ); - else - copy = new AlignmentAnnotation( - aa.label, aa.description, aa.annotations - ); - - copy.datasetAnnotation = aa; - - addAnnotation(copy); - - copy.sequenceRef = seqRef; - - return copy; - } - else - { - addAnnotation(aa); - return aa; - } - } public void adjustSequenceAnnotations() { @@ -810,18 +685,41 @@ public class Alignment implements AlignmentI public boolean padGaps() { boolean modified=false; - int Width = getWidth(); + + //Remove excess gaps from the end of alignment + int maxLength = -1; + SequenceI current; + for (int i = 0; i < sequences.size(); i++) + { + current = getSequenceAt(i); + for (int j = current.getLength(); j > maxLength; j--) + { + if (j > maxLength && !jalview.util.Comparison.isGap( + current.getCharAt(j))) + { + maxLength = j; + break; + } + } + } + + maxLength++; + for (int i = 0; i < sequences.size(); i++) { current = getSequenceAt(i); - if (current.getLength() < Width) + if (current.getLength() < maxLength) { - current.insertCharAt(Width - 1, gapCharacter); + current.insertCharAt(maxLength - 1, gapCharacter); modified=true; } + else if(current.getLength() > maxLength) + { + current.deleteChars(maxLength, current.getLength()); + } } return modified; }