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.GraphLine;
27 import jalview.datamodel.SequenceI;
28 import jalview.gui.AlignFrame;
29 import jalview.gui.AlignViewport;
30 import jalview.gui.Desktop;
31 import jalview.gui.TreePanel;
32 import jalview.io.vamsas.Datasetsequence;
33 import jalview.io.vamsas.DatastoreItem;
34 import jalview.io.vamsas.DatastoreRegistry;
35 import jalview.io.vamsas.Rangetype;
36 import jalview.project.Jalview2XML;
37 import jalview.util.MessageManager;
38 import jalview.viewmodel.AlignmentViewport;
40 import java.io.IOException;
41 import java.util.Enumeration;
42 import java.util.HashMap;
43 import java.util.Hashtable;
44 import java.util.IdentityHashMap;
45 import java.util.Iterator;
46 import java.util.List;
47 import java.util.Vector;
48 import java.util.jar.JarInputStream;
49 import java.util.jar.JarOutputStream;
51 import uk.ac.vamsas.client.IClientAppdata;
52 import uk.ac.vamsas.client.IClientDocument;
53 import uk.ac.vamsas.client.Vobject;
54 import uk.ac.vamsas.client.VorbaId;
55 import uk.ac.vamsas.objects.core.Alignment;
56 import uk.ac.vamsas.objects.core.AlignmentSequence;
57 import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation;
58 import uk.ac.vamsas.objects.core.AnnotationElement;
59 import uk.ac.vamsas.objects.core.DataSet;
60 import uk.ac.vamsas.objects.core.DataSetAnnotations;
61 import uk.ac.vamsas.objects.core.DbRef;
62 import uk.ac.vamsas.objects.core.Entry;
63 import uk.ac.vamsas.objects.core.Glyph;
64 import uk.ac.vamsas.objects.core.Local;
65 import uk.ac.vamsas.objects.core.MapType;
66 import uk.ac.vamsas.objects.core.Mapped;
67 import uk.ac.vamsas.objects.core.Property;
68 import uk.ac.vamsas.objects.core.Provenance;
69 import uk.ac.vamsas.objects.core.RangeAnnotation;
70 import uk.ac.vamsas.objects.core.RangeType;
71 import uk.ac.vamsas.objects.core.Seg;
72 import uk.ac.vamsas.objects.core.Sequence;
73 import uk.ac.vamsas.objects.core.SequenceType;
74 import uk.ac.vamsas.objects.core.VAMSAS;
75 import uk.ac.vamsas.objects.utils.Properties;
80 * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty(
81 * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); }
85 * TODO: check/verify consistency for vamsas sync with group associated alignment annotation
87 public class VamsasAppDatastore
90 * Type used for general jalview generated annotation added to vamsas document
92 public static final String JALVIEW_ANNOTATION_ROW = "JalviewAnnotation";
95 * AlignmentAnnotation property to indicate that values should not be
98 public static final String DISCRETE_ANNOTATION = "discrete";
101 * continuous property - optional to specify that annotation should be
102 * represented as a continous graph line
104 private static final String CONTINUOUS_ANNOTATION = "continuous";
106 private static final String THRESHOLD = "threshold";
109 * template for provenance entries written to vamsas session document
111 Entry provEntry = null;
114 * Instance of the session document being synchronized with
116 IClientDocument cdoc;
119 * map Vorba (vamsas object xml ref) IDs to live jalview object references
124 * map live jalview object references to Vorba IDs
126 IdentityHashMap jv2vobj;
129 * map jalview sequence set ID (which is vorba ID for alignment) to last
130 * recorded hash value for the alignment viewport (the undo/redo hash value)
132 Hashtable alignRDHash;
134 public VamsasAppDatastore(IClientDocument cdoc, Hashtable vobj2jv,
135 IdentityHashMap jv2vobj, Entry provEntry, Hashtable alignRDHash)
138 this.vobj2jv = vobj2jv;
139 this.jv2vobj = jv2vobj;
140 this.provEntry = provEntry;
141 this.alignRDHash = alignRDHash;
146 * the skipList used to skip over views from Jalview Appdata's that we've
147 * already syncrhonized
151 private void buildSkipList()
153 skipList = new Hashtable();
154 AlignFrame[] al = Desktop.getAlignFrames();
155 for (int f = 0; al != null && f < al.length; f++)
157 skipList.put(al[f].getViewport().getSequenceSetId(), al[f]);
162 * @return the Vobject bound to Jalview datamodel object
164 protected Vobject getjv2vObj(Object jvobj)
166 if (jv2vobj.containsKey(jvobj))
168 return cdoc.getObject((VorbaId) jv2vobj.get(jvobj));
170 // check if we're working with a string - then workaround
171 // the use of IdentityHashTable because different strings
172 // have different object IDs.
173 if (jvobj instanceof String)
175 Object seqsetidobj = null;
176 seqsetidobj = getVamsasObjectBinding().get(jvobj);
177 if (seqsetidobj != null)
179 if (seqsetidobj instanceof String)
181 // what is expected. object returned by av.getSequenceSetId() -
182 // reverse lookup to get the 'registered' instance of this string
183 Vobject obj = getjv2vObj(seqsetidobj);
184 if (obj != null && !(obj instanceof Alignment))
187 "IMPLEMENTATION ERROR?: Unexpected mapping for unmapped jalview string object content:"
188 + seqsetidobj + " to object " + obj);
194 Cache.log.warn("Unexpected mapping for Jalview String Object ID "
195 + seqsetidobj + " to another jalview dataset object "
201 if (Cache.log.isDebugEnabled())
204 "Returning null VorbaID binding for jalview object " + jvobj);
212 * @return Jalview datamodel object bound to the vamsas document object
214 protected Object getvObj2jv(uk.ac.vamsas.client.Vobject vobj)
216 VorbaId id = vobj.getVorbaId();
219 id = cdoc.registerObject(vobj);
221 "Registering new object and returning null for getvObj2jv");
224 if (vobj2jv.containsKey(vobj.getVorbaId()))
226 return vobj2jv.get(vobj.getVorbaId());
231 protected void bindjvvobj(Object jvobj, uk.ac.vamsas.client.Vobject vobj)
233 VorbaId id = vobj.getVorbaId();
236 id = cdoc.registerObject(vobj);
237 if (id == null || vobj.getVorbaId() == null
238 || cdoc.getObject(id) != vobj)
240 Cache.log.error("Failed to get id for "
241 + (vobj.isRegisterable() ? "registerable"
243 + " object " + vobj);
247 if (vobj2jv.containsKey(vobj.getVorbaId())
248 && !((VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
251 "Warning? Overwriting existing vamsas id binding for "
253 new Exception(MessageManager.getString(
254 "exception.overwriting_vamsas_id_binding")));
256 else if (jv2vobj.containsKey(jvobj)
257 && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
260 "Warning? Overwriting existing jalview object binding for "
262 new Exception("Overwriting jalview object binding."));
265 * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
266 * +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+"
267 * already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to
270 // we just update the hash's regardless!
271 Cache.log.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
272 vobj2jv.put(vobj.getVorbaId(), jvobj);
273 // JBPNote - better implementing a hybrid invertible hash.
274 jv2vobj.put(jvobj, vobj.getVorbaId());
278 * put the alignment viewed by AlignViewport into cdoc.
281 * alignViewport to be stored
283 * title for alignment
284 * @return true if alignment associated with viewport was stored/synchronized
287 public boolean storeVAMSAS(AlignViewport av, String aFtitle)
291 jalview.datamodel.AlignmentI jal = av.getAlignment();
292 jalview.datamodel.AlignmentI jds = jal.getDataset();
294 VAMSAS root = null; // will be resolved based on Dataset Parent.
295 // /////////////////////////////////////////
297 DataSet dataset = null;
300 Cache.log.warn("Creating new dataset for an alignment.");
301 jal.setDataset(null);
302 jds = jal.getDataset();
305 // try and get alignment and association for sequence set id
307 Alignment alignment = (Alignment) getjv2vObj(av.getSequenceSetId());
308 if (alignment != null)
310 dataset = (DataSet) alignment.getV_parent();
314 // is the dataset already registered
315 dataset = (DataSet) getjv2vObj(jds);
320 // it might be that one of the dataset sequences does actually have a
321 // binding, so search for it indirectly. If it does, then the local
323 // must be merged with the existing vamsas dataset.
324 jalview.datamodel.SequenceI[] jdatset = jds.getSequencesArray();
325 for (int i = 0; i < jdatset.length; i++)
327 Vobject vbound = getjv2vObj(jdatset[i]);
330 if (vbound instanceof uk.ac.vamsas.objects.core.Sequence)
334 dataset = (DataSet) vbound.getV_parent();
338 if (vbound.getV_parent() != null
339 && dataset != vbound.getV_parent())
341 throw new Error(MessageManager.getString(
342 "error.implementation_error_cannot_map_alignment_sequences"));
343 // This occurs because the dataset for the alignment we are
354 Cache.log.warn("Creating new vamsas dataset for alignment view "
355 + av.getSequenceSetId());
356 // we create a new dataset on the default vamsas root.
357 root = cdoc.getVamsasRoots()[0]; // default vamsas root for modifying.
358 dataset = new DataSet();
359 root.addDataSet(dataset);
360 bindjvvobj(jds, dataset);
361 dataset.setProvenance(dummyProvenance());
362 // dataset.getProvenance().addEntry(provEntry);
367 root = (VAMSAS) dataset.getV_parent();
371 // set new dataset and alignment sequences based on alignment Nucleotide
373 // this *will* break when alignment contains both nucleotide and amino
375 String dict = jal.isNucleotide()
376 ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
377 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA;
378 Vector dssmods = new Vector();
379 for (int i = 0; i < jal.getHeight(); i++)
381 SequenceI sq = jal.getSequenceAt(i).getDatasetSequence(); // only insert
385 Datasetsequence dssync = new jalview.io.vamsas.Datasetsequence(this,
387 sequence = (Sequence) dssync.getVobj();
388 if (dssync.getModified())
390 dssmods.addElement(sequence);
394 if (dssmods.size() > 0)
398 Entry pentry = this.addProvenance(dataset.getProvenance(),
399 "updated sequences");
400 // pentry.addInput(vInput); could write in which sequences were
402 dssmods.removeAllElements();
405 // dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));
406 // ////////////////////////////////////////////
407 if (alignmentWillBeSkipped(av))
409 // TODO: trees could be written - but for the moment we just
411 // add to the JalviewXML skipList and ..
415 if (alignment == null)
417 alignment = new Alignment();
418 bindjvvobj(av.getSequenceSetId(), alignment);
419 if (alignment.getProvenance() == null)
421 alignment.setProvenance(new Provenance());
423 addProvenance(alignment.getProvenance(), "added"); // TODO: insert some
426 dataset.addAlignment(alignment);
428 Property title = new Property();
429 title.setName("title");
430 title.setType("string");
431 title.setContent(aFtitle);
432 alignment.addProperty(title);
434 alignment.setGapChar(String.valueOf(av.getGapCharacter()));
435 for (int i = 0; i < jal.getHeight(); i++)
437 syncToAlignmentSequence(jal.getSequenceAt(i), alignment, null);
439 alignRDHash.put(av.getSequenceSetId(), av.getUndoRedoHash());
443 // always prepare to clone the alignment
444 boolean alismod = av.isUndoRedoHashModified(
445 (long[]) alignRDHash.get(av.getSequenceSetId()));
446 // todo: verify and update mutable alignment props.
447 // TODO: Use isLocked methods
448 if (alignment.getModifiable() == null
449 || alignment.getModifiable().length() == 0)
450 // && !alignment.isDependedOn())
452 boolean modified = false;
453 // check existing sequences in local and in document.
454 Vector docseqs = new Vector(
455 alignment.getAlignmentSequenceAsReference());
456 for (int i = 0; i < jal.getHeight(); i++)
458 modified |= syncToAlignmentSequence(jal.getSequenceAt(i),
461 if (docseqs.size() > 0)
463 // removeValignmentSequences(alignment, docseqs);
464 docseqs.removeAllElements();
466 "Sequence deletion from alignment is not implemented.");
474 addProvenance(alignment.getProvenance(), "Edited"); // TODO:
483 addProvenance(alignment.getProvenance(), "Attributes Edited"); // TODO:
493 System.out.println("update alignment in document.");
497 System.out.println("alignment in document left unchanged.");
502 // unbind alignment from view.
503 // create new binding and new alignment.
504 // mark trail on new alignment as being derived from old ?
506 "update edited alignment to new alignment in document.");
509 // ////////////////////////////////////////////
510 // SAVE Alignment Sequence Features
511 for (int i = 0, iSize = alignment
512 .getAlignmentSequenceCount(); i < iSize; i++)
514 AlignmentSequence valseq;
515 SequenceI alseq = (SequenceI) getvObj2jv(
516 valseq = alignment.getAlignmentSequence(i));
517 if (alseq != null && alseq.getSequenceFeatures() != null)
520 * We do not put local Alignment Sequence Features into the vamsas
524 * jalview.datamodel.SequenceFeature[] features = alseq
525 * .getSequenceFeatures(); for (int f = 0; f < features.length; f++) {
526 * if (features[f] != null) { AlignmentSequenceAnnotation valseqf = (
527 * AlignmentSequenceAnnotation) getjv2vObj(features[i]); if (valseqf
530 * valseqf = (AlignmentSequenceAnnotation) getDSAnnotationFromJalview(
531 * new AlignmentSequenceAnnotation(), features[i]);
532 * valseqf.setGraph(false);
533 * valseqf.addProperty(newProperty("jalview:feature"
534 * ,"boolean","true")); if (valseqf.getProvenance() == null) {
535 * valseqf.setProvenance(new Provenance()); }
536 * addProvenance(valseqf.getProvenance(), "created"); // JBPNote - //
537 * need to // update bindjvvobj(features[i], valseqf);
538 * valseq.addAlignmentSequenceAnnotation(valseqf); } } }
543 // ////////////////////////////////////////////
545 if (jal.getAlignmentAnnotation() != null)
547 jalview.datamodel.AlignmentAnnotation[] aa = jal
548 .getAlignmentAnnotation();
549 java.util.HashMap AlSeqMaps = new HashMap(); // stores int maps from
550 // alignment columns to
551 // sequence positions.
552 for (int i = 0; i < aa.length; i++)
554 if (aa[i] == null || isJalviewOnly(aa[i]))
558 if (aa[i].groupRef != null)
560 // TODO: store any group associated annotation references
562 "Group associated sequence annotation is not stored in VAMSAS document.");
565 if (aa[i].sequenceRef != null)
567 // Deal with sequence associated annotation
568 Vobject sref = getjv2vObj(aa[i].sequenceRef);
569 if (sref instanceof uk.ac.vamsas.objects.core.AlignmentSequence)
571 saveAlignmentSequenceAnnotation(AlSeqMaps,
572 (AlignmentSequence) sref, aa[i]);
576 // first find the alignment sequence to associate this with.
577 for (SequenceI jvalsq : av.getAlignment().getSequences())
579 // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence)
581 if (jvalsq.getDatasetSequence() == aa[i].sequenceRef)
583 Vobject alsref = getjv2vObj(jvalsq);
584 saveAlignmentSequenceAnnotation(AlSeqMaps,
585 (AlignmentSequence) alsref, aa[i]);
594 // add Alignment Annotation
595 uk.ac.vamsas.objects.core.AlignmentAnnotation an = (uk.ac.vamsas.objects.core.AlignmentAnnotation) getjv2vObj(
599 an = new uk.ac.vamsas.objects.core.AlignmentAnnotation();
600 an.setType(JALVIEW_ANNOTATION_ROW);
601 an.setDescription(aa[i].description);
602 alignment.addAlignmentAnnotation(an);
603 Seg vSeg = new Seg(); // TODO: refactor to have a default
604 // rangeAnnotationType initer/updater that
605 // takes a set of int ranges.
607 vSeg.setInclusive(true);
608 vSeg.setEnd(jal.getWidth());
612 an.setGraph(true); // aa[i].graph);
614 an.setLabel(aa[i].label);
615 an.setProvenance(dummyProvenance());
616 if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
618 an.setGroup(Integer.toString(aa[i].graphGroup)); // // JBPNote
633 AnnotationElement ae;
635 for (int a = 0; a < aa[i].annotations.length; a++)
637 if ((aa[i] == null) || (aa[i].annotations[a] == null))
642 ae = new AnnotationElement();
643 ae.setDescription(aa[i].annotations[a].description);
644 ae.addGlyph(new Glyph());
646 .setContent(aa[i].annotations[a].displayCharacter); // assume
655 ae.addValue(aa[i].annotations[a].value);
657 ae.setPosition(a + 1);
658 if (aa[i].annotations[a].secondaryStructure != ' ')
660 Glyph ss = new Glyph();
662 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
663 ss.setContent(String.valueOf(
664 aa[i].annotations[a].secondaryStructure));
667 an.addAnnotationElement(ae);
671 // an.addProperty(newProperty("jalview:editable", null,
673 // an.setModifiable(""); // TODO: This is not the way the
674 // modifiable flag is supposed to be used.
676 setAnnotationType(an, aa[i]);
678 if (aa[i].graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
681 an.setGroup(Integer.toString(aa[i].graphGroup));
682 if (aa[i].threshold != null && aa[i].threshold.displayed)
684 an.addProperty(Properties.newProperty(THRESHOLD,
685 Properties.FLOATTYPE,
686 "" + aa[i].threshold.value));
687 if (aa[i].threshold.label != null)
689 an.addProperty(Properties.newProperty(
690 THRESHOLD + "Name", Properties.STRINGTYPE,
691 "" + aa[i].threshold.label));
700 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT
703 // verify annotation - update (perhaps)
705 "update alignment sequence annotation. not yet implemented.");
709 // verify annotation - update (perhaps)
711 "updated alignment sequence annotation added.");
717 // /////////////////////////////////////////////////////
719 // //////////////////////////////////////////////
721 // /////////////////////////////////
722 // FIND ANY ASSOCIATED TREES
723 if (Desktop.getDesktopPane() != null)
725 javax.swing.JInternalFrame[] frames = Desktop.getInstance()
728 for (int t = 0; t < frames.length; t++)
730 if (frames[t] instanceof TreePanel)
732 TreePanel tp = (TreePanel) frames[t];
734 if (tp.getViewPort().getSequenceSetId()
735 .equals(av.getSequenceSetId()))
737 DatastoreItem vtree = new jalview.io.vamsas.Tree(this, tp,
743 // Store Jalview specific stuff in the Jalview appData
744 // not implemented in the SimpleDoc interface.
749 ex.printStackTrace();
756 * very quick test to see if the viewport would be stored in the vamsas
757 * document. Reasons for not storing include the unaligned flag being false
758 * (for all sequences, including the hidden ones!)
761 * @return true if alignment associated with this view will be stored in
764 public boolean alignmentWillBeSkipped(AlignmentViewport av)
766 return (!av.getAlignment().isAligned());
769 private void addToSkipList(AlignmentViewport av)
771 if (skipList == null)
773 skipList = new Hashtable();
775 skipList.put(av.getSequenceSetId(), av);
779 * remove docseqs from the given alignment marking provenance appropriately
780 * and removing any references to the sequences.
785 private void removeValignmentSequences(Alignment alignment,
788 // delete these from document. This really needs to be a generic document
789 // API function derived by CASTOR.
790 Enumeration en = docseqs.elements();
791 while (en.hasMoreElements())
793 alignment.removeAlignmentSequence(
794 (AlignmentSequence) en.nextElement());
796 Entry pe = addProvenance(alignment.getProvenance(),
797 "Removed " + docseqs.size() + " sequences");
798 en = alignment.enumerateAlignmentAnnotation();
799 Vector toremove = new Vector();
800 while (en.hasMoreElements())
802 uk.ac.vamsas.objects.core.AlignmentAnnotation alan = (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
804 if (alan.getSeqrefsCount() > 0)
807 Vector storem = new Vector();
808 Enumeration sr = alan.enumerateSeqrefs();
809 while (sr.hasMoreElements())
811 Object alsr = sr.nextElement();
812 if (docseqs.contains(alsr))
814 storem.addElement(alsr);
817 // remove references to the deleted sequences
818 sr = storem.elements();
819 while (sr.hasMoreElements())
821 alan.removeSeqrefs(sr.nextElement());
824 if (alan.getSeqrefsCount() == 0)
826 // should then delete alan from dataset
827 toremove.addElement(alan);
831 // remove any annotation that used to be associated to a specific bunch of
833 en = toremove.elements();
834 while (en.hasMoreElements())
836 alignment.removeAlignmentAnnotation(
837 (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
840 // TODO: search through alignment annotations to remove any references to
841 // this alignment sequence
845 * sync a jalview alignment seuqence into a vamsas alignment assumes all lock
846 * transformation/bindings have been sorted out before hand. creates/syncs the
847 * vamsas alignment sequence for jvalsq and adds it to the alignment if
848 * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
849 * and these are removed after being processed w.r.t a bound jvalsq
852 private boolean syncToAlignmentSequence(SequenceI jvalsq,
853 Alignment alignment, Vector unbounddocseq)
855 boolean modal = false;
856 // todo: islocked method here
857 boolean up2doc = false;
858 AlignmentSequence alseq = (AlignmentSequence) getjv2vObj(jvalsq);
861 alseq = new AlignmentSequence();
866 if (unbounddocseq != null)
868 unbounddocseq.removeElement(alseq);
871 // boolean locked = (alignment.getModifiable()==null ||
872 // alignment.getModifiable().length()>0);
873 // TODO: VAMSAS: translate lowercase symbols to annotation ?
874 if (up2doc || !alseq.getSequence().equals(jvalsq.getSequenceAsString()))
876 alseq.setSequence(jvalsq.getSequenceAsString());
877 alseq.setStart(jvalsq.getStart());
878 alseq.setEnd(jvalsq.getEnd());
881 if (up2doc || !alseq.getName().equals(jvalsq.getName()))
884 alseq.setName(jvalsq.getName());
886 if (jvalsq.getDescription() != null && (alseq.getDescription() == null
887 || !jvalsq.getDescription().equals(alseq.getDescription())))
890 alseq.setDescription(jvalsq.getDescription());
892 if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
895 "Serious Implementation error - Unbound dataset sequence in alignment: "
896 + jvalsq.getDatasetSequence());
898 alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
902 alignment.addAlignmentSequence(alseq);
903 bindjvvobj(jvalsq, alseq);
905 return up2doc || modal;
909 * locally sync a jalview alignment seuqence from a vamsas alignment assumes
910 * all lock transformation/bindings have been sorted out before hand.
911 * creates/syncs the jvalsq from the alignment sequence
913 private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
914 char valGapchar, char gapChar, List<SequenceI> dsseqs)
917 boolean modal = false;
918 // todo: islocked method here
919 boolean upFromdoc = false;
920 jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
928 // boolean locked = (alignment.getModifiable()==null ||
929 // alignment.getModifiable().length()>0);
930 // TODO: VAMSAS: translate lowercase symbols to annotation ?
932 || !valseq.getSequence().equals(alseq.getSequenceAsString()))
934 // this might go *horribly* wrong
935 alseq.setSequence(new String(valseq.getSequence())
936 .replace(valGapchar, gapChar));
937 alseq.setStart((int) valseq.getStart());
938 alseq.setEnd((int) valseq.getEnd());
941 if (!valseq.getName().equals(alseq.getName()))
944 alseq.setName(valseq.getName());
946 if (alseq.getDescription() == null || (valseq.getDescription() != null
947 && !alseq.getDescription().equals(valseq.getDescription())))
949 alseq.setDescription(valseq.getDescription());
952 if (modal && Cache.log.isDebugEnabled())
955 "Updating apparently edited sequence " + alseq.getName());
960 alseq = new jalview.datamodel.Sequence(valseq.getName(),
961 valseq.getSequence().replace(valGapchar, gapChar),
962 (int) valseq.getStart(), (int) valseq.getEnd());
964 Vobject datsetseq = (Vobject) valseq.getRefid();
965 if (datsetseq != null)
967 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
968 if (valseq.getDescription() != null)
970 alseq.setDescription(valseq.getDescription());
974 // inherit description line from dataset.
975 if (alseq.getDatasetSequence().getDescription() != null)
977 alseq.setDescription(
978 alseq.getDatasetSequence().getDescription());
992 "Invalid dataset sequence id (null) for alignment sequence "
993 + valseq.getVorbaId());
995 bindjvvobj(alseq, valseq);
996 alseq.setVamsasId(valseq.getVorbaId().getId());
999 Vobject datsetseq = (Vobject) valseq.getRefid();
1000 if (datsetseq != null)
1002 if (datsetseq != alseq.getDatasetSequence())
1006 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
1008 return upFromdoc || modal;
1011 private void initRangeAnnotationType(RangeAnnotation an,
1012 AlignmentAnnotation alan, int[] gapMap)
1014 Seg vSeg = new Seg();
1016 vSeg.setInclusive(true);
1017 vSeg.setEnd(gapMap.length);
1020 // LATER: much of this is verbatim from the alignmentAnnotation
1021 // method below. suggests refactoring to make rangeAnnotation the
1023 an.setDescription(alan.description);
1024 an.setLabel(alan.label);
1025 an.setGroup(Integer.toString(alan.graphGroup));
1034 AnnotationElement ae;
1035 for (int a = 0; a < alan.annotations.length; a++)
1037 if (alan.annotations[a] == null)
1042 ae = new AnnotationElement();
1043 ae.setDescription(alan.annotations[a].description);
1044 ae.addGlyph(new Glyph());
1045 ae.getGlyph(0).setContent(alan.annotations[a].displayCharacter); // assume
1052 if (alan.graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
1054 ae.addValue(alan.annotations[a].value);
1056 ae.setPosition(gapMap[a] + 1); // position w.r.t. AlignmentSequence
1058 if (alan.annotations[a].secondaryStructure != ' ')
1060 // we only write an annotation where it really exists.
1061 Glyph ss = new Glyph();
1063 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
1065 String.valueOf(alan.annotations[a].secondaryStructure));
1068 an.addAnnotationElement(ae);
1073 private void saveDatasetSequenceAnnotation(HashMap AlSeqMaps,
1074 uk.ac.vamsas.objects.core.Sequence sref, AlignmentAnnotation alan)
1078 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1079 // objects.core.AlignmentSequence) sref;
1080 uk.ac.vamsas.objects.core.DataSetAnnotations an = (uk.ac.vamsas.objects.core.DataSetAnnotations) getjv2vObj(
1082 int[] gapMap = getGapMap(AlSeqMaps, alan);
1085 an = new uk.ac.vamsas.objects.core.DataSetAnnotations();
1086 initRangeAnnotationType(an, alan, gapMap);
1088 an.setProvenance(dummyProvenance()); // get provenance as user
1089 // created, or jnet, or
1091 setAnnotationType(an, alan);
1092 an.setGroup(Integer.toString(alan.graphGroup)); // // JBPNote -
1100 if (alan.getThreshold() != null && alan.getThreshold().displayed)
1102 an.addProperty(Properties.newProperty(THRESHOLD,
1103 Properties.FLOATTYPE, "" + alan.getThreshold().value));
1104 if (alan.getThreshold().label != null)
1106 an.addProperty(Properties.newProperty(THRESHOLD + "Name",
1107 Properties.STRINGTYPE, "" + alan.getThreshold().label));
1110 ((DataSet) sref.getV_parent()).addDataSetAnnotations(an);
1111 bindjvvobj(alan, an);
1115 // update reference sequence Annotation
1116 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1119 // verify existing alignment sequence annotation is up to date
1120 System.out.println("update dataset sequence annotation.");
1124 // verify existing alignment sequence annotation is up to date
1126 "make new alignment dataset sequence annotation if modification has happened.");
1132 private int[] getGapMap(HashMap AlSeqMaps, AlignmentAnnotation alan)
1135 if (AlSeqMaps.containsKey(alan.sequenceRef))
1137 gapMap = (int[]) AlSeqMaps.get(alan.sequenceRef);
1141 gapMap = new int[alan.sequenceRef.getLength()];
1142 // map from alignment position to sequence position.
1143 int[] sgapMap = alan.sequenceRef.gapMap();
1144 for (int a = 0; a < sgapMap.length; a++)
1146 gapMap[sgapMap[a]] = a;
1152 private void saveAlignmentSequenceAnnotation(HashMap AlSeqMaps,
1153 AlignmentSequence alsref, AlignmentAnnotation alan)
1157 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1158 // objects.core.AlignmentSequence) sref;
1159 uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation an = (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) getjv2vObj(
1161 int[] gapMap = getGapMap(AlSeqMaps, alan);
1164 an = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation();
1165 initRangeAnnotationType(an, alan, gapMap);
1167 * I mean here that we don't actually have a semantic 'type' for the
1168 * annotation (this might be - score, intrinsic property, measurement,
1169 * something extracted from another program, etc)
1171 an.setType(JALVIEW_ANNOTATION_ROW); // TODO: better fix
1172 // this rough guess ;)
1173 alsref.addAlignmentSequenceAnnotation(an);
1174 bindjvvobj(alan, an);
1175 // These properties are directly supported by the
1176 // AlignmentSequenceAnnotation type.
1177 setAnnotationType(an, alan);
1178 an.setProvenance(dummyProvenance()); // get provenance as user
1179 // created, or jnet, or
1184 // update reference sequence Annotation
1185 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1188 // verify existing alignment sequence annotation is up to date
1189 System.out.println("update alignment sequence annotation.");
1193 // verify existing alignment sequence annotation is up to date
1195 "make new alignment sequence annotation if modification has happened.");
1201 * set vamsas annotation object type from jalview annotation
1206 private void setAnnotationType(RangeAnnotation an,
1207 AlignmentAnnotation alan)
1209 if (an instanceof AlignmentSequenceAnnotation)
1211 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1213 ((AlignmentSequenceAnnotation) an).setGraph(true);
1217 ((AlignmentSequenceAnnotation) an).setGraph(false);
1220 if (an instanceof uk.ac.vamsas.objects.core.AlignmentAnnotation)
1222 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1224 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an).setGraph(true);
1228 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an)
1234 case AlignmentAnnotation.BAR_GRAPH:
1235 an.addProperty(Properties.newProperty(DISCRETE_ANNOTATION,
1236 Properties.BOOLEANTYPE, "true"));
1238 case AlignmentAnnotation.LINE_GRAPH:
1239 an.addProperty(Properties.newProperty(CONTINUOUS_ANNOTATION,
1240 Properties.BOOLEANTYPE, "true"));
1243 // don't add any kind of discrete or continous property info.
1248 * get start<end range of segment, adjusting for inclusivity flag and
1252 * @param ensureDirection
1253 * when true - always ensure start is less than end.
1254 * @return int[] { start, end, direction} where direction==1 for range running
1255 * from end to start.
1257 private int[] getSegRange(Seg visSeg, boolean ensureDirection)
1259 boolean incl = visSeg.getInclusive();
1260 // adjust for inclusive flag.
1261 int pol = (visSeg.getStart() <= visSeg.getEnd()) ? 1 : -1; // polarity of
1263 int start = visSeg.getStart() + (incl ? 0 : pol);
1264 int end = visSeg.getEnd() + (incl ? 0 : -pol);
1265 if (ensureDirection && pol == -1)
1267 // jalview doesn't deal with inverted ranges, yet.
1272 return new int[] { start, end, pol < 0 ? 1 : 0 };
1278 * @return true if annotation is not to be stored in document
1280 private boolean isJalviewOnly(AlignmentAnnotation annotation)
1282 return annotation.autoCalculated || annotation.label.equals("Quality")
1283 || annotation.label.equals("Conservation")
1284 || annotation.label.equals("Consensus");
1287 boolean dojvsync = true;
1289 // boolean dojvsync = false; // disables Jalview AppData IO
1291 * list of alignment views created when updating Jalview from document.
1293 private final Vector newAlignmentViews = new Vector();
1296 * update local jalview view settings from the stored appdata (if any)
1298 public void updateJalviewFromAppdata()
1300 // recover any existing Jalview data from appdata
1301 // TODO: recover any PDB files stored as attachments in the vamsas session
1302 // and initialise the Jalview2XML.alreadyLoadedPDB hashtable with mappings
1305 final IClientAppdata cappdata = cdoc.getClientAppdata();
1306 if (cappdata != null)
1308 if (cappdata.hasClientAppdata())
1310 // TODO: how to check version of Jalview client app data and whether
1311 // it has been modified
1312 // client data is shared over all app clients
1315 // jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
1316 Jalview2XML fromxml = new Jalview2XML();
1317 fromxml.attemptversion1parse = false;
1318 fromxml.setUniqueSetSuffix("");
1319 fromxml.setObjectMappingTables(vobj2jv, jv2vobj); // mapKeysToString
1321 // mapValuesToString
1322 fromxml.setSkipList(skipList);
1323 jalview.util.jarInputStreamProvider jprovider = new jalview.util.jarInputStreamProvider()
1327 public String getFilename()
1330 // TODO Get the vamsas session ID here
1331 return "Jalview Vamsas Document Client Data";
1335 public JarInputStream getJarInputStream() throws IOException
1337 jalview.bin.Cache.log.debug(
1338 "Returning client input stream for Jalview from Vamsas Document.");
1339 return new JarInputStream(cappdata.getClientInputStream());
1344 fromxml.loadJalviewAlign(jprovider);
1346 } catch (Exception e)
1349 } catch (OutOfMemoryError e)
1358 if (cappdata.hasUserAppdata())
1360 // TODO: how to check version of Jalview user app data and whether it
1361 // has been modified
1362 // user data overrides data shared over all app clients ?
1365 Jalview2XML fromxml = new Jalview2XML();
1366 fromxml.attemptversion1parse = false;
1367 fromxml.setUniqueSetSuffix("");
1368 fromxml.setSkipList(skipList);
1369 fromxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1370 mapValuesToString(jv2vobj));
1371 jalview.util.jarInputStreamProvider jarstream = new jalview.util.jarInputStreamProvider()
1375 public String getFilename()
1378 // TODO Get the vamsas session ID here
1379 return "Jalview Vamsas Document User Data";
1383 public JarInputStream getJarInputStream() throws IOException
1385 jalview.bin.Cache.log.debug(
1386 "Returning user input stream for Jalview from Vamsas Document.");
1387 return new JarInputStream(cappdata.getUserInputStream());
1392 fromxml.loadJalviewAlign(jarstream);
1394 } catch (Exception e)
1397 } catch (OutOfMemoryError e)
1407 flushAlignViewports();
1411 * remove any spurious views generated by document synchronization
1413 private void flushAlignViewports()
1415 // remove any additional viewports originally recovered from the vamsas
1417 // search for all alignframes containing viewports generated from document
1419 // and if any contain more than one view, then remove the one generated by
1421 AlignmentViewport views[], av = null;
1422 AlignFrame af = null;
1423 Iterator newviews = newAlignmentViews.iterator();
1424 while (newviews.hasNext())
1426 av = (AlignmentViewport) newviews.next();
1427 af = Desktop.getAlignFrameFor(av);
1428 // TODO implement this : af.getNumberOfViews
1429 String seqsetidobj = av.getSequenceSetId();
1430 views = Desktop.getViewports(seqsetidobj);
1432 .debug("Found " + (views == null ? " no " : "" + views.length)
1433 + " views for '" + av.getSequenceSetId() + "'");
1434 if (views.length > 1)
1436 // we need to close the original document view.
1438 // work out how to do this by seeing if the views are gathered.
1439 // pretty clunky but the only way to do this without adding more flags
1440 // to the align frames.
1441 boolean gathered = false;
1442 String newviewid = null;
1443 List<AlignedCodonFrame> mappings = av.getAlignment()
1445 for (int i = 0; i < views.length; i++)
1449 AlignFrame viewframe = Desktop.getAlignFrameFor(views[i]);
1450 if (viewframe == af)
1454 newviewid = views[i].getSequenceSetId();
1458 // lose the reference to the vamsas document created view
1462 // close the view generated by the vamsas document synchronization
1469 af.closeMenuItem_actionPerformed(false);
1471 replaceJvObjMapping(seqsetidobj, newviewid);
1472 seqsetidobj = newviewid;
1473 // not sure if we need to do this:
1475 if (false) // mappings != null)
1477 // ensure sequence mappings from vamsas document view still
1479 if (mappings != null)
1481 Desktop.getStructureSelectionManager()
1482 .registerMappings(mappings);
1486 // ensure vamsas object binds to the stored views retrieved from
1488 // jalview.structure.StructureSelectionManager
1489 // .getStructureSelectionManager()
1490 // .addStructureViewerListener(viewframe.alignPanel);
1495 newAlignmentViews.clear();
1499 * replaces oldjvobject with newjvobject in the Jalview Object <> VorbaID
1502 * @param oldjvobject
1503 * @param newjvobject
1506 private void replaceJvObjMapping(Object oldjvobject, Object newjvobject)
1508 Object vobject = jv2vobj.remove(oldjvobject);
1509 if (vobject == null)
1511 // NOTE: this happens if user deletes object in one session then updates
1512 // from another client
1513 throw new Error(MessageManager.formatMessage(
1514 "error.implementation_error_old_jalview_object_not_bound",
1516 { oldjvobject.toString() }));
1518 if (newjvobject != null)
1520 jv2vobj.put(newjvobject, vobject);
1521 vobj2jv.put(vobject, newjvobject);
1526 * Update the jalview client and user appdata from the local jalview settings
1528 public void updateJalviewClientAppdata()
1530 final IClientAppdata cappdata = cdoc.getClientAppdata();
1531 if (cappdata != null)
1535 Jalview2XML jxml = new Jalview2XML();
1536 jxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1537 mapValuesToString(jv2vobj));
1538 jxml.setSkipList(skipList);
1542 new JarOutputStream(cappdata.getClientOutputStream()));
1545 } catch (Exception e)
1547 // TODO raise GUI warning if user requests it.
1548 jalview.bin.Cache.log.error(
1549 "Couldn't update jalview client application data. Giving up - local settings probably lost.",
1555 jalview.bin.Cache.log.error(
1556 "Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
1561 * translate the Vobject keys to strings for use in Jalview2XML
1566 private IdentityHashMap mapValuesToString(IdentityHashMap jv2vobj2)
1568 IdentityHashMap mapped = new IdentityHashMap();
1569 Iterator keys = jv2vobj2.keySet().iterator();
1570 while (keys.hasNext())
1572 Object key = keys.next();
1573 mapped.put(key, jv2vobj2.get(key).toString());
1579 * translate the Vobject values to strings for use in Jalview2XML
1582 * @return hashtable with string values
1584 private Hashtable mapKeysToString(Hashtable vobj2jv2)
1586 Hashtable mapped = new Hashtable();
1587 Iterator keys = vobj2jv2.keySet().iterator();
1588 while (keys.hasNext())
1590 Object key = keys.next();
1591 mapped.put(key.toString(), vobj2jv2.get(key));
1597 * synchronize Jalview from the vamsas document
1599 * @return number of new views from document
1601 public int updateToJalview()
1603 VAMSAS _roots[] = cdoc.getVamsasRoots();
1605 for (int _root = 0; _root < _roots.length; _root++)
1607 VAMSAS root = _roots[_root];
1608 boolean newds = false;
1609 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
1611 // ///////////////////////////////////
1613 DataSet dataset = root.getDataSet(_ds);
1614 int i, iSize = dataset.getSequenceCount();
1615 List<SequenceI> dsseqs;
1616 jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(
1619 if (jdataset == null)
1621 Cache.log.debug("Initialising new jalview dataset fields");
1623 dsseqs = new Vector();
1627 Cache.log.debug("Update jalview dataset from vamsas.");
1628 jremain = jdataset.getHeight();
1629 dsseqs = jdataset.getSequences();
1632 // TODO: test sequence merging - we preserve existing non vamsas
1633 // sequences but add in any new vamsas ones, and don't yet update any
1634 // sequence attributes
1635 for (i = 0; i < iSize; i++)
1637 Sequence vdseq = dataset.getSequence(i);
1638 jalview.io.vamsas.Datasetsequence dssync = new Datasetsequence(
1641 jalview.datamodel.SequenceI dsseq = (SequenceI) dssync.getJvobj();
1642 if (dssync.isAddfromdoc())
1646 if (vdseq.getDbRefCount() > 0)
1648 DbRef[] dbref = vdseq.getDbRef();
1649 for (int db = 0; db < dbref.length; db++)
1651 new jalview.io.vamsas.Dbref(this, dbref[db], vdseq, dsseq);
1654 dsseq.updatePDBIds();
1660 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1661 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1663 seqs[i] = dsseqs.get(i);
1664 dsseqs.set(i, null);
1666 jdataset = new jalview.datamodel.Alignment(seqs);
1667 Cache.log.debug("New vamsas dataset imported into jalview.");
1668 bindjvvobj(jdataset, dataset);
1671 // add any new dataset sequence feature annotations
1672 if (dataset.getDataSetAnnotations() != null)
1674 for (int dsa = 0; dsa < dataset
1675 .getDataSetAnnotationsCount(); dsa++)
1677 DataSetAnnotations dseta = dataset.getDataSetAnnotations(dsa);
1678 // TODO: deal with group annotation on datset sequences.
1679 if (dseta.getSeqRefCount() == 1)
1681 SequenceI dsSeq = (SequenceI) getvObj2jv(
1682 (Vobject) dseta.getSeqRef(0)); // TODO: deal with group
1687 jalview.bin.Cache.log.warn(
1688 "Couldn't resolve jalview sequenceI for dataset object reference "
1689 + ((Vobject) dataset
1690 .getDataSetAnnotations(dsa)
1691 .getSeqRef(0)).getVorbaId()
1696 if (dseta.getAnnotationElementCount() == 0)
1698 new jalview.io.vamsas.Sequencefeature(this, dseta, dsSeq);
1703 // TODO: deal with alignmentAnnotation style annotation
1704 // appearing on dataset sequences.
1705 // JBPNote: we could just add them to all alignments but
1706 // that may complicate cross references in the jalview
1709 "Ignoring dataset annotation with annotationElements. Not yet supported in jalview.");
1716 "Ignoring multiply referenced dataset sequence annotation for binding to datsaet sequence features.");
1720 if (dataset.getAlignmentCount() > 0)
1722 // LOAD ALIGNMENTS from DATASET
1724 for (int al = 0, nal = dataset
1725 .getAlignmentCount(); al < nal; al++)
1727 uk.ac.vamsas.objects.core.Alignment alignment = dataset
1729 // TODO check this handles multiple views properly
1730 AlignmentViewport av = findViewport(alignment);
1732 jalview.datamodel.AlignmentI jal = null;
1735 // TODO check that correct alignment object is retrieved when
1736 // hidden seqs exist.
1737 jal = (av.hasHiddenRows()) ? av.getAlignment()
1738 .getHiddenSequences().getFullAlignment()
1739 : av.getAlignment();
1741 iSize = alignment.getAlignmentSequenceCount();
1742 boolean refreshal = false;
1743 Vector newasAnnots = new Vector();
1744 char gapChar = ' '; // default for new alignments read in from the
1748 dsseqs = jal.getSequences(); // for merge/update
1749 gapChar = jal.getGapCharacter();
1753 dsseqs = new Vector();
1755 char valGapchar = alignment.getGapChar().charAt(0);
1756 for (i = 0; i < iSize; i++)
1758 AlignmentSequence valseq = alignment.getAlignmentSequence(i);
1759 jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(
1761 if (syncFromAlignmentSequence(valseq, valGapchar, gapChar,
1762 dsseqs) && alseq != null)
1765 // updated to sequence from the document
1769 if (valseq.getAlignmentSequenceAnnotationCount() > 0)
1771 AlignmentSequenceAnnotation[] vasannot = valseq
1772 .getAlignmentSequenceAnnotation();
1773 for (int a = 0; a < vasannot.length; a++)
1775 jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
1776 vasannot[a]); // TODO:
1784 int se[] = getBounds(vasannot[a]);
1785 asa = getjAlignmentAnnotation(jal, vasannot[a]);
1786 asa.setSequenceRef(alseq);
1787 asa.createSequenceMapping(alseq, se[0], false); // TODO:
1798 alseq.addAlignmentAnnotation(asa);
1799 bindjvvobj(asa, vasannot[a]);
1801 newasAnnots.add(asa);
1805 // update existing annotation - can do this in place
1806 if (vasannot[a].getModifiable() == null) // TODO: USE
1812 "UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
1813 // TODO: should at least replace with new one - otherwise
1814 // things will break
1815 // basically do this:
1816 // int se[] = getBounds(vasannot[a]);
1817 // asa.update(getjAlignmentAnnotation(jal, vasannot[a]));
1818 // // update from another annotation object in place.
1819 // asa.createSequenceMapping(alseq, se[0], false);
1828 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1829 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1831 seqs[i] = dsseqs.get(i);
1832 dsseqs.set(i, null);
1834 jal = new jalview.datamodel.Alignment(seqs);
1835 Cache.log.debug("New vamsas alignment imported into jalview "
1836 + alignment.getVorbaId().getId());
1837 jal.setDataset(jdataset);
1839 if (newasAnnots != null && newasAnnots.size() > 0)
1841 // Add the new sequence annotations in to the alignment.
1842 for (int an = 0, anSize = newasAnnots
1843 .size(); an < anSize; an++)
1846 (AlignmentAnnotation) newasAnnots.elementAt(an));
1847 // TODO: check if anything has to be done - like calling
1848 // adjustForAlignment or something.
1849 newasAnnots.setElementAt(null, an);
1853 // //////////////////////////////////////////
1854 // //LOAD ANNOTATIONS FOR THE ALIGNMENT
1855 // ////////////////////////////////////
1856 if (alignment.getAlignmentAnnotationCount() > 0)
1858 uk.ac.vamsas.objects.core.AlignmentAnnotation[] an = alignment
1859 .getAlignmentAnnotation();
1861 for (int j = 0; j < an.length; j++)
1863 jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
1867 // update or stay the same.
1868 // TODO: should at least replace with a new one - otherwise
1869 // things will break
1870 // basically do this:
1871 // jan.update(getjAlignmentAnnotation(jal, an[a])); // update
1872 // from another annotation object in place.
1875 "update from vamsas alignment annotation to existing jalview alignment annotation.");
1876 if (an[j].getModifiable() == null) // TODO: USE VAMSAS
1877 // LIBRARY OBJECT LOCK
1880 // TODO: user defined annotation is totally mutable... - so
1881 // load it up or throw away if locally edited.
1883 "NOT IMPLEMENTED - Recovering user-modifiable annotation - yet...");
1885 // TODO: compare annotation element rows
1886 // TODO: compare props.
1890 jan = getjAlignmentAnnotation(jal, an[j]);
1891 // TODO: ensure we add the alignment annotation before the
1892 // automatic annotation rows
1893 jal.addAnnotation(jan);
1894 bindjvvobj(jan, an[j]);
1899 AlignFrame alignFrame;
1902 Cache.log.debug("New alignframe for alignment "
1903 + alignment.getVorbaId());
1904 // ///////////////////////////////
1905 // construct alignment view
1906 alignFrame = new AlignFrame(jal, AlignFrame.DEFAULT_WIDTH,
1907 AlignFrame.DEFAULT_HEIGHT,
1908 alignment.getVorbaId().toString());
1909 av = alignFrame.getViewport();
1910 newAlignmentViews.addElement(av);
1911 String title = alignment.getProvenance()
1913 alignment.getProvenance().getEntryCount() - 1)
1915 if (alignment.getPropertyCount() > 0)
1917 for (int p = 0, pe = alignment
1918 .getPropertyCount(); p < pe; p++)
1920 if (alignment.getProperty(p).getName().equals("title"))
1922 title = alignment.getProperty(p).getContent();
1926 // TODO: automatically create meaningful title for a vamsas
1927 // alignment using its provenance.
1928 if (Cache.log.isDebugEnabled())
1930 title = title + "(" + alignment.getVorbaId() + ")";
1933 jalview.gui.Desktop.addInternalFrame(alignFrame, title,
1934 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1935 bindjvvobj(av.getSequenceSetId(), alignment);
1939 // find the alignFrame for jal.
1940 // TODO: fix this so we retrieve the alignFrame handing av
1941 // *directly* (JBPNote - don't understand this now)
1942 // TODO: make sure all associated views are refreshed
1943 alignFrame = Desktop.getAlignFrameFor(av);
1946 av.alignmentChanged(alignFrame.alignPanel);
1947 alignFrame.alignPanel.adjustAnnotationHeight();
1951 // /////////////////////////////////////
1952 if (alignment.getTreeCount() > 0)
1955 for (int t = 0; t < alignment.getTreeCount(); t++)
1957 jalview.io.vamsas.Tree vstree = new jalview.io.vamsas.Tree(
1958 this, alignFrame, alignment.getTree(t));
1959 TreePanel tp = null;
1960 if (vstree.isValidTree())
1962 tp = alignFrame.showNewickTree(vstree.getNewickTree(),
1963 vstree.getTitle(), vstree.getInputData(), 600,
1964 500, t * 20 + 50, t * 20 + 50);
1969 bindjvvobj(tp, alignment.getTree(t));
1972 vstree.UpdateSequenceTreeMap(tp);
1973 } catch (RuntimeException e)
1975 Cache.log.warn("update of labels failed.", e);
1980 Cache.log.warn("Cannot create tree for tree " + t
1982 + alignment.getTree(t).getVorbaId());
1990 // we do sequenceMappings last because they span all datasets in a vamsas
1992 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
1994 DataSet dataset = root.getDataSet(_ds);
1995 if (dataset.getSequenceMappingCount() > 0)
1997 for (int sm = 0, smCount = dataset
1998 .getSequenceMappingCount(); sm < smCount; sm++)
2000 Rangetype seqmap = new jalview.io.vamsas.Sequencemapping(this,
2001 dataset.getSequenceMapping(sm));
2006 return newAlignmentViews.size();
2009 public AlignmentViewport findViewport(Alignment alignment)
2011 AlignmentViewport av = null;
2012 AlignmentViewport[] avs = Desktop
2013 .getViewports((String) getvObj2jv(alignment));
2021 // bitfields - should be a template in j1.5
2022 private static final int HASSECSTR = 0;
2024 private static final int HASVALS = 1;
2026 private static final int HASHPHOB = 2;
2028 private static final int HASDC = 3;
2030 private static final int HASDESCSTR = 4;
2032 private static final int HASTWOSTATE = 5; // not used yet.
2035 * parses the AnnotationElements - if they exist - into
2036 * jalview.datamodel.Annotation[] rows Two annotation rows are made if there
2037 * are distinct annotation for both at 'pos' and 'after pos' at any particular
2041 * @return { boolean[static int constants ], int[ae.length] - map to annotated
2042 * object frame, jalview.datamodel.Annotation[],
2043 * jalview.datamodel.Annotation[] (after)}
2045 private Object[] parseRangeAnnotation(
2046 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2048 // set these attributes by looking in the annotation to decide what kind of
2049 // alignment annotation rows will be made
2050 // TODO: potentially we might make several annotation rows from one vamsas
2051 // alignment annotation. the jv2Vobj binding mechanism
2052 // may not quite cope with this (without binding an array of annotations to
2053 // a vamsas alignment annotation)
2054 // summary flags saying what we found over the set of annotation rows.
2055 boolean[] AeContent = new boolean[] { false, false, false, false,
2057 int[] rangeMap = getMapping(annotation);
2058 jalview.datamodel.Annotation[][] anot = new jalview.datamodel.Annotation[][] {
2059 new jalview.datamodel.Annotation[rangeMap.length],
2060 new jalview.datamodel.Annotation[rangeMap.length] };
2061 boolean mergeable = true; // false if 'after positions cant be placed on
2062 // same annotation row as positions.
2064 if (annotation.getAnnotationElementCount() > 0)
2066 AnnotationElement ae[] = annotation.getAnnotationElement();
2067 for (int aa = 0; aa < ae.length; aa++)
2069 int pos = (int) ae[aa].getPosition() - 1; // pos counts from 1 to
2070 // (|seg.start-seg.end|+1)
2071 if (pos >= 0 && pos < rangeMap.length)
2073 int row = ae[aa].getAfter() ? 1 : 0;
2074 if (anot[row][pos] != null)
2076 // only time this should happen is if the After flag is set.
2077 Cache.log.debug("Ignoring duplicate annotation site at " + pos);
2080 if (anot[1 - row][pos] != null)
2085 if (ae[aa].getDescription() != null)
2087 desc = ae[aa].getDescription();
2088 if (desc.length() > 0)
2090 // have imported valid description string
2091 AeContent[HASDESCSTR] = true;
2094 String dc = null; // ae[aa].getDisplayCharacter()==null ? "dc" :
2095 // ae[aa].getDisplayCharacter();
2096 String ss = null; // ae[aa].getSecondaryStructure()==null ? "ss" :
2097 // ae[aa].getSecondaryStructure();
2098 java.awt.Color colour = null;
2099 if (ae[aa].getGlyphCount() > 0)
2101 Glyph[] glyphs = ae[aa].getGlyph();
2102 for (int g = 0; g < glyphs.length; g++)
2104 if (glyphs[g].getDict().equals(
2105 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE))
2107 ss = glyphs[g].getContent();
2108 AeContent[HASSECSTR] = true;
2110 else if (glyphs[g].getDict().equals(
2111 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO))
2113 Cache.log.debug("ignoring hydrophobicity glyph marker.");
2114 AeContent[HASHPHOB] = true;
2115 char c = (dc = glyphs[g].getContent()).charAt(0);
2116 // dc may get overwritten - but we still set the colour.
2117 colour = new java.awt.Color(c == '+' ? 255 : 0,
2118 c == '.' ? 255 : 0, c == '-' ? 255 : 0);
2121 else if (glyphs[g].getDict().equals(
2122 uk.ac.vamsas.objects.utils.GlyphDictionary.DEFAULT))
2124 dc = glyphs[g].getContent();
2125 AeContent[HASDC] = true;
2130 "IMPLEMENTATION TODO: Ignoring unknown glyph type "
2131 + glyphs[g].getDict());
2136 if (ae[aa].getValueCount() > 0)
2138 AeContent[HASVALS] = true;
2139 if (ae[aa].getValueCount() > 1)
2142 "ignoring additional " + (ae[aa].getValueCount() - 1)
2143 + " values in annotation element.");
2145 val = ae[aa].getValue(0);
2149 anot[row][pos] = new jalview.datamodel.Annotation(
2150 (dc != null) ? dc : "", desc,
2151 (ss != null) ? ss.charAt(0) : ' ', val);
2155 anot[row][pos] = new jalview.datamodel.Annotation(
2156 (dc != null) ? dc : "", desc,
2157 (ss != null) ? ss.charAt(0) : ' ', val, colour);
2162 Cache.log.warn("Ignoring out of bound annotation element " + aa
2163 + " in " + annotation.getVorbaId().getId());
2166 // decide on how many annotation rows are needed.
2169 for (int i = 0; i < anot[0].length; i++)
2171 if (anot[1][i] != null)
2173 anot[0][i] = anot[1][i];
2174 anot[0][i].description = anot[0][i].description + " (after)";
2175 AeContent[HASDESCSTR] = true; // we have valid description string
2184 for (int i = 0; i < anot[0].length; i++)
2186 anot[1][i].description = anot[1][i].description + " (after)";
2189 return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
2193 // no annotations to parse. Just return an empty annotationElement[]
2195 return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
2202 * the jalview alignment to which the annotation will be attached
2203 * (ideally - freshly updated from corresponding vamsas alignment)
2205 * @return unbound jalview alignment annotation object.
2207 private jalview.datamodel.AlignmentAnnotation getjAlignmentAnnotation(
2208 jalview.datamodel.AlignmentI jal,
2209 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2211 if (annotation == null)
2216 // hasSequenceRef=annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class);
2217 // boolean hasProvenance=hasSequenceRef ||
2218 // (annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentAnnotation.class));
2220 * int se[] = getBounds(annotation); if (se==null) se=new int[]
2221 * {0,jal.getWidth()-1};
2223 Object[] parsedRangeAnnotation = parseRangeAnnotation(annotation);
2224 String a_label = annotation.getLabel();
2225 String a_descr = annotation.getDescription();
2226 GraphLine gl = null;
2228 boolean interp = true; // cleared if annotation is DISCRETE
2229 // set type and other attributes from properties
2230 if (annotation.getPropertyCount() > 0)
2232 // look for special jalview properties
2233 uk.ac.vamsas.objects.core.Property[] props = annotation.getProperty();
2234 for (int p = 0; p < props.length; p++)
2236 if (props[p].getName().equalsIgnoreCase(DISCRETE_ANNOTATION))
2238 type = AlignmentAnnotation.BAR_GRAPH;
2241 else if (props[p].getName().equalsIgnoreCase(CONTINUOUS_ANNOTATION))
2243 type = AlignmentAnnotation.LINE_GRAPH;
2245 else if (props[p].getName().equalsIgnoreCase(THRESHOLD))
2250 val = new Float(props[p].getContent());
2251 } catch (Exception e)
2253 Cache.log.warn("Failed to parse threshold property");
2259 gl = new GraphLine(val.floatValue(), "",
2260 java.awt.Color.black);
2264 gl.value = val.floatValue();
2268 else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name"))
2272 gl = new GraphLine(0, "", java.awt.Color.black);
2274 gl.label = props[p].getContent();
2278 jalview.datamodel.AlignmentAnnotation jan = null;
2279 if (a_label == null || a_label.length() == 0)
2281 a_label = annotation.getType();
2282 if (a_label.length() == 0)
2284 a_label = "Unamed annotation";
2287 if (a_descr == null || a_descr.length() == 0)
2289 a_descr = "Annotation of type '" + annotation.getType() + "'";
2291 if (parsedRangeAnnotation == null)
2294 "Inserting empty annotation row elements for a whole-alignment annotation.");
2298 if (parsedRangeAnnotation[3] != null)
2300 Cache.log.warn("Ignoring 'After' annotation row in "
2301 + annotation.getVorbaId());
2303 jalview.datamodel.Annotation[] arow = (jalview.datamodel.Annotation[]) parsedRangeAnnotation[2];
2304 boolean[] has = (boolean[]) parsedRangeAnnotation[0];
2305 // VAMSAS: getGraph is only on derived annotation for alignments - in this
2306 // way its 'odd' - there is already an existing TODO about removing this
2307 // flag as being redundant
2309 * if((annotation.getClass().equals(uk.ac.vamsas.objects.core.
2310 * AlignmentAnnotation.class) &&
2311 * ((uk.ac.vamsas.objects.core.AlignmentAnnotation)annotation).getGraph())
2312 * || (hasSequenceRef=true &&
2313 * ((uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation
2314 * )annotation).getGraph())) {
2320 type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default
2326 // no hints - so we ensure HPHOB display is like this.
2327 type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH;
2330 // make bounds and automatic description strings for jalview user's
2331 // benefit (these shouldn't be written back to vamsas document)
2332 boolean first = true;
2333 float min = 0, max = 1;
2335 for (int i = 0; i < arow.length; i++)
2337 if (arow[i] != null)
2339 if (i - lastval > 1 && interp)
2341 // do some interpolation *between* points
2342 if (arow[lastval] != null)
2344 float interval = arow[i].value - arow[lastval].value;
2345 interval /= i - lastval;
2346 float base = arow[lastval].value;
2347 for (int ip = lastval + 1, np = 0; ip < i; np++, ip++)
2349 arow[ip] = new jalview.datamodel.Annotation("", "", ' ',
2350 interval * np + base);
2351 // NB - Interpolated points don't get a tooltip and
2357 // check range - shouldn't we have a min and max property in the
2358 // annotation object ?
2361 min = max = arow[i].value;
2366 if (arow[i].value < min)
2368 min = arow[i].value;
2370 else if (arow[i].value > max)
2372 max = arow[i].value;
2375 // make tooltip and display char value
2376 if (!has[HASDESCSTR])
2378 arow[i].description = arow[i].value + "";
2384 if (arow[i].description != null
2385 && arow[i].description.length() < 3)
2387 // copy over the description as the display char.
2388 arow[i].displayCharacter = new String(
2389 arow[i].description);
2394 // mark the position as a point used for the interpolation.
2395 arow[i].displayCharacter = arow[i].value + "";
2400 jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
2401 arow, min, max, type);
2405 if (annotation.getAnnotationElementCount() == 0)
2407 // empty annotation array
2408 // TODO: alignment 'features' compare rangeType spec to alignment
2409 // width - if it is not complete, then mark regions on the annotation
2412 jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
2414 jan.setThreshold(null);
2415 jan.annotationId = annotation.getVorbaId().toString(); // keep all the
2418 if (annotation.getLinkCount() > 0)
2420 Cache.log.warn("Ignoring " + annotation.getLinkCount()
2421 + "links added to AlignmentAnnotation.");
2423 if (annotation.getModifiable() == null
2424 || annotation.getModifiable().length() == 0) // TODO: USE VAMSAS
2428 jan.editable = true;
2432 if (annotation.getGroup() != null
2433 && annotation.getGroup().length() > 0)
2435 jan.graphGroup = Integer.parseInt(annotation.getGroup()); // TODO:
2443 } catch (Exception e)
2446 "UNIMPLEMENTED : Couldn't parse non-integer group value for setting graphGroup correctly.");
2456 * get real bounds of a RangeType's specification. start and end are an
2457 * inclusive range within which all segments and positions lie. TODO: refactor
2461 * @return int[] { start, end}
2463 private int[] getBounds(RangeType dseta)
2468 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2470 throw new Error(MessageManager.getString(
2471 "error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2473 if (dseta.getSegCount() > 0)
2475 se = getSegRange(dseta.getSeg(0), true);
2476 for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++)
2478 int nse[] = getSegRange(dseta.getSeg(s), true);
2489 if (dseta.getPosCount() > 0)
2491 // could do a polarity for pos range too. and pass back indication of
2493 int pos = dseta.getPos(0).getI();
2494 se = new int[] { pos, pos };
2495 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2497 pos = dseta.getPos(p).getI();
2514 * map from a rangeType's internal frame to the referenced object's coordinate
2518 * @return int [] { ref(pos)...} for all pos in rangeType's frame.
2520 private int[] getMapping(RangeType dseta)
2522 Vector posList = new Vector();
2526 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2528 throw new Error(MessageManager.getString(
2529 "error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2531 if (dseta.getSegCount() > 0)
2533 for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++)
2535 se = getSegRange(dseta.getSeg(s), false);
2536 int se_end = se[1 - se[2]] + (se[2] == 0 ? 1 : -1);
2537 for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1)
2539 posList.add(new Integer(p));
2543 else if (dseta.getPosCount() > 0)
2545 int pos = dseta.getPos(0).getI();
2547 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2549 pos = dseta.getPos(p).getI();
2550 posList.add(new Integer(pos));
2554 if (posList != null && posList.size() > 0)
2556 int[] range = new int[posList.size()];
2557 for (int i = 0; i < range.length; i++)
2559 range[i] = ((Integer) posList.elementAt(i)).intValue();
2570 * where the from range is the local mapped range, and the to range
2571 * is the 'mapped' range in the MapRangeType
2578 private jalview.util.MapList parsemapType(MapType maprange, int localu,
2581 jalview.util.MapList ml = null;
2582 int[] localRange = getMapping(maprange.getLocal());
2583 int[] mappedRange = getMapping(maprange.getMapped());
2584 long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit()
2586 long mu = maprange.getMapped().hasUnit()
2587 ? maprange.getMapped().getUnit()
2589 ml = new jalview.util.MapList(localRange, mappedRange, (int) lu,
2595 * initialise a range type object from a set of start/end inclusive intervals
2600 private void initRangeType(RangeType mrt, List<int[]> ranges)
2602 for (int[] range : ranges)
2604 Seg vSeg = new Seg();
2605 vSeg.setStart(range[0]);
2606 vSeg.setEnd(range[1]);
2612 * initialise a MapType object from a MapList object.
2618 private void initMapType(MapType maprange, jalview.util.MapList ml,
2621 maprange.setLocal(new Local());
2622 maprange.setMapped(new Mapped());
2623 initRangeType(maprange.getLocal(), ml.getFromRanges());
2624 initRangeType(maprange.getMapped(), ml.getToRanges());
2627 maprange.getLocal().setUnit(ml.getFromRatio());
2628 maprange.getLocal().setUnit(ml.getToRatio());
2633 * not needed now. Provenance getVamsasProvenance(jalview.datamodel.Provenance
2634 * jprov) { jalview.datamodel.ProvenanceEntry[] entries = null; // TODO: fix
2635 * App and Action here. Provenance prov = new Provenance();
2636 * org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( new
2637 * java.util.Date()); Entry provEntry;
2639 * if (jprov != null) { entries = jprov.getEntries(); for (int i = 0; i <
2640 * entries.length; i++) { provEntry = new Entry(); try { date = new
2641 * org.exolab.castor.types.Date(entries[i].getDate()); } catch (Exception ex)
2642 * { ex.printStackTrace();
2644 * date = new org.exolab.castor.types.Date(entries[i].getDate()); }
2645 * provEntry.setDate(date); provEntry.setUser(entries[i].getUser());
2646 * provEntry.setAction(entries[i].getAction()); prov.addEntry(provEntry); } }
2647 * else { provEntry = new Entry(); provEntry.setDate(date);
2648 * provEntry.setUser(System.getProperty("user.name")); // TODO: ext string
2649 * provEntry.setApp("JVAPP"); // TODO: ext string provEntry.setAction(action);
2650 * prov.addEntry(provEntry); }
2654 jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
2656 // TODO: fix App and Action entries and check use of provenance in jalview.
2657 jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
2658 for (int i = 0; i < prov.getEntryCount(); i++)
2660 jprov.addEntry(prov.getEntry(i).getUser(),
2661 prov.getEntry(i).getAction(), prov.getEntry(i).getDate(),
2662 prov.getEntry(i).getId());
2670 * @return default initial provenance list for a Jalview created vamsas
2673 Provenance dummyProvenance()
2675 return dummyProvenance(null);
2678 Entry dummyPEntry(String action)
2680 Entry entry = new Entry();
2681 entry.setApp(this.provEntry.getApp());
2684 entry.setAction(action);
2688 entry.setAction("created.");
2690 entry.setDate(new java.util.Date());
2691 entry.setUser(this.provEntry.getUser());
2695 Provenance dummyProvenance(String action)
2697 Provenance prov = new Provenance();
2698 prov.addEntry(dummyPEntry(action));
2702 Entry addProvenance(Provenance p, String action)
2704 Entry dentry = dummyPEntry(action);
2709 public Entry getProvEntry()
2714 public IClientDocument getClientDocument()
2719 public IdentityHashMap getJvObjectBinding()
2724 public Hashtable getVamsasObjectBinding()
2729 public void storeSequenceMappings(AlignmentViewport viewport,
2730 String title) throws Exception
2732 AlignmentViewport av = viewport;
2735 jalview.datamodel.AlignmentI jal = av.getAlignment();
2736 // /////////////////////////////////////////
2738 DataSet dataset = null;
2739 if (jal.getDataset() == null)
2741 Cache.log.warn("Creating new dataset for an alignment.");
2742 jal.setDataset(null);
2744 dataset = (DataSet) ((Alignment) getjv2vObj(
2745 viewport.getSequenceSetId())).getV_parent(); // jal.getDataset());
2746 if (dataset == null)
2748 dataset = (DataSet) getjv2vObj(jal.getDataset());
2750 "Can't find the correct dataset for the alignment in this view. Creating new one.");
2753 // Store any sequence mappings.
2754 List<AlignedCodonFrame> cframes = av.getAlignment().getCodonFrames();
2755 if (cframes != null)
2757 for (AlignedCodonFrame acf : cframes)
2759 if (acf.getdnaSeqs() != null && acf.getdnaSeqs().length > 0)
2761 jalview.datamodel.SequenceI[] dmps = acf.getdnaSeqs();
2762 jalview.datamodel.Mapping[] mps = acf.getProtMappings();
2763 for (int smp = 0; smp < mps.length; smp++)
2765 uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(
2769 new jalview.io.vamsas.Sequencemapping(this, mps[smp], mfrom,
2775 "NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
2776 + dmps[smp].getDisplayId(true) + " to "
2777 + mps[smp].getTo().getName());
2783 } catch (Exception e)
2785 throw new Exception(MessageManager.formatMessage(
2786 "exception.couldnt_store_sequence_mappings", new String[]
2791 public void clearSkipList()
2793 if (skipList != null)
2800 * @return the skipList
2802 public Hashtable getSkipList()
2809 * the skipList to set
2811 public void setSkipList(Hashtable skipList)
2813 this.skipList = skipList;
2817 * registry for datastoreItems
2819 DatastoreRegistry dsReg = new DatastoreRegistry();
2821 public DatastoreRegistry getDatastoreRegisty()
2825 dsReg = new DatastoreRegistry();