From e0a4b92352ee3e31a8dea075a51ec080ae3945f2 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 3 Feb 2006 17:40:26 +0000 Subject: [PATCH] Add annotation with sequence ref updated --- src/jalview/datamodel/Alignment.java | 126 ++++++++++++++++++++---- src/jalview/datamodel/AlignmentAnnotation.java | 29 +++++- src/jalview/datamodel/AlignmentI.java | 6 +- 3 files changed, 140 insertions(+), 21 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 2545ec1..78aa015 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; 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 +739,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-1index) + temp[a] = datasetAnnotation.annotations[index]; + } + } + + annotations = temp; + } } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 69a5ac6..ebd95d9 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -251,7 +251,9 @@ public interface AlignmentI * Adds a new AlignmentAnnotation to this alignment, * associated to Sequence starting at sequence index */ - public void addAnnotation(AlignmentAnnotation aa, SequenceI seqRef, int index); + public AlignmentAnnotation addAnnotation(AlignmentAnnotation aa, SequenceI seqRef); + + public void setAnnotationIndex(AlignmentAnnotation aa, int index); /** * Deletes a specific AlignmentAnnotation from the alignment. @@ -312,5 +314,7 @@ public interface AlignmentI */ public boolean padGaps(); + public void adjustSequenceAnnotations(); + } -- 1.7.10.2