X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=b4e2b3f45be44f4ef1db3623dbf085a6b4aee2cc;hb=4944c2f33bb34b4f262fd2f3ae40dcdc2a825557;hp=338294b77bfab6ec444146bed2d39f3242c6e1a3;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 338294b..b4e2b3f 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -59,6 +59,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; as.getLength()) + { + sequences.removeElement(s); + j--; + jSize--; + } + else + { + s.setStart(newstart); + s.setSequence(s.getSequence().substring(i)); + } } } @@ -228,7 +248,8 @@ public class Alignment implements AlignmentI int newend = s.findPosition(i); s.setEnd(newend); - s.setSequence(s.getSequence().substring(0, i + 1)); + if(s.getLength()>i) + s.setSequence(s.getSequence().substring(0, i + 1)); } } @@ -369,47 +390,7 @@ public class Alignment implements AlignmentI return ret; } - /** - * DOCUMENT ME! - * - * @param sg DOCUMENT ME! - */ - public void addSuperGroup(SuperGroup sg) - { - superGroup.addElement(sg); - } - /** - * DOCUMENT ME! - * - * @param sg DOCUMENT ME! - */ - public void removeSuperGroup(SuperGroup sg) - { - superGroup.removeElement(sg); - } - - /** - * DOCUMENT ME! - * - * @param sg DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public SuperGroup getSuperGroup(SequenceGroup sg) - { - for (int i = 0; i < this.superGroup.size(); i++) - { - SuperGroup temp = (SuperGroup) superGroup.elementAt(i); - - if (temp.sequenceGroups.contains(sg)) - { - return temp; - } - } - - return null; - } /** */ public void addGroup(SequenceGroup sg) @@ -632,6 +613,85 @@ public class Alignment implements AlignmentI } /** + * + * @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() + { + if(annotations!=null) + { + for (int a = 0; a < annotations.length; a++) + { + if (annotations[a].sequenceRef != null) + { + annotations[a].adjustForAlignment(); + } + } + } + } + + /** * DOCUMENT ME! * * @param aa DOCUMENT ME! @@ -639,25 +699,48 @@ 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[aSize-1] = aa; + int i = 0; if (aSize > 1) { - for (i = 0; i < (aSize - 1); i++) + for (i = 0; i < (aSize-1); i++) { temp[i] = annotations[i]; } } - temp[i] = aa; + annotations = temp; + } + + public void setAnnotationIndex(AlignmentAnnotation aa, int index) + { + if(aa==null || annotations==null || annotations.length-1