From 133454102814512287d6bb5b1f4e5c2601eea863 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 10 May 2006 12:56:30 +0000 Subject: [PATCH] Create sequence mapping for annotations --- src/jalview/datamodel/AlignmentAnnotation.java | 68 +++++++++++++++++++----- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index c3ccb0b..d75683c 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -29,11 +29,6 @@ public class AlignmentAnnotation { public SequenceI sequenceRef; - /** This annotation is the original loaded annotation - * without any gaps. It is necessary to adjust the annotation - * if sequences are updated */ - public AlignmentAnnotation datasetAnnotation; - /** DOCUMENT ME!! */ public String label; @@ -43,6 +38,7 @@ public class AlignmentAnnotation /** DOCUMENT ME!! */ public Annotation[] annotations; + public java.util.Hashtable sequenceMapping; /** DOCUMENT ME!! */ public float graphMin; @@ -243,21 +239,65 @@ public class AlignmentAnnotation return threshold; } + /** + * This + */ + public void createSequenceMapping(SequenceI seqRef, int startRes) + { + if(seqRef == null) + return; + + sequenceMapping = new java.util.Hashtable(); + + sequenceRef = seqRef; + + if(startRes < sequenceRef.getStart()) + startRes = sequenceRef.getStart(); + + int seqPos, seqIndex; + + int fileOffset = 0; + if(startRes > sequenceRef.getStart()) + { + fileOffset = startRes - sequenceRef.getStart(); + } + + for(int i = 0; i < annotations.length; i++) + { + seqPos = sequenceRef.findPosition(i - fileOffset)-1; + if(seqPos=startRes) + sequenceMapping.put(new Integer(seqIndex), + annotations[seqPos]); + } + } + } + + adjustForAlignment(); + + } + public void adjustForAlignment() { int a=0, aSize = sequenceRef.getLength(); - int index = 0; + int position; Annotation[] temp = new Annotation[aSize]; - - for (a = 0; a < aSize; a++) + Integer index; + for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++) { - if (!jalview.util.Comparison.isGap(sequenceRef.getCharAt(a))) - { - index = sequenceRef.findPosition(a); - if(datasetAnnotation.annotations.length>index) - temp[a] = datasetAnnotation.annotations[index]; - } + index = new Integer(a); + if(sequenceMapping.containsKey(index)) + { + position = sequenceRef.findIndex(a)-1; + + temp[position] = (Annotation)sequenceMapping.get(index); + } } annotations = temp; -- 1.7.10.2