}\r
\r
SequenceI refSeq = null;\r
+ String refSeqId = null;\r
public boolean readAnnotationFile(AlignmentI al,\r
String file,\r
String protocol)\r
\r
else if (token.equalsIgnoreCase("SEQUENCE_REF"))\r
{\r
- refSeq = al.findName(st.nextToken());\r
+ if (st.hasMoreTokens())\r
+ {\r
+ refSeq = al.findName(refSeqId=st.nextToken());\r
+ if (refSeq==null)\r
+ {\r
+ refSeqId=null;\r
+ }\r
try\r
{\r
refSeqIndex = Integer.parseInt(st.nextToken());\r
{\r
refSeqIndex = 1;\r
}\r
-\r
+ } else {\r
+ refSeq = null;\r
+ refSeqId = null;\r
+ }\r
continue ;\r
}\r
\r
if (refSeq != null)\r
{\r
annotation.belowAlignment=false;\r
- annotation.createSequenceMapping(refSeq, refSeqIndex, false);\r
- annotation.adjustForAlignment();\r
- refSeq.addAlignmentAnnotation(annotation);\r
- }\r
-\r
- al.addAnnotation(annotation);\r
-\r
- al.setAnnotationIndex(annotation,\r
+ do {\r
+ // copy before we do any mapping business.\r
+ // TODO: verify that undo/redo with 1:many sequence associated annotations can be undone correctly\r
+ AlignmentAnnotation ann = new AlignmentAnnotation(annotation);\r
+ annotation.createSequenceMapping(refSeq, refSeqIndex, false);\r
+ annotation.adjustForAlignment();\r
+ refSeq.addAlignmentAnnotation(annotation);\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r
+ al.getAlignmentAnnotation().length - existingAnnotations -\r
+ 1);\r
+ // and recover our virgin copy to use again if necessary.\r
+ annotation = ann;\r
+ \r
+ } while (refSeqId!=null && (refSeq=al.findName(refSeq, refSeqId, true))!=null);\r
+ } else {\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r
al.getAlignmentAnnotation().length - existingAnnotations -\r
1);\r
+ }\r
}\r
\r
}\r