X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=f3d17b4dcbcafc627801c13d78eb908acec69b11;hb=cd71fb9ef1a21678ad648ba13564b658b53ab834;hp=78aa0157bce1cd05116da3335415de48165853a7;hpb=e0a4b92352ee3e31a8dea075a51ec080ae3945f2;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 78aa015..f3d17b4 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -24,7 +24,6 @@ import jalview.util.*; import java.util.*; - /** Data structure to hold and manipulate a multiple sequence alignment */ public class Alignment implements AlignmentI @@ -32,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; @@ -41,6 +39,9 @@ public class Alignment implements AlignmentI /** DOCUMENT ME!! */ public AlignmentAnnotation[] annotations; + HiddenSequences hiddenSequences = new HiddenSequences(this); + + /** Make an alignment from an array of Sequences. * * @param sequences @@ -59,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 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() { @@ -848,19 +731,48 @@ 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; } + + public HiddenSequences getHiddenSequences() + { + return hiddenSequences; + } + }