2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.bin.Cache;
24 import jalview.datamodel.AlignedCodonFrame;
25 import jalview.datamodel.AlignmentAnnotation;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.GraphLine;
28 import jalview.datamodel.SequenceI;
29 import jalview.gui.AlignFrame;
30 import jalview.gui.AlignViewport;
31 import jalview.gui.Desktop;
32 import jalview.gui.TreePanel;
33 import jalview.io.vamsas.Datasetsequence;
34 import jalview.io.vamsas.DatastoreItem;
35 import jalview.io.vamsas.DatastoreRegistry;
36 import jalview.io.vamsas.Rangetype;
37 import jalview.util.MapList;
38 import jalview.util.MessageManager;
39 import jalview.viewmodel.AlignmentViewport;
41 import java.io.IOException;
42 import java.util.Enumeration;
43 import java.util.HashMap;
44 import java.util.Hashtable;
45 import java.util.IdentityHashMap;
46 import java.util.Iterator;
47 import java.util.List;
49 import java.util.Vector;
50 import java.util.jar.JarInputStream;
51 import java.util.jar.JarOutputStream;
53 import uk.ac.vamsas.client.IClientAppdata;
54 import uk.ac.vamsas.client.IClientDocument;
55 import uk.ac.vamsas.client.Vobject;
56 import uk.ac.vamsas.client.VorbaId;
57 import uk.ac.vamsas.objects.core.Alignment;
58 import uk.ac.vamsas.objects.core.AlignmentSequence;
59 import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation;
60 import uk.ac.vamsas.objects.core.AnnotationElement;
61 import uk.ac.vamsas.objects.core.DataSet;
62 import uk.ac.vamsas.objects.core.DataSetAnnotations;
63 import uk.ac.vamsas.objects.core.DbRef;
64 import uk.ac.vamsas.objects.core.Entry;
65 import uk.ac.vamsas.objects.core.Glyph;
66 import uk.ac.vamsas.objects.core.Local;
67 import uk.ac.vamsas.objects.core.MapType;
68 import uk.ac.vamsas.objects.core.Mapped;
69 import uk.ac.vamsas.objects.core.Property;
70 import uk.ac.vamsas.objects.core.Provenance;
71 import uk.ac.vamsas.objects.core.RangeAnnotation;
72 import uk.ac.vamsas.objects.core.RangeType;
73 import uk.ac.vamsas.objects.core.Seg;
74 import uk.ac.vamsas.objects.core.Sequence;
75 import uk.ac.vamsas.objects.core.SequenceType;
76 import uk.ac.vamsas.objects.core.VAMSAS;
77 import uk.ac.vamsas.objects.utils.Properties;
82 * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty(
83 * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); }
87 * TODO: check/verify consistency for vamsas sync with group associated alignment annotation
89 public class VamsasAppDatastore
92 * Type used for general jalview generated annotation added to vamsas document
94 public static final String JALVIEW_ANNOTATION_ROW = "JalviewAnnotation";
97 * AlignmentAnnotation property to indicate that values should not be
100 public static final String DISCRETE_ANNOTATION = "discrete";
103 * continuous property - optional to specify that annotation should be
104 * represented as a continous graph line
106 private static final String CONTINUOUS_ANNOTATION = "continuous";
108 private static final String THRESHOLD = "threshold";
111 * template for provenance entries written to vamsas session document
113 Entry provEntry = null;
116 * Instance of the session document being synchronized with
118 IClientDocument cdoc;
121 * map Vorba (vamsas object xml ref) IDs to live jalview object references
126 * map live jalview object references to Vorba IDs
128 IdentityHashMap jv2vobj;
131 * map jalview sequence set ID (which is vorba ID for alignment) to last
132 * recorded hash value for the alignment viewport (the undo/redo hash value)
134 Hashtable alignRDHash;
136 public VamsasAppDatastore(IClientDocument cdoc, Hashtable vobj2jv,
137 IdentityHashMap jv2vobj, Entry provEntry, Hashtable alignRDHash)
140 this.vobj2jv = vobj2jv;
141 this.jv2vobj = jv2vobj;
142 this.provEntry = provEntry;
143 this.alignRDHash = alignRDHash;
148 * the skipList used to skip over views from Jalview Appdata's that we've
149 * already syncrhonized
153 private void buildSkipList()
155 skipList = new Hashtable();
156 AlignFrame[] al = Desktop.getAlignFrames();
157 for (int f = 0; al != null && f < al.length; f++)
159 skipList.put(al[f].getViewport().getSequenceSetId(), al[f]);
164 * @return the Vobject bound to Jalview datamodel object
166 protected Vobject getjv2vObj(Object jvobj)
168 if (jv2vobj.containsKey(jvobj))
170 return cdoc.getObject((VorbaId) jv2vobj.get(jvobj));
172 // check if we're working with a string - then workaround
173 // the use of IdentityHashTable because different strings
174 // have different object IDs.
175 if (jvobj instanceof String)
177 Object seqsetidobj = null;
178 seqsetidobj = getVamsasObjectBinding().get(jvobj);
179 if (seqsetidobj != null)
181 if (seqsetidobj instanceof String)
183 // what is expected. object returned by av.getSequenceSetId() -
184 // reverse lookup to get the 'registered' instance of this string
185 Vobject obj = getjv2vObj(seqsetidobj);
186 if (obj != null && !(obj instanceof Alignment))
189 .warn("IMPLEMENTATION ERROR?: Unexpected mapping for unmapped jalview string object content:"
190 + seqsetidobj + " to object " + obj);
196 Cache.log.warn("Unexpected mapping for Jalview String Object ID "
197 + seqsetidobj + " to another jalview dataset object "
203 if (Cache.log.isDebugEnabled())
205 Cache.log.debug("Returning null VorbaID binding for jalview object "
214 * @return Jalview datamodel object bound to the vamsas document object
216 protected Object getvObj2jv(uk.ac.vamsas.client.Vobject vobj)
218 VorbaId id = vobj.getVorbaId();
221 id = cdoc.registerObject(vobj);
223 .debug("Registering new object and returning null for getvObj2jv");
226 if (vobj2jv.containsKey(vobj.getVorbaId()))
228 return vobj2jv.get(vobj.getVorbaId());
233 protected void bindjvvobj(Object jvobj, uk.ac.vamsas.client.Vobject vobj)
235 VorbaId id = vobj.getVorbaId();
238 id = cdoc.registerObject(vobj);
239 if (id == null || vobj.getVorbaId() == null
240 || cdoc.getObject(id) != vobj)
242 Cache.log.error("Failed to get id for "
243 + (vobj.isRegisterable() ? "registerable"
244 : "unregisterable") + " object " + vobj);
248 if (vobj2jv.containsKey(vobj.getVorbaId())
249 && !((VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
252 "Warning? Overwriting existing vamsas id binding for "
253 + vobj.getVorbaId(), new Exception(MessageManager.getString("exception.overwriting_vamsas_id_binding")));
255 else if (jv2vobj.containsKey(jvobj)
256 && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
259 "Warning? Overwriting existing jalview object binding for "
260 + jvobj, new Exception(
261 "Overwriting jalview object binding."));
264 * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
265 * +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+"
266 * already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to
269 // we just update the hash's regardless!
270 Cache.log.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
271 vobj2jv.put(vobj.getVorbaId(), jvobj);
272 // JBPNote - better implementing a hybrid invertible hash.
273 jv2vobj.put(jvobj, vobj.getVorbaId());
277 * put the alignment viewed by AlignViewport into cdoc.
280 * alignViewport to be stored
282 * title for alignment
283 * @return true if alignment associated with viewport was stored/synchronized
286 public boolean storeVAMSAS(AlignViewport av, String aFtitle)
290 AlignmentI jal = av.getAlignment();
291 AlignmentI jds = jal.getDataset();
293 VAMSAS root = null; // will be resolved based on Dataset Parent.
294 // /////////////////////////////////////////
296 DataSet dataset = null;
299 Cache.log.warn("Creating new dataset for an alignment.");
300 jal.setDataset(null);
301 jds = jal.getDataset();
304 // try and get alignment and association for sequence set id
306 Alignment alignment = (Alignment) getjv2vObj(av.getSequenceSetId());
307 if (alignment != null)
309 dataset = (DataSet) alignment.getV_parent();
313 // is the dataset already registered
314 dataset = (DataSet) getjv2vObj(jds);
319 // it might be that one of the dataset sequences does actually have a
320 // binding, so search for it indirectly. If it does, then the local
322 // must be merged with the existing vamsas dataset.
323 jalview.datamodel.SequenceI[] jdatset = jds.getSequencesArray();
324 for (int i = 0; i < jdatset.length; i++)
326 Vobject vbound = getjv2vObj(jdatset[i]);
329 if (vbound instanceof uk.ac.vamsas.objects.core.Sequence)
333 dataset = (DataSet) vbound.getV_parent();
337 if (vbound.getV_parent() != null
338 && dataset != vbound.getV_parent())
340 throw new Error(MessageManager.getString("error.implementation_error_cannot_map_alignment_sequences"));
341 // This occurs because the dataset for the alignment we are
352 Cache.log.warn("Creating new vamsas dataset for alignment view "
353 + av.getSequenceSetId());
354 // we create a new dataset on the default vamsas root.
355 root = cdoc.getVamsasRoots()[0]; // default vamsas root for modifying.
356 dataset = new DataSet();
357 root.addDataSet(dataset);
358 bindjvvobj(jds, dataset);
359 dataset.setProvenance(dummyProvenance());
360 // dataset.getProvenance().addEntry(provEntry);
365 root = (VAMSAS) dataset.getV_parent();
369 // set new dataset and alignment sequences based on alignment Nucleotide
371 // this *will* break when alignment contains both nucleotide and amino
373 String dict = jal.isNucleotide() ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
374 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA;
375 Vector dssmods = new Vector();
376 for (int i = 0; i < jal.getHeight(); i++)
378 SequenceI sq = jal.getSequenceAt(i).getDatasetSequence(); // only insert
382 Datasetsequence dssync = new jalview.io.vamsas.Datasetsequence(
383 this, sq, dict, dataset);
384 sequence = (Sequence) dssync.getVobj();
385 if (dssync.getModified())
387 dssmods.addElement(sequence);
391 if (dssmods.size() > 0)
395 Entry pentry = this.addProvenance(dataset.getProvenance(),
396 "updated sequences");
397 // pentry.addInput(vInput); could write in which sequences were
399 dssmods.removeAllElements();
402 // dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));
403 // ////////////////////////////////////////////
404 if (alignmentWillBeSkipped(av))
406 // TODO: trees could be written - but for the moment we just
408 // add to the JalviewXML skipList and ..
412 if (alignment == null)
414 alignment = new Alignment();
415 bindjvvobj(av.getSequenceSetId(), alignment);
416 if (alignment.getProvenance() == null)
418 alignment.setProvenance(new Provenance());
420 addProvenance(alignment.getProvenance(), "added"); // TODO: insert some
423 dataset.addAlignment(alignment);
425 Property title = new Property();
426 title.setName("title");
427 title.setType("string");
428 title.setContent(aFtitle);
429 alignment.addProperty(title);
431 alignment.setGapChar(String.valueOf(av.getGapCharacter()));
432 for (int i = 0; i < jal.getHeight(); i++)
434 syncToAlignmentSequence(jal.getSequenceAt(i), alignment, null);
436 alignRDHash.put(av.getSequenceSetId(), av.getUndoRedoHash());
440 // always prepare to clone the alignment
441 boolean alismod = av.isUndoRedoHashModified((long[]) alignRDHash
442 .get(av.getSequenceSetId()));
443 // todo: verify and update mutable alignment props.
444 // TODO: Use isLocked methods
445 if (alignment.getModifiable() == null
446 || alignment.getModifiable().length() == 0)
447 // && !alignment.isDependedOn())
449 boolean modified = false;
450 // check existing sequences in local and in document.
451 Vector docseqs = new Vector(
452 alignment.getAlignmentSequenceAsReference());
453 for (int i = 0; i < jal.getHeight(); i++)
455 modified |= syncToAlignmentSequence(jal.getSequenceAt(i),
458 if (docseqs.size() > 0)
460 // removeValignmentSequences(alignment, docseqs);
461 docseqs.removeAllElements();
463 .println("Sequence deletion from alignment is not implemented.");
471 addProvenance(alignment.getProvenance(), "Edited"); // TODO:
480 addProvenance(alignment.getProvenance(), "Attributes Edited"); // TODO:
490 System.out.println("update alignment in document.");
494 System.out.println("alignment in document left unchanged.");
499 // unbind alignment from view.
500 // create new binding and new alignment.
501 // mark trail on new alignment as being derived from old ?
503 .println("update edited alignment to new alignment in document.");
506 // ////////////////////////////////////////////
507 // SAVE Alignment Sequence Features
508 for (int i = 0, iSize = alignment.getAlignmentSequenceCount(); i < iSize; i++)
510 AlignmentSequence valseq;
511 SequenceI alseq = (SequenceI) getvObj2jv(valseq = alignment
512 .getAlignmentSequence(i));
513 if (alseq != null && alseq.getSequenceFeatures() != null)
516 * We do not put local Alignment Sequence Features into the vamsas
520 * jalview.datamodel.SequenceFeature[] features = alseq
521 * .getSequenceFeatures(); for (int f = 0; f < features.length; f++) {
522 * if (features[f] != null) { AlignmentSequenceAnnotation valseqf = (
523 * AlignmentSequenceAnnotation) getjv2vObj(features[i]); if (valseqf
526 * valseqf = (AlignmentSequenceAnnotation) getDSAnnotationFromJalview(
527 * new AlignmentSequenceAnnotation(), features[i]);
528 * valseqf.setGraph(false);
529 * valseqf.addProperty(newProperty("jalview:feature"
530 * ,"boolean","true")); if (valseqf.getProvenance() == null) {
531 * valseqf.setProvenance(new Provenance()); }
532 * addProvenance(valseqf.getProvenance(), "created"); // JBPNote - //
533 * need to // update bindjvvobj(features[i], valseqf);
534 * valseq.addAlignmentSequenceAnnotation(valseqf); } } }
539 // ////////////////////////////////////////////
541 if (jal.getAlignmentAnnotation() != null)
543 AlignmentAnnotation[] aa = jal
544 .getAlignmentAnnotation();
545 java.util.HashMap AlSeqMaps = new HashMap(); // stores int maps from
546 // alignment columns to
547 // sequence positions.
548 for (int i = 0; i < aa.length; i++)
550 if (aa[i] == null || isJalviewOnly(aa[i]))
554 if (aa[i].groupRef != null)
556 // TODO: store any group associated annotation references
558 .warn("Group associated sequence annotation is not stored in VAMSAS document.");
561 if (aa[i].sequenceRef != null)
563 // Deal with sequence associated annotation
564 Vobject sref = getjv2vObj(aa[i].sequenceRef);
565 if (sref instanceof uk.ac.vamsas.objects.core.AlignmentSequence)
567 saveAlignmentSequenceAnnotation(AlSeqMaps,
568 (AlignmentSequence) sref, aa[i]);
572 // first find the alignment sequence to associate this with.
573 for (SequenceI jvalsq : av.getAlignment().getSequences())
575 // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence)
577 if (jvalsq.getDatasetSequence() == aa[i].sequenceRef)
579 Vobject alsref = getjv2vObj(jvalsq);
580 saveAlignmentSequenceAnnotation(AlSeqMaps,
581 (AlignmentSequence) alsref, aa[i]);
590 // add Alignment Annotation
591 uk.ac.vamsas.objects.core.AlignmentAnnotation an = (uk.ac.vamsas.objects.core.AlignmentAnnotation) getjv2vObj(aa[i]);
594 an = new uk.ac.vamsas.objects.core.AlignmentAnnotation();
595 an.setType(JALVIEW_ANNOTATION_ROW);
596 an.setDescription(aa[i].description);
597 alignment.addAlignmentAnnotation(an);
598 Seg vSeg = new Seg(); // TODO: refactor to have a default
599 // rangeAnnotationType initer/updater that
600 // takes a set of int ranges.
602 vSeg.setInclusive(true);
603 vSeg.setEnd(jal.getWidth());
607 an.setGraph(true); // aa[i].graph);
609 an.setLabel(aa[i].label);
610 an.setProvenance(dummyProvenance());
611 if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
613 an.setGroup(Integer.toString(aa[i].graphGroup)); // // JBPNote
628 AnnotationElement ae;
630 for (int a = 0; a < aa[i].annotations.length; a++)
632 if ((aa[i] == null) || (aa[i].annotations[a] == null))
637 ae = new AnnotationElement();
638 ae.setDescription(aa[i].annotations[a].description);
639 ae.addGlyph(new Glyph());
640 ae.getGlyph(0).setContent(
641 aa[i].annotations[a].displayCharacter); // assume
650 ae.addValue(aa[i].annotations[a].value);
652 ae.setPosition(a + 1);
653 if (aa[i].annotations[a].secondaryStructure != ' ')
655 Glyph ss = new Glyph();
656 ss.setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
658 .valueOf(aa[i].annotations[a].secondaryStructure));
661 an.addAnnotationElement(ae);
665 // an.addProperty(newProperty("jalview:editable", null,
667 // an.setModifiable(""); // TODO: This is not the way the
668 // modifiable flag is supposed to be used.
670 setAnnotationType(an, aa[i]);
672 if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
675 an.setGroup(Integer.toString(aa[i].graphGroup));
676 if (aa[i].threshold != null && aa[i].threshold.displayed)
678 an.addProperty(Properties.newProperty(THRESHOLD,
679 Properties.FLOATTYPE, "" + aa[i].threshold.value));
680 if (aa[i].threshold.label != null)
682 an.addProperty(Properties.newProperty(THRESHOLD
683 + "Name", Properties.STRINGTYPE, ""
684 + aa[i].threshold.label));
693 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT
696 // verify annotation - update (perhaps)
698 .info("update alignment sequence annotation. not yet implemented.");
702 // verify annotation - update (perhaps)
704 .info("updated alignment sequence annotation added.");
710 // /////////////////////////////////////////////////////
712 // //////////////////////////////////////////////
714 // /////////////////////////////////
715 // FIND ANY ASSOCIATED TREES
716 if (Desktop.desktop != null)
718 javax.swing.JInternalFrame[] frames = Desktop.instance
721 for (int t = 0; t < frames.length; t++)
723 if (frames[t] instanceof TreePanel)
725 TreePanel tp = (TreePanel) frames[t];
727 if (tp.getViewPort().getSequenceSetId()
728 .equals(av.getSequenceSetId()))
730 DatastoreItem vtree = new jalview.io.vamsas.Tree(this, tp,
736 // Store Jalview specific stuff in the Jalview appData
737 // not implemented in the SimpleDoc interface.
742 ex.printStackTrace();
749 * very quick test to see if the viewport would be stored in the vamsas
750 * document. Reasons for not storing include the unaligned flag being false
751 * (for all sequences, including the hidden ones!)
754 * @return true if alignment associated with this view will be stored in
757 public boolean alignmentWillBeSkipped(AlignmentViewport av)
759 return (!av.getAlignment().isAligned());
762 private void addToSkipList(AlignmentViewport av)
764 if (skipList == null)
766 skipList = new Hashtable();
768 skipList.put(av.getSequenceSetId(), av);
772 * remove docseqs from the given alignment marking provenance appropriately
773 * and removing any references to the sequences.
778 private void removeValignmentSequences(Alignment alignment, Vector docseqs)
780 // delete these from document. This really needs to be a generic document
781 // API function derived by CASTOR.
782 Enumeration en = docseqs.elements();
783 while (en.hasMoreElements())
785 alignment.removeAlignmentSequence((AlignmentSequence) en
788 Entry pe = addProvenance(alignment.getProvenance(), "Removed "
789 + docseqs.size() + " sequences");
790 en = alignment.enumerateAlignmentAnnotation();
791 Vector toremove = new Vector();
792 while (en.hasMoreElements())
794 uk.ac.vamsas.objects.core.AlignmentAnnotation alan = (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
796 if (alan.getSeqrefsCount() > 0)
799 Vector storem = new Vector();
800 Enumeration sr = alan.enumerateSeqrefs();
801 while (sr.hasMoreElements())
803 Object alsr = sr.nextElement();
804 if (docseqs.contains(alsr))
806 storem.addElement(alsr);
809 // remove references to the deleted sequences
810 sr = storem.elements();
811 while (sr.hasMoreElements())
813 alan.removeSeqrefs(sr.nextElement());
816 if (alan.getSeqrefsCount() == 0)
818 // should then delete alan from dataset
819 toremove.addElement(alan);
823 // remove any annotation that used to be associated to a specific bunch of
825 en = toremove.elements();
826 while (en.hasMoreElements())
829 .removeAlignmentAnnotation((uk.ac.vamsas.objects.core.AlignmentAnnotation) en
832 // TODO: search through alignment annotations to remove any references to
833 // this alignment sequence
837 * sync a jalview alignment seuqence into a vamsas alignment assumes all lock
838 * transformation/bindings have been sorted out before hand. creates/syncs the
839 * vamsas alignment sequence for jvalsq and adds it to the alignment if
840 * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
841 * and these are removed after being processed w.r.t a bound jvalsq
844 private boolean syncToAlignmentSequence(SequenceI jvalsq,
845 Alignment alignment, Vector unbounddocseq)
847 boolean modal = false;
848 // todo: islocked method here
849 boolean up2doc = false;
850 AlignmentSequence alseq = (AlignmentSequence) getjv2vObj(jvalsq);
853 alseq = new AlignmentSequence();
858 if (unbounddocseq != null)
860 unbounddocseq.removeElement(alseq);
863 // boolean locked = (alignment.getModifiable()==null ||
864 // alignment.getModifiable().length()>0);
865 // TODO: VAMSAS: translate lowercase symbols to annotation ?
866 if (up2doc || !alseq.getSequence().equals(jvalsq.getSequenceAsString()))
868 alseq.setSequence(jvalsq.getSequenceAsString());
869 alseq.setStart(jvalsq.getStart());
870 alseq.setEnd(jvalsq.getEnd());
873 if (up2doc || !alseq.getName().equals(jvalsq.getName()))
876 alseq.setName(jvalsq.getName());
878 if (jvalsq.getDescription() != null
879 && (alseq.getDescription() == null || !jvalsq.getDescription()
880 .equals(alseq.getDescription())))
883 alseq.setDescription(jvalsq.getDescription());
885 if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
888 .warn("Serious Implementation error - Unbound dataset sequence in alignment: "
889 + jvalsq.getDatasetSequence());
891 alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
895 alignment.addAlignmentSequence(alseq);
896 bindjvvobj(jvalsq, alseq);
898 return up2doc || modal;
902 * locally sync a jalview alignment seuqence from a vamsas alignment assumes
903 * all lock transformation/bindings have been sorted out before hand.
904 * creates/syncs the jvalsq from the alignment sequence
906 private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
907 char valGapchar, char gapChar, List<SequenceI> dsseqs)
910 boolean modal = false;
911 // todo: islocked method here
912 boolean upFromdoc = false;
913 jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
921 // boolean locked = (alignment.getModifiable()==null ||
922 // alignment.getModifiable().length()>0);
923 // TODO: VAMSAS: translate lowercase symbols to annotation ?
925 || !valseq.getSequence().equals(alseq.getSequenceAsString()))
927 // this might go *horribly* wrong
928 alseq.setSequence(new String(valseq.getSequence()).replace(
929 valGapchar, gapChar));
930 alseq.setStart((int) valseq.getStart());
931 alseq.setEnd((int) valseq.getEnd());
934 if (!valseq.getName().equals(alseq.getName()))
937 alseq.setName(valseq.getName());
939 if (alseq.getDescription() == null
940 || (valseq.getDescription() != null && !alseq
941 .getDescription().equals(valseq.getDescription())))
943 alseq.setDescription(valseq.getDescription());
946 if (modal && Cache.log.isDebugEnabled())
948 Cache.log.debug("Updating apparently edited sequence "
954 alseq = new jalview.datamodel.Sequence(valseq.getName(), valseq
955 .getSequence().replace(valGapchar, gapChar),
956 (int) valseq.getStart(), (int) valseq.getEnd());
958 Vobject datsetseq = (Vobject) valseq.getRefid();
959 if (datsetseq != null)
961 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
962 if (valseq.getDescription() != null)
964 alseq.setDescription(valseq.getDescription());
968 // inherit description line from dataset.
969 if (alseq.getDatasetSequence().getDescription() != null)
971 alseq.setDescription(alseq.getDatasetSequence()
986 .error("Invalid dataset sequence id (null) for alignment sequence "
987 + valseq.getVorbaId());
989 bindjvvobj(alseq, valseq);
990 alseq.setVamsasId(valseq.getVorbaId().getId());
993 Vobject datsetseq = (Vobject) valseq.getRefid();
994 if (datsetseq != null)
996 if (datsetseq != alseq.getDatasetSequence())
1000 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
1002 return upFromdoc || modal;
1005 private void initRangeAnnotationType(RangeAnnotation an,
1006 AlignmentAnnotation alan, int[] gapMap)
1008 Seg vSeg = new Seg();
1010 vSeg.setInclusive(true);
1011 vSeg.setEnd(gapMap.length);
1014 // LATER: much of this is verbatim from the alignmentAnnotation
1015 // method below. suggests refactoring to make rangeAnnotation the
1017 an.setDescription(alan.description);
1018 an.setLabel(alan.label);
1019 an.setGroup(Integer.toString(alan.graphGroup));
1028 AnnotationElement ae;
1029 for (int a = 0; a < alan.annotations.length; a++)
1031 if (alan.annotations[a] == null)
1036 ae = new AnnotationElement();
1037 ae.setDescription(alan.annotations[a].description);
1038 ae.addGlyph(new Glyph());
1039 ae.getGlyph(0).setContent(alan.annotations[a].displayCharacter); // assume
1046 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1048 ae.addValue(alan.annotations[a].value);
1050 ae.setPosition(gapMap[a] + 1); // position w.r.t. AlignmentSequence
1052 if (alan.annotations[a].secondaryStructure != ' ')
1054 // we only write an annotation where it really exists.
1055 Glyph ss = new Glyph();
1056 ss.setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
1057 ss.setContent(String
1058 .valueOf(alan.annotations[a].secondaryStructure));
1061 an.addAnnotationElement(ae);
1066 private void saveDatasetSequenceAnnotation(HashMap AlSeqMaps,
1067 uk.ac.vamsas.objects.core.Sequence sref, AlignmentAnnotation alan)
1071 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1072 // objects.core.AlignmentSequence) sref;
1073 uk.ac.vamsas.objects.core.DataSetAnnotations an = (uk.ac.vamsas.objects.core.DataSetAnnotations) getjv2vObj(alan);
1074 int[] gapMap = getGapMap(AlSeqMaps, alan);
1077 an = new uk.ac.vamsas.objects.core.DataSetAnnotations();
1078 initRangeAnnotationType(an, alan, gapMap);
1080 an.setProvenance(dummyProvenance()); // get provenance as user
1081 // created, or jnet, or
1083 setAnnotationType(an, alan);
1084 an.setGroup(Integer.toString(alan.graphGroup)); // // JBPNote -
1092 if (alan.getThreshold() != null && alan.getThreshold().displayed)
1094 an.addProperty(Properties.newProperty(THRESHOLD,
1095 Properties.FLOATTYPE, "" + alan.getThreshold().value));
1096 if (alan.getThreshold().label != null)
1098 an.addProperty(Properties.newProperty(THRESHOLD + "Name",
1099 Properties.STRINGTYPE, "" + alan.getThreshold().label));
1102 ((DataSet) sref.getV_parent()).addDataSetAnnotations(an);
1103 bindjvvobj(alan, an);
1107 // update reference sequence Annotation
1108 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1111 // verify existing alignment sequence annotation is up to date
1112 System.out.println("update dataset sequence annotation.");
1116 // verify existing alignment sequence annotation is up to date
1118 .println("make new alignment dataset sequence annotation if modification has happened.");
1124 private int[] getGapMap(HashMap AlSeqMaps, AlignmentAnnotation alan)
1127 if (AlSeqMaps.containsKey(alan.sequenceRef))
1129 gapMap = (int[]) AlSeqMaps.get(alan.sequenceRef);
1133 gapMap = new int[alan.sequenceRef.getLength()];
1134 // map from alignment position to sequence position.
1135 int[] sgapMap = alan.sequenceRef.gapMap();
1136 for (int a = 0; a < sgapMap.length; a++)
1138 gapMap[sgapMap[a]] = a;
1144 private void saveAlignmentSequenceAnnotation(HashMap AlSeqMaps,
1145 AlignmentSequence alsref, AlignmentAnnotation alan)
1149 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1150 // objects.core.AlignmentSequence) sref;
1151 uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation an = (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) getjv2vObj(alan);
1152 int[] gapMap = getGapMap(AlSeqMaps, alan);
1155 an = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation();
1156 initRangeAnnotationType(an, alan, gapMap);
1158 * I mean here that we don't actually have a semantic 'type' for the
1159 * annotation (this might be - score, intrinsic property, measurement,
1160 * something extracted from another program, etc)
1162 an.setType(JALVIEW_ANNOTATION_ROW); // TODO: better fix
1163 // this rough guess ;)
1164 alsref.addAlignmentSequenceAnnotation(an);
1165 bindjvvobj(alan, an);
1166 // These properties are directly supported by the
1167 // AlignmentSequenceAnnotation type.
1168 setAnnotationType(an, alan);
1169 an.setProvenance(dummyProvenance()); // get provenance as user
1170 // created, or jnet, or
1175 // update reference sequence Annotation
1176 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1179 // verify existing alignment sequence annotation is up to date
1180 System.out.println("update alignment sequence annotation.");
1184 // verify existing alignment sequence annotation is up to date
1186 .println("make new alignment sequence annotation if modification has happened.");
1192 * set vamsas annotation object type from jalview annotation
1197 private void setAnnotationType(RangeAnnotation an,
1198 AlignmentAnnotation alan)
1200 if (an instanceof AlignmentSequenceAnnotation)
1202 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1204 ((AlignmentSequenceAnnotation) an).setGraph(true);
1208 ((AlignmentSequenceAnnotation) an).setGraph(false);
1211 if (an instanceof uk.ac.vamsas.objects.core.AlignmentAnnotation)
1213 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1215 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an).setGraph(true);
1219 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an)
1225 case AlignmentAnnotation.BAR_GRAPH:
1226 an.addProperty(Properties.newProperty(DISCRETE_ANNOTATION,
1227 Properties.BOOLEANTYPE, "true"));
1229 case AlignmentAnnotation.LINE_GRAPH:
1230 an.addProperty(Properties.newProperty(CONTINUOUS_ANNOTATION,
1231 Properties.BOOLEANTYPE, "true"));
1234 // don't add any kind of discrete or continous property info.
1239 * get start<end range of segment, adjusting for inclusivity flag and
1243 * @param ensureDirection
1244 * when true - always ensure start is less than end.
1245 * @return int[] { start, end, direction} where direction==1 for range running
1246 * from end to start.
1248 private int[] getSegRange(Seg visSeg, boolean ensureDirection)
1250 boolean incl = visSeg.getInclusive();
1251 // adjust for inclusive flag.
1252 int pol = (visSeg.getStart() <= visSeg.getEnd()) ? 1 : -1; // polarity of
1254 int start = visSeg.getStart() + (incl ? 0 : pol);
1255 int end = visSeg.getEnd() + (incl ? 0 : -pol);
1256 if (ensureDirection && pol == -1)
1258 // jalview doesn't deal with inverted ranges, yet.
1264 { start, end, pol < 0 ? 1 : 0 };
1270 * @return true if annotation is not to be stored in document
1272 private boolean isJalviewOnly(AlignmentAnnotation annotation)
1274 return annotation.autoCalculated || annotation.label.equals("Quality")
1275 || annotation.label.equals("Conservation")
1276 || annotation.label.equals("Consensus");
1279 boolean dojvsync = true;
1281 // boolean dojvsync = false; // disables Jalview AppData IO
1283 * list of alignment views created when updating Jalview from document.
1285 private final Vector newAlignmentViews = new Vector();
1288 * update local jalview view settings from the stored appdata (if any)
1290 public void updateJalviewFromAppdata()
1292 // recover any existing Jalview data from appdata
1293 // TODO: recover any PDB files stored as attachments in the vamsas session
1294 // and initialise the Jalview2XML.alreadyLoadedPDB hashtable with mappings
1297 final IClientAppdata cappdata = cdoc.getClientAppdata();
1298 if (cappdata != null)
1300 if (cappdata.hasClientAppdata())
1302 // TODO: how to check version of Jalview client app data and whether
1303 // it has been modified
1304 // client data is shared over all app clients
1307 jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
1308 fromxml.attemptversion1parse = false;
1309 fromxml.setUniqueSetSuffix("");
1310 fromxml.setObjectMappingTables(vobj2jv, jv2vobj); // mapKeysToString
1312 // mapValuesToString
1313 fromxml.setSkipList(skipList);
1314 jalview.util.jarInputStreamProvider jprovider = new jalview.util.jarInputStreamProvider()
1318 public String getFilename()
1321 // TODO Get the vamsas session ID here
1322 return "Jalview Vamsas Document Client Data";
1326 public JarInputStream getJarInputStream() throws IOException
1329 .debug("Returning client input stream for Jalview from Vamsas Document.");
1330 return new JarInputStream(cappdata.getClientInputStream());
1335 fromxml.loadJalviewAlign(jprovider);
1337 } catch (Exception e)
1340 } catch (OutOfMemoryError e)
1349 if (cappdata.hasUserAppdata())
1351 // TODO: how to check version of Jalview user app data and whether it
1352 // has been modified
1353 // user data overrides data shared over all app clients ?
1356 jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
1357 fromxml.attemptversion1parse = false;
1358 fromxml.setUniqueSetSuffix("");
1359 fromxml.setSkipList(skipList);
1360 fromxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1361 mapValuesToString(jv2vobj));
1362 jalview.util.jarInputStreamProvider jarstream = new jalview.util.jarInputStreamProvider()
1366 public String getFilename()
1369 // TODO Get the vamsas session ID here
1370 return "Jalview Vamsas Document User Data";
1374 public JarInputStream getJarInputStream() throws IOException
1377 .debug("Returning user input stream for Jalview from Vamsas Document.");
1378 return new JarInputStream(cappdata.getUserInputStream());
1383 fromxml.loadJalviewAlign(jarstream);
1385 } catch (Exception e)
1388 } catch (OutOfMemoryError e)
1398 flushAlignViewports();
1402 * remove any spurious views generated by document synchronization
1404 private void flushAlignViewports()
1406 // remove any additional viewports originally recovered from the vamsas
1408 // search for all alignframes containing viewports generated from document
1410 // and if any contain more than one view, then remove the one generated by
1412 AlignmentViewport views[], av = null;
1413 AlignFrame af = null;
1414 Iterator newviews = newAlignmentViews.iterator();
1415 while (newviews.hasNext())
1417 av = (AlignmentViewport) newviews.next();
1418 af = Desktop.getAlignFrameFor(av);
1419 // TODO implement this : af.getNumberOfViews
1420 String seqsetidobj = av.getSequenceSetId();
1421 views = Desktop.getViewports(seqsetidobj);
1422 Cache.log.debug("Found "
1423 + (views == null ? " no " : "" + views.length)
1424 + " views for '" + av.getSequenceSetId() + "'");
1425 if (views.length > 1)
1427 // we need to close the original document view.
1429 // work out how to do this by seeing if the views are gathered.
1430 // pretty clunky but the only way to do this without adding more flags
1431 // to the align frames.
1432 boolean gathered = false;
1433 String newviewid = null;
1434 Set<AlignedCodonFrame> mappings = av.getAlignment()
1436 for (int i = 0; i < views.length; i++)
1440 AlignFrame viewframe = Desktop.getAlignFrameFor(views[i]);
1441 if (viewframe == af)
1445 newviewid = views[i].getSequenceSetId();
1449 // lose the reference to the vamsas document created view
1453 // close the view generated by the vamsas document synchronization
1460 af.closeMenuItem_actionPerformed(false);
1462 replaceJvObjMapping(seqsetidobj, newviewid);
1463 seqsetidobj = newviewid;
1464 // not sure if we need to do this:
1466 if (false) // mappings != null)
1468 // ensure sequence mappings from vamsas document view still
1470 if (mappings != null)
1472 jalview.structure.StructureSelectionManager
1473 .getStructureSelectionManager(Desktop.instance)
1474 .addMappings(mappings);
1478 // ensure vamsas object binds to the stored views retrieved from
1480 // jalview.structure.StructureSelectionManager
1481 // .getStructureSelectionManager()
1482 // .addStructureViewerListener(viewframe.alignPanel);
1487 newAlignmentViews.clear();
1491 * replaces oldjvobject with newjvobject in the Jalview Object <> VorbaID
1494 * @param oldjvobject
1495 * @param newjvobject
1498 private void replaceJvObjMapping(Object oldjvobject, Object newjvobject)
1500 Object vobject = jv2vobj.remove(oldjvobject);
1501 if (vobject == null)
1503 // NOTE: this happens if user deletes object in one session then updates
1504 // from another client
1505 throw new Error(MessageManager.formatMessage("error.implementation_error_old_jalview_object_not_bound", new String[]{oldjvobject.toString()}));
1507 if (newjvobject != null)
1509 jv2vobj.put(newjvobject, vobject);
1510 vobj2jv.put(vobject, newjvobject);
1515 * Update the jalview client and user appdata from the local jalview settings
1517 public void updateJalviewClientAppdata()
1519 final IClientAppdata cappdata = cdoc.getClientAppdata();
1520 if (cappdata != null)
1524 jalview.gui.Jalview2XML jxml = new jalview.gui.Jalview2XML();
1525 jxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1526 mapValuesToString(jv2vobj));
1527 jxml.setSkipList(skipList);
1530 jxml.saveState(new JarOutputStream(cappdata
1531 .getClientOutputStream()));
1534 } catch (Exception e)
1536 // TODO raise GUI warning if user requests it.
1538 .error("Couldn't update jalview client application data. Giving up - local settings probably lost.",
1545 .error("Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
1550 * translate the Vobject keys to strings for use in Jalview2XML
1555 private IdentityHashMap mapValuesToString(IdentityHashMap jv2vobj2)
1557 IdentityHashMap mapped = new IdentityHashMap();
1558 Iterator keys = jv2vobj2.keySet().iterator();
1559 while (keys.hasNext())
1561 Object key = keys.next();
1562 mapped.put(key, jv2vobj2.get(key).toString());
1568 * translate the Vobject values to strings for use in Jalview2XML
1571 * @return hashtable with string values
1573 private Hashtable mapKeysToString(Hashtable vobj2jv2)
1575 Hashtable mapped = new Hashtable();
1576 Iterator keys = vobj2jv2.keySet().iterator();
1577 while (keys.hasNext())
1579 Object key = keys.next();
1580 mapped.put(key.toString(), vobj2jv2.get(key));
1586 * synchronize Jalview from the vamsas document
1588 * @return number of new views from document
1590 public int updateToJalview()
1592 VAMSAS _roots[] = cdoc.getVamsasRoots();
1594 for (int _root = 0; _root < _roots.length; _root++)
1596 VAMSAS root = _roots[_root];
1597 boolean newds = false;
1598 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
1600 // ///////////////////////////////////
1602 DataSet dataset = root.getDataSet(_ds);
1603 int i, iSize = dataset.getSequenceCount();
1604 List<SequenceI> dsseqs;
1605 jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(dataset);
1607 if (jdataset == null)
1609 Cache.log.debug("Initialising new jalview dataset fields");
1611 dsseqs = new Vector();
1615 Cache.log.debug("Update jalview dataset from vamsas.");
1616 jremain = jdataset.getHeight();
1617 dsseqs = jdataset.getSequences();
1620 // TODO: test sequence merging - we preserve existing non vamsas
1621 // sequences but add in any new vamsas ones, and don't yet update any
1622 // sequence attributes
1623 for (i = 0; i < iSize; i++)
1625 Sequence vdseq = dataset.getSequence(i);
1626 jalview.io.vamsas.Datasetsequence dssync = new Datasetsequence(
1629 jalview.datamodel.SequenceI dsseq = (SequenceI) dssync.getJvobj();
1630 if (dssync.isAddfromdoc())
1634 if (vdseq.getDbRefCount() > 0)
1636 DbRef[] dbref = vdseq.getDbRef();
1637 for (int db = 0; db < dbref.length; db++)
1639 new jalview.io.vamsas.Dbref(this, dbref[db], vdseq, dsseq);
1642 dsseq.updatePDBIds();
1648 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1649 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1651 seqs[i] = dsseqs.get(i);
1652 dsseqs.set(i, null);
1654 jdataset = new jalview.datamodel.Alignment(seqs);
1655 Cache.log.debug("New vamsas dataset imported into jalview.");
1656 bindjvvobj(jdataset, dataset);
1659 // add any new dataset sequence feature annotations
1660 if (dataset.getDataSetAnnotations() != null)
1662 for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++)
1664 DataSetAnnotations dseta = dataset.getDataSetAnnotations(dsa);
1665 // TODO: deal with group annotation on datset sequences.
1666 if (dseta.getSeqRefCount() == 1)
1668 SequenceI dsSeq = (SequenceI) getvObj2jv((Vobject) dseta
1669 .getSeqRef(0)); // TODO: deal with group dataset
1674 .warn("Couldn't resolve jalview sequenceI for dataset object reference "
1675 + ((Vobject) dataset.getDataSetAnnotations(
1676 dsa).getSeqRef(0)).getVorbaId()
1681 if (dseta.getAnnotationElementCount() == 0)
1683 new jalview.io.vamsas.Sequencefeature(this, dseta, dsSeq);
1688 // TODO: deal with alignmentAnnotation style annotation
1689 // appearing on dataset sequences.
1690 // JBPNote: we could just add them to all alignments but
1691 // that may complicate cross references in the jalview
1694 .warn("Ignoring dataset annotation with annotationElements. Not yet supported in jalview.");
1701 .warn("Ignoring multiply referenced dataset sequence annotation for binding to datsaet sequence features.");
1705 if (dataset.getAlignmentCount() > 0)
1707 // LOAD ALIGNMENTS from DATASET
1709 for (int al = 0, nal = dataset.getAlignmentCount(); al < nal; al++)
1711 uk.ac.vamsas.objects.core.Alignment alignment = dataset
1713 // TODO check this handles multiple views properly
1714 AlignmentViewport av = findViewport(alignment);
1716 AlignmentI jal = null;
1719 // TODO check that correct alignment object is retrieved when
1720 // hidden seqs exist.
1721 jal = (av.hasHiddenRows()) ? av.getAlignment()
1722 .getHiddenSequences().getFullAlignment() : av
1725 iSize = alignment.getAlignmentSequenceCount();
1726 boolean refreshal = false;
1727 Vector newasAnnots = new Vector();
1728 char gapChar = ' '; // default for new alignments read in from the
1732 dsseqs = jal.getSequences(); // for merge/update
1733 gapChar = jal.getGapCharacter();
1737 dsseqs = new Vector();
1739 char valGapchar = alignment.getGapChar().charAt(0);
1740 for (i = 0; i < iSize; i++)
1742 AlignmentSequence valseq = alignment.getAlignmentSequence(i);
1743 jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(valseq);
1744 if (syncFromAlignmentSequence(valseq, valGapchar, gapChar,
1745 dsseqs) && alseq != null)
1748 // updated to sequence from the document
1752 if (valseq.getAlignmentSequenceAnnotationCount() > 0)
1754 AlignmentSequenceAnnotation[] vasannot = valseq
1755 .getAlignmentSequenceAnnotation();
1756 for (int a = 0; a < vasannot.length; a++)
1758 AlignmentAnnotation asa = (AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO:
1766 int se[] = getBounds(vasannot[a]);
1767 asa = getjAlignmentAnnotation(jal, vasannot[a]);
1768 asa.setSequenceRef(alseq);
1769 asa.createSequenceMapping(alseq, se[0], false); // TODO:
1780 alseq.addAlignmentAnnotation(asa);
1781 bindjvvobj(asa, vasannot[a]);
1783 newasAnnots.add(asa);
1787 // update existing annotation - can do this in place
1788 if (vasannot[a].getModifiable() == null) // TODO: USE
1794 .info("UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
1795 // TODO: should at least replace with new one - otherwise
1796 // things will break
1797 // basically do this:
1798 // int se[] = getBounds(vasannot[a]);
1799 // asa.update(getjAlignmentAnnotation(jal, vasannot[a]));
1800 // // update from another annotation object in place.
1801 // asa.createSequenceMapping(alseq, se[0], false);
1810 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1811 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1813 seqs[i] = dsseqs.get(i);
1814 dsseqs.set(i, null);
1816 jal = new jalview.datamodel.Alignment(seqs);
1817 Cache.log.debug("New vamsas alignment imported into jalview "
1818 + alignment.getVorbaId().getId());
1819 jal.setDataset(jdataset);
1821 if (newasAnnots != null && newasAnnots.size() > 0)
1823 // Add the new sequence annotations in to the alignment.
1824 for (int an = 0, anSize = newasAnnots.size(); an < anSize; an++)
1826 jal.addAnnotation((AlignmentAnnotation) newasAnnots
1828 // TODO: check if anything has to be done - like calling
1829 // adjustForAlignment or something.
1830 newasAnnots.setElementAt(null, an);
1834 // //////////////////////////////////////////
1835 // //LOAD ANNOTATIONS FOR THE ALIGNMENT
1836 // ////////////////////////////////////
1837 if (alignment.getAlignmentAnnotationCount() > 0)
1839 uk.ac.vamsas.objects.core.AlignmentAnnotation[] an = alignment
1840 .getAlignmentAnnotation();
1842 for (int j = 0; j < an.length; j++)
1844 AlignmentAnnotation jan = (AlignmentAnnotation) getvObj2jv(an[j]);
1847 // update or stay the same.
1848 // TODO: should at least replace with a new one - otherwise
1849 // things will break
1850 // basically do this:
1851 // jan.update(getjAlignmentAnnotation(jal, an[a])); // update
1852 // from another annotation object in place.
1855 .debug("update from vamsas alignment annotation to existing jalview alignment annotation.");
1856 if (an[j].getModifiable() == null) // TODO: USE VAMSAS
1857 // LIBRARY OBJECT LOCK
1860 // TODO: user defined annotation is totally mutable... - so
1861 // load it up or throw away if locally edited.
1863 .info("NOT IMPLEMENTED - Recovering user-modifiable annotation - yet...");
1865 // TODO: compare annotation element rows
1866 // TODO: compare props.
1870 jan = getjAlignmentAnnotation(jal, an[j]);
1871 // TODO: ensure we add the alignment annotation before the
1872 // automatic annotation rows
1873 jal.addAnnotation(jan);
1874 bindjvvobj(jan, an[j]);
1879 AlignFrame alignFrame;
1882 Cache.log.debug("New alignframe for alignment "
1883 + alignment.getVorbaId());
1884 // ///////////////////////////////
1885 // construct alignment view
1886 alignFrame = new AlignFrame(jal, AlignFrame.DEFAULT_WIDTH,
1887 AlignFrame.DEFAULT_HEIGHT, alignment.getVorbaId()
1889 av = alignFrame.getViewport();
1890 newAlignmentViews.addElement(av);
1891 String title = alignment
1894 alignment.getProvenance().getEntryCount() - 1)
1896 if (alignment.getPropertyCount() > 0)
1898 for (int p = 0, pe = alignment.getPropertyCount(); p < pe; p++)
1900 if (alignment.getProperty(p).getName().equals("title"))
1902 title = alignment.getProperty(p).getContent();
1906 // TODO: automatically create meaningful title for a vamsas
1907 // alignment using its provenance.
1908 if (Cache.log.isDebugEnabled())
1910 title = title + "(" + alignment.getVorbaId() + ")";
1913 jalview.gui.Desktop.addInternalFrame(alignFrame, title,
1914 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1915 bindjvvobj(av.getSequenceSetId(), alignment);
1919 // find the alignFrame for jal.
1920 // TODO: fix this so we retrieve the alignFrame handing av
1921 // *directly* (JBPNote - don't understand this now)
1922 // TODO: make sure all associated views are refreshed
1923 alignFrame = Desktop.getAlignFrameFor(av);
1926 av.alignmentChanged(alignFrame.alignPanel);
1927 alignFrame.alignPanel.adjustAnnotationHeight();
1931 // /////////////////////////////////////
1932 if (alignment.getTreeCount() > 0)
1935 for (int t = 0; t < alignment.getTreeCount(); t++)
1937 jalview.io.vamsas.Tree vstree = new jalview.io.vamsas.Tree(
1938 this, alignFrame, alignment.getTree(t));
1939 TreePanel tp = null;
1940 if (vstree.isValidTree())
1942 tp = alignFrame.ShowNewickTree(vstree.getNewickTree(),
1943 vstree.getTitle(), vstree.getInputData(), 600,
1944 500, t * 20 + 50, t * 20 + 50);
1949 bindjvvobj(tp, alignment.getTree(t));
1952 vstree.UpdateSequenceTreeMap(tp);
1953 } catch (RuntimeException e)
1955 Cache.log.warn("update of labels failed.", e);
1960 Cache.log.warn("Cannot create tree for tree " + t
1962 + alignment.getTree(t).getVorbaId());
1970 // we do sequenceMappings last because they span all datasets in a vamsas
1972 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
1974 DataSet dataset = root.getDataSet(_ds);
1975 if (dataset.getSequenceMappingCount() > 0)
1977 for (int sm = 0, smCount = dataset.getSequenceMappingCount(); sm < smCount; sm++)
1979 Rangetype seqmap = new jalview.io.vamsas.Sequencemapping(this,
1980 dataset.getSequenceMapping(sm));
1985 return newAlignmentViews.size();
1988 public AlignmentViewport findViewport(Alignment alignment)
1990 AlignmentViewport av = null;
1991 AlignmentViewport[] avs = Desktop
1992 .getViewports((String) getvObj2jv(alignment));
2000 // bitfields - should be a template in j1.5
2001 private static int HASSECSTR = 0;
2003 private static int HASVALS = 1;
2005 private static int HASHPHOB = 2;
2007 private static int HASDC = 3;
2009 private static int HASDESCSTR = 4;
2011 private static int HASTWOSTATE = 5; // not used yet.
2014 * parses the AnnotationElements - if they exist - into
2015 * jalview.datamodel.Annotation[] rows Two annotation rows are made if there
2016 * are distinct annotation for both at 'pos' and 'after pos' at any particular
2020 * @return { boolean[static int constants ], int[ae.length] - map to annotated
2021 * object frame, jalview.datamodel.Annotation[],
2022 * jalview.datamodel.Annotation[] (after)}
2024 private Object[] parseRangeAnnotation(
2025 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2027 // set these attributes by looking in the annotation to decide what kind of
2028 // alignment annotation rows will be made
2029 // TODO: potentially we might make several annotation rows from one vamsas
2030 // alignment annotation. the jv2Vobj binding mechanism
2031 // may not quite cope with this (without binding an array of annotations to
2032 // a vamsas alignment annotation)
2033 // summary flags saying what we found over the set of annotation rows.
2034 boolean[] AeContent = new boolean[]
2035 { false, false, false, false, false };
2036 int[] rangeMap = getMapping(annotation);
2037 jalview.datamodel.Annotation[][] anot = new jalview.datamodel.Annotation[][]
2038 { new jalview.datamodel.Annotation[rangeMap.length],
2039 new jalview.datamodel.Annotation[rangeMap.length] };
2040 boolean mergeable = true; // false if 'after positions cant be placed on
2041 // same annotation row as positions.
2043 if (annotation.getAnnotationElementCount() > 0)
2045 AnnotationElement ae[] = annotation.getAnnotationElement();
2046 for (int aa = 0; aa < ae.length; aa++)
2048 int pos = (int) ae[aa].getPosition() - 1; // pos counts from 1 to
2049 // (|seg.start-seg.end|+1)
2050 if (pos >= 0 && pos < rangeMap.length)
2052 int row = ae[aa].getAfter() ? 1 : 0;
2053 if (anot[row][pos] != null)
2055 // only time this should happen is if the After flag is set.
2056 Cache.log.debug("Ignoring duplicate annotation site at " + pos);
2059 if (anot[1 - row][pos] != null)
2064 if (ae[aa].getDescription() != null)
2066 desc = ae[aa].getDescription();
2067 if (desc.length() > 0)
2069 // have imported valid description string
2070 AeContent[HASDESCSTR] = true;
2073 String dc = null; // ae[aa].getDisplayCharacter()==null ? "dc" :
2074 // ae[aa].getDisplayCharacter();
2075 String ss = null; // ae[aa].getSecondaryStructure()==null ? "ss" :
2076 // ae[aa].getSecondaryStructure();
2077 java.awt.Color colour = null;
2078 if (ae[aa].getGlyphCount() > 0)
2080 Glyph[] glyphs = ae[aa].getGlyph();
2081 for (int g = 0; g < glyphs.length; g++)
2085 .equals(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE))
2087 ss = glyphs[g].getContent();
2088 AeContent[HASSECSTR] = true;
2092 .equals(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO))
2094 Cache.log.debug("ignoring hydrophobicity glyph marker.");
2095 AeContent[HASHPHOB] = true;
2096 char c = (dc = glyphs[g].getContent()).charAt(0);
2097 // dc may get overwritten - but we still set the colour.
2098 colour = new java.awt.Color(c == '+' ? 255 : 0,
2099 c == '.' ? 255 : 0, c == '-' ? 255 : 0);
2102 else if (glyphs[g].getDict().equals(
2103 uk.ac.vamsas.objects.utils.GlyphDictionary.DEFAULT))
2105 dc = glyphs[g].getContent();
2106 AeContent[HASDC] = true;
2111 .debug("IMPLEMENTATION TODO: Ignoring unknown glyph type "
2112 + glyphs[g].getDict());
2117 if (ae[aa].getValueCount() > 0)
2119 AeContent[HASVALS] = true;
2120 if (ae[aa].getValueCount() > 1)
2122 Cache.log.warn("ignoring additional "
2123 + (ae[aa].getValueCount() - 1)
2124 + " values in annotation element.");
2126 val = ae[aa].getValue(0);
2130 anot[row][pos] = new jalview.datamodel.Annotation(
2131 (dc != null) ? dc : "", desc,
2132 (ss != null) ? ss.charAt(0) : ' ', val);
2136 anot[row][pos] = new jalview.datamodel.Annotation(
2137 (dc != null) ? dc : "", desc,
2138 (ss != null) ? ss.charAt(0) : ' ', val, colour);
2143 Cache.log.warn("Ignoring out of bound annotation element " + aa
2144 + " in " + annotation.getVorbaId().getId());
2147 // decide on how many annotation rows are needed.
2150 for (int i = 0; i < anot[0].length; i++)
2152 if (anot[1][i] != null)
2154 anot[0][i] = anot[1][i];
2155 anot[0][i].description = anot[0][i].description + " (after)";
2156 AeContent[HASDESCSTR] = true; // we have valid description string
2165 for (int i = 0; i < anot[0].length; i++)
2167 anot[1][i].description = anot[1][i].description + " (after)";
2171 { AeContent, rangeMap, anot[0], anot[1] };
2175 // no annotations to parse. Just return an empty annotationElement[]
2178 { AeContent, rangeMap, anot[0], anot[1] };
2185 * the jalview alignment to which the annotation will be attached
2186 * (ideally - freshly updated from corresponding vamsas alignment)
2188 * @return unbound jalview alignment annotation object.
2190 private AlignmentAnnotation getjAlignmentAnnotation(
2192 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2194 if (annotation == null)
2199 // hasSequenceRef=annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class);
2200 // boolean hasProvenance=hasSequenceRef ||
2201 // (annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentAnnotation.class));
2203 * int se[] = getBounds(annotation); if (se==null) se=new int[]
2204 * {0,jal.getWidth()-1};
2206 Object[] parsedRangeAnnotation = parseRangeAnnotation(annotation);
2207 String a_label = annotation.getLabel();
2208 String a_descr = annotation.getDescription();
2209 GraphLine gl = null;
2211 boolean interp = true; // cleared if annotation is DISCRETE
2212 // set type and other attributes from properties
2213 if (annotation.getPropertyCount() > 0)
2215 // look for special jalview properties
2216 uk.ac.vamsas.objects.core.Property[] props = annotation.getProperty();
2217 for (int p = 0; p < props.length; p++)
2219 if (props[p].getName().equalsIgnoreCase(DISCRETE_ANNOTATION))
2221 type = AlignmentAnnotation.BAR_GRAPH;
2224 else if (props[p].getName().equalsIgnoreCase(CONTINUOUS_ANNOTATION))
2226 type = AlignmentAnnotation.LINE_GRAPH;
2228 else if (props[p].getName().equalsIgnoreCase(THRESHOLD))
2233 val = new Float(props[p].getContent());
2234 } catch (Exception e)
2236 Cache.log.warn("Failed to parse threshold property");
2242 gl = new GraphLine(val.floatValue(), "", java.awt.Color.black);
2246 gl.value = val.floatValue();
2250 else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name"))
2254 gl = new GraphLine(0, "", java.awt.Color.black);
2256 gl.label = props[p].getContent();
2260 AlignmentAnnotation jan = null;
2261 if (a_label == null || a_label.length() == 0)
2263 a_label = annotation.getType();
2264 if (a_label.length() == 0)
2266 a_label = "Unamed annotation";
2269 if (a_descr == null || a_descr.length() == 0)
2271 a_descr = "Annotation of type '" + annotation.getType() + "'";
2273 if (parsedRangeAnnotation == null)
2276 .debug("Inserting empty annotation row elements for a whole-alignment annotation.");
2280 if (parsedRangeAnnotation[3] != null)
2282 Cache.log.warn("Ignoring 'After' annotation row in "
2283 + annotation.getVorbaId());
2285 jalview.datamodel.Annotation[] arow = (jalview.datamodel.Annotation[]) parsedRangeAnnotation[2];
2286 boolean[] has = (boolean[]) parsedRangeAnnotation[0];
2287 // VAMSAS: getGraph is only on derived annotation for alignments - in this
2288 // way its 'odd' - there is already an existing TODO about removing this
2289 // flag as being redundant
2291 * if((annotation.getClass().equals(uk.ac.vamsas.objects.core.
2292 * AlignmentAnnotation.class) &&
2293 * ((uk.ac.vamsas.objects.core.AlignmentAnnotation)annotation).getGraph())
2294 * || (hasSequenceRef=true &&
2295 * ((uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation
2296 * )annotation).getGraph())) {
2302 type = AlignmentAnnotation.BAR_GRAPH; // default
2308 // no hints - so we ensure HPHOB display is like this.
2309 type = AlignmentAnnotation.BAR_GRAPH;
2312 // make bounds and automatic description strings for jalview user's
2313 // benefit (these shouldn't be written back to vamsas document)
2314 boolean first = true;
2315 float min = 0, max = 1;
2317 for (int i = 0; i < arow.length; i++)
2319 if (arow[i] != null)
2321 if (i - lastval > 1 && interp)
2323 // do some interpolation *between* points
2324 if (arow[lastval] != null)
2326 float interval = arow[i].value - arow[lastval].value;
2327 interval /= i - lastval;
2328 float base = arow[lastval].value;
2329 for (int ip = lastval + 1, np = 0; ip < i; np++, ip++)
2331 arow[ip] = new jalview.datamodel.Annotation("", "", ' ',
2332 interval * np + base);
2333 // NB - Interpolated points don't get a tooltip and
2339 // check range - shouldn't we have a min and max property in the
2340 // annotation object ?
2343 min = max = arow[i].value;
2348 if (arow[i].value < min)
2350 min = arow[i].value;
2352 else if (arow[i].value > max)
2354 max = arow[i].value;
2357 // make tooltip and display char value
2358 if (!has[HASDESCSTR])
2360 arow[i].description = arow[i].value + "";
2366 if (arow[i].description != null
2367 && arow[i].description.length() < 3)
2369 // copy over the description as the display char.
2370 arow[i].displayCharacter = new String(arow[i].description);
2375 // mark the position as a point used for the interpolation.
2376 arow[i].displayCharacter = arow[i].value + "";
2381 jan = new AlignmentAnnotation(a_label, a_descr,
2382 arow, min, max, type);
2386 if (annotation.getAnnotationElementCount() == 0)
2388 // empty annotation array
2389 // TODO: alignment 'features' compare rangeType spec to alignment
2390 // width - if it is not complete, then mark regions on the annotation
2393 jan = new AlignmentAnnotation(a_label, a_descr,
2395 jan.setThreshold(null);
2396 jan.annotationId = annotation.getVorbaId().toString(); // keep all the
2399 if (annotation.getLinkCount() > 0)
2401 Cache.log.warn("Ignoring " + annotation.getLinkCount()
2402 + "links added to AlignmentAnnotation.");
2404 if (annotation.getModifiable() == null
2405 || annotation.getModifiable().length() == 0) // TODO: USE VAMSAS
2409 jan.editable = true;
2413 if (annotation.getGroup() != null
2414 && annotation.getGroup().length() > 0)
2416 jan.graphGroup = Integer.parseInt(annotation.getGroup()); // TODO:
2424 } catch (Exception e)
2427 .info("UNIMPLEMENTED : Couldn't parse non-integer group value for setting graphGroup correctly.");
2437 * get real bounds of a RangeType's specification. start and end are an
2438 * inclusive range within which all segments and positions lie. TODO: refactor
2442 * @return int[] { start, end}
2444 private int[] getBounds(RangeType dseta)
2449 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2451 throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2453 if (dseta.getSegCount() > 0)
2455 se = getSegRange(dseta.getSeg(0), true);
2456 for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++)
2458 int nse[] = getSegRange(dseta.getSeg(s), true);
2469 if (dseta.getPosCount() > 0)
2471 // could do a polarity for pos range too. and pass back indication of
2473 int pos = dseta.getPos(0).getI();
2476 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2478 pos = dseta.getPos(p).getI();
2495 * map from a rangeType's internal frame to the referenced object's coordinate
2499 * @return int [] { ref(pos)...} for all pos in rangeType's frame.
2501 private int[] getMapping(RangeType dseta)
2503 Vector posList = new Vector();
2507 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2509 throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2511 if (dseta.getSegCount() > 0)
2513 for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++)
2515 se = getSegRange(dseta.getSeg(s), false);
2516 int se_end = se[1 - se[2]] + (se[2] == 0 ? 1 : -1);
2517 for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1)
2519 posList.add(new Integer(p));
2523 else if (dseta.getPosCount() > 0)
2525 int pos = dseta.getPos(0).getI();
2527 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2529 pos = dseta.getPos(p).getI();
2530 posList.add(new Integer(pos));
2534 if (posList != null && posList.size() > 0)
2536 int[] range = new int[posList.size()];
2537 for (int i = 0; i < range.length; i++)
2539 range[i] = ((Integer) posList.elementAt(i)).intValue();
2550 * where the from range is the local mapped range, and the to range
2551 * is the 'mapped' range in the MapRangeType
2552 * @param default unit for local
2553 * @param default unit for mapped
2556 private MapList parsemapType(MapType maprange, int localu,
2560 int[] localRange = getMapping(maprange.getLocal());
2561 int[] mappedRange = getMapping(maprange.getMapped());
2562 long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit()
2564 long mu = maprange.getMapped().hasUnit() ? maprange.getMapped()
2565 .getUnit() : mappedu;
2566 ml = new MapList(localRange, mappedRange, (int) lu,
2572 * initialise a range type object from a set of start/end inclusive intervals
2577 private void initRangeType(RangeType mrt, List<int[]> ranges)
2579 for (int[] range : ranges)
2581 Seg vSeg = new Seg();
2582 vSeg.setStart(range[0]);
2583 vSeg.setEnd(range[1]);
2589 * initialise a MapType object from a MapList object.
2595 private void initMapType(MapType maprange, MapList ml,
2598 maprange.setLocal(new Local());
2599 maprange.setMapped(new Mapped());
2600 initRangeType(maprange.getLocal(), ml.getFromRanges());
2601 initRangeType(maprange.getMapped(), ml.getToRanges());
2604 maprange.getLocal().setUnit(ml.getFromRatio());
2605 maprange.getLocal().setUnit(ml.getToRatio());
2610 * not needed now. Provenance getVamsasProvenance(jalview.datamodel.Provenance
2611 * jprov) { jalview.datamodel.ProvenanceEntry[] entries = null; // TODO: fix
2612 * App and Action here. Provenance prov = new Provenance();
2613 * org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( new
2614 * java.util.Date()); Entry provEntry;
2616 * if (jprov != null) { entries = jprov.getEntries(); for (int i = 0; i <
2617 * entries.length; i++) { provEntry = new Entry(); try { date = new
2618 * org.exolab.castor.types.Date(entries[i].getDate()); } catch (Exception ex)
2619 * { ex.printStackTrace();
2621 * date = new org.exolab.castor.types.Date(entries[i].getDate()); }
2622 * provEntry.setDate(date); provEntry.setUser(entries[i].getUser());
2623 * provEntry.setAction(entries[i].getAction()); prov.addEntry(provEntry); } }
2624 * else { provEntry = new Entry(); provEntry.setDate(date);
2625 * provEntry.setUser(System.getProperty("user.name")); // TODO: ext string
2626 * provEntry.setApp("JVAPP"); // TODO: ext string provEntry.setAction(action);
2627 * prov.addEntry(provEntry); }
2631 jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
2633 // TODO: fix App and Action entries and check use of provenance in jalview.
2634 jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
2635 for (int i = 0; i < prov.getEntryCount(); i++)
2637 jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i)
2638 .getAction(), prov.getEntry(i).getDate(), prov.getEntry(i)
2647 * @return default initial provenance list for a Jalview created vamsas
2650 Provenance dummyProvenance()
2652 return dummyProvenance(null);
2655 Entry dummyPEntry(String action)
2657 Entry entry = new Entry();
2658 entry.setApp(this.provEntry.getApp());
2661 entry.setAction(action);
2665 entry.setAction("created.");
2667 entry.setDate(new java.util.Date());
2668 entry.setUser(this.provEntry.getUser());
2672 Provenance dummyProvenance(String action)
2674 Provenance prov = new Provenance();
2675 prov.addEntry(dummyPEntry(action));
2679 Entry addProvenance(Provenance p, String action)
2681 Entry dentry = dummyPEntry(action);
2686 public Entry getProvEntry()
2691 public IClientDocument getClientDocument()
2696 public IdentityHashMap getJvObjectBinding()
2701 public Hashtable getVamsasObjectBinding()
2706 public void storeSequenceMappings(AlignmentViewport viewport, String title)
2709 AlignmentViewport av = viewport;
2712 AlignmentI jal = av.getAlignment();
2713 // /////////////////////////////////////////
2715 DataSet dataset = null;
2716 if (jal.getDataset() == null)
2718 Cache.log.warn("Creating new dataset for an alignment.");
2719 jal.setDataset(null);
2721 dataset = (DataSet) ((Alignment) getjv2vObj(viewport
2722 .getSequenceSetId())).getV_parent(); // jal.getDataset());
2723 if (dataset == null)
2725 dataset = (DataSet) getjv2vObj(jal.getDataset());
2727 .error("Can't find the correct dataset for the alignment in this view. Creating new one.");
2730 // Store any sequence mappings.
2731 Set<AlignedCodonFrame> cframes = av.getAlignment().getCodonFrames();
2732 if (cframes != null)
2734 for (AlignedCodonFrame acf : cframes)
2736 if (acf.getdnaSeqs() != null && acf.getdnaSeqs().length > 0)
2738 jalview.datamodel.SequenceI[] dmps = acf.getdnaSeqs();
2739 jalview.datamodel.Mapping[] mps = acf.getProtMappings();
2740 for (int smp = 0; smp < mps.length; smp++)
2742 uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(dmps[smp]);
2745 new jalview.io.vamsas.Sequencemapping(this, mps[smp],
2751 .warn("NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
2752 + dmps[smp].getDisplayId(true)
2754 + mps[smp].getTo().getName());
2760 } catch (Exception e)
2762 throw new Exception(MessageManager.formatMessage("exception.couldnt_store_sequence_mappings", new String[]{title}),e);
2766 public void clearSkipList()
2768 if (skipList != null)
2775 * @return the skipList
2777 public Hashtable getSkipList()
2784 * the skipList to set
2786 public void setSkipList(Hashtable skipList)
2788 this.skipList = skipList;
2792 * registry for datastoreItems
2794 DatastoreRegistry dsReg = new DatastoreRegistry();
2796 public DatastoreRegistry getDatastoreRegisty()
2800 dsReg = new DatastoreRegistry();