X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=b0b04cae8739551cd24ee5b045d62d5391d81b01;hb=1ed150e97b6a7df6ebe5cf92ead96cd147a58b7e;hp=2545ec1355a8d852ea3201da6ddc9048fd9addf8;hpb=7e4c4ad887a30dc26496087b0150f4ac2fe355ec;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 2545ec1..b0b04ca 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 @@ -41,6 +40,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,6 +61,16 @@ 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; + } + } - addAnnotation(aa); + public void adjustSequenceAnnotations() + { + if(annotations!=null) + { + for (int a = 0; a < annotations.length; a++) + { + if (annotations[a].sequenceRef != null) + { + annotations[a].adjustForAlignment(); + } + } + } } /** @@ -671,30 +701,52 @@ public class Alignment implements AlignmentI public void addAnnotation(AlignmentAnnotation aa) { int aSize = 1; - if (annotations != null) { aSize = annotations.length + 1; } - AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize]; - temp[0] = aa; + temp[aSize-1] = aa; - int i = 1; + int i = 0; if (aSize > 1) { - for (i = 1; i < (aSize); i++) + for (i = 0; i < (aSize-1); i++) { - temp[i] = annotations[i-1]; + temp[i] = annotations[i]; } } annotations = temp; } + public void setAnnotationIndex(AlignmentAnnotation aa, int index) + { + if(aa==null || annotations==null || annotations.length-1 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; + } + }