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.util.jarInputStreamProvider;
39 import jalview.viewmodel.AlignmentViewport;
42 import java.io.IOException;
43 import java.util.Enumeration;
44 import java.util.HashMap;
45 import java.util.Hashtable;
46 import java.util.IdentityHashMap;
47 import java.util.Iterator;
48 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 "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())
206 "Returning null VorbaID binding for jalview object " + jvobj);
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 "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"
245 + " object " + vobj);
249 if (vobj2jv.containsKey(vobj.getVorbaId())
250 && !((VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
253 "Warning? Overwriting existing vamsas id binding for "
255 new Exception(MessageManager.getString(
256 "exception.overwriting_vamsas_id_binding")));
258 else if (jv2vobj.containsKey(jvobj)
259 && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
262 "Warning? Overwriting existing jalview object binding for "
264 new Exception("Overwriting jalview object binding."));
267 * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
268 * +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+"
269 * already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to
272 // we just update the hash's regardless!
273 Cache.log.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
274 vobj2jv.put(vobj.getVorbaId(), jvobj);
275 // JBPNote - better implementing a hybrid invertible hash.
276 jv2vobj.put(jvobj, vobj.getVorbaId());
280 * put the alignment viewed by AlignViewport into cdoc.
283 * alignViewport to be stored
285 * title for alignment
286 * @return true if alignment associated with viewport was stored/synchronized
289 public boolean storeVAMSAS(AlignViewport av, String aFtitle)
293 jalview.datamodel.AlignmentI jal = av.getAlignment();
294 jalview.datamodel.AlignmentI jds = jal.getDataset();
296 VAMSAS root = null; // will be resolved based on Dataset Parent.
297 // /////////////////////////////////////////
299 DataSet dataset = null;
302 Cache.log.warn("Creating new dataset for an alignment.");
303 jal.setDataset(null);
304 jds = jal.getDataset();
307 // try and get alignment and association for sequence set id
309 Alignment alignment = (Alignment) getjv2vObj(av.getSequenceSetId());
310 if (alignment != null)
312 dataset = (DataSet) alignment.getV_parent();
316 // is the dataset already registered
317 dataset = (DataSet) getjv2vObj(jds);
322 // it might be that one of the dataset sequences does actually have a
323 // binding, so search for it indirectly. If it does, then the local
325 // must be merged with the existing vamsas dataset.
326 jalview.datamodel.SequenceI[] jdatset = jds.getSequencesArray();
327 for (int i = 0; i < jdatset.length; i++)
329 Vobject vbound = getjv2vObj(jdatset[i]);
332 if (vbound instanceof uk.ac.vamsas.objects.core.Sequence)
336 dataset = (DataSet) vbound.getV_parent();
340 if (vbound.getV_parent() != null
341 && dataset != vbound.getV_parent())
343 throw new Error(MessageManager.getString(
344 "error.implementation_error_cannot_map_alignment_sequences"));
345 // This occurs because the dataset for the alignment we are
356 Cache.log.warn("Creating new vamsas dataset for alignment view "
357 + av.getSequenceSetId());
358 // we create a new dataset on the default vamsas root.
359 root = cdoc.getVamsasRoots()[0]; // default vamsas root for modifying.
360 dataset = new DataSet();
361 root.addDataSet(dataset);
362 bindjvvobj(jds, dataset);
363 dataset.setProvenance(dummyProvenance());
364 // dataset.getProvenance().addEntry(provEntry);
369 root = (VAMSAS) dataset.getV_parent();
373 // set new dataset and alignment sequences based on alignment Nucleotide
375 // this *will* break when alignment contains both nucleotide and amino
377 String dict = jal.isNucleotide()
378 ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
379 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA;
380 Vector dssmods = new Vector();
381 for (int i = 0; i < jal.getHeight(); i++)
383 SequenceI sq = jal.getSequenceAt(i).getDatasetSequence(); // only insert
387 Datasetsequence dssync = new jalview.io.vamsas.Datasetsequence(this,
389 sequence = (Sequence) dssync.getVobj();
390 if (dssync.getModified())
392 dssmods.addElement(sequence);
396 if (dssmods.size() > 0)
400 Entry pentry = this.addProvenance(dataset.getProvenance(),
401 "updated sequences");
402 // pentry.addInput(vInput); could write in which sequences were
404 dssmods.removeAllElements();
407 // dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));
408 // ////////////////////////////////////////////
409 if (alignmentWillBeSkipped(av))
411 // TODO: trees could be written - but for the moment we just
413 // add to the JalviewXML skipList and ..
417 if (alignment == null)
419 alignment = new Alignment();
420 bindjvvobj(av.getSequenceSetId(), alignment);
421 if (alignment.getProvenance() == null)
423 alignment.setProvenance(new Provenance());
425 addProvenance(alignment.getProvenance(), "added"); // TODO: insert some
428 dataset.addAlignment(alignment);
430 Property title = new Property();
431 title.setName("title");
432 title.setType("string");
433 title.setContent(aFtitle);
434 alignment.addProperty(title);
436 alignment.setGapChar(String.valueOf(av.getGapCharacter()));
437 for (int i = 0; i < jal.getHeight(); i++)
439 syncToAlignmentSequence(jal.getSequenceAt(i), alignment, null);
441 alignRDHash.put(av.getSequenceSetId(), av.getUndoRedoHash());
445 // always prepare to clone the alignment
446 boolean alismod = av.isUndoRedoHashModified(
447 (long[]) alignRDHash.get(av.getSequenceSetId()));
448 // todo: verify and update mutable alignment props.
449 // TODO: Use isLocked methods
450 if (alignment.getModifiable() == null
451 || alignment.getModifiable().length() == 0)
452 // && !alignment.isDependedOn())
454 boolean modified = false;
455 // check existing sequences in local and in document.
456 Vector docseqs = new Vector(
457 alignment.getAlignmentSequenceAsReference());
458 for (int i = 0; i < jal.getHeight(); i++)
460 modified |= syncToAlignmentSequence(jal.getSequenceAt(i),
463 if (docseqs.size() > 0)
465 // removeValignmentSequences(alignment, docseqs);
466 docseqs.removeAllElements();
468 "Sequence deletion from alignment is not implemented.");
476 addProvenance(alignment.getProvenance(), "Edited"); // TODO:
485 addProvenance(alignment.getProvenance(), "Attributes Edited"); // TODO:
495 System.out.println("update alignment in document.");
499 System.out.println("alignment in document left unchanged.");
504 // unbind alignment from view.
505 // create new binding and new alignment.
506 // mark trail on new alignment as being derived from old ?
508 "update edited alignment to new alignment in document.");
511 // ////////////////////////////////////////////
512 // SAVE Alignment Sequence Features
513 for (int i = 0, iSize = alignment
514 .getAlignmentSequenceCount(); i < iSize; i++)
516 AlignmentSequence valseq;
517 SequenceI alseq = (SequenceI) getvObj2jv(
518 valseq = alignment.getAlignmentSequence(i));
519 if (alseq != null && alseq.getSequenceFeatures() != null)
522 * We do not put local Alignment Sequence Features into the vamsas
526 * jalview.datamodel.SequenceFeature[] features = alseq
527 * .getSequenceFeatures(); for (int f = 0; f < features.length; f++) {
528 * if (features[f] != null) { AlignmentSequenceAnnotation valseqf = (
529 * AlignmentSequenceAnnotation) getjv2vObj(features[i]); if (valseqf
532 * valseqf = (AlignmentSequenceAnnotation) getDSAnnotationFromJalview(
533 * new AlignmentSequenceAnnotation(), features[i]);
534 * valseqf.setGraph(false);
535 * valseqf.addProperty(newProperty("jalview:feature"
536 * ,"boolean","true")); if (valseqf.getProvenance() == null) {
537 * valseqf.setProvenance(new Provenance()); }
538 * addProvenance(valseqf.getProvenance(), "created"); // JBPNote - //
539 * need to // update bindjvvobj(features[i], valseqf);
540 * valseq.addAlignmentSequenceAnnotation(valseqf); } } }
545 // ////////////////////////////////////////////
547 if (jal.getAlignmentAnnotation() != null)
549 jalview.datamodel.AlignmentAnnotation[] aa = jal
550 .getAlignmentAnnotation();
551 java.util.HashMap AlSeqMaps = new HashMap(); // stores int maps from
552 // alignment columns to
553 // sequence positions.
554 for (int i = 0; i < aa.length; i++)
556 if (aa[i] == null || isJalviewOnly(aa[i]))
560 if (aa[i].groupRef != null)
562 // TODO: store any group associated annotation references
564 "Group associated sequence annotation is not stored in VAMSAS document.");
567 if (aa[i].sequenceRef != null)
569 // Deal with sequence associated annotation
570 Vobject sref = getjv2vObj(aa[i].sequenceRef);
571 if (sref instanceof uk.ac.vamsas.objects.core.AlignmentSequence)
573 saveAlignmentSequenceAnnotation(AlSeqMaps,
574 (AlignmentSequence) sref, aa[i]);
578 // first find the alignment sequence to associate this with.
579 for (SequenceI jvalsq : av.getAlignment().getSequences())
581 // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence)
583 if (jvalsq.getDatasetSequence() == aa[i].sequenceRef)
585 Vobject alsref = getjv2vObj(jvalsq);
586 saveAlignmentSequenceAnnotation(AlSeqMaps,
587 (AlignmentSequence) alsref, aa[i]);
596 // add Alignment Annotation
597 uk.ac.vamsas.objects.core.AlignmentAnnotation an = (uk.ac.vamsas.objects.core.AlignmentAnnotation) getjv2vObj(
601 an = new uk.ac.vamsas.objects.core.AlignmentAnnotation();
602 an.setType(JALVIEW_ANNOTATION_ROW);
603 an.setDescription(aa[i].description);
604 alignment.addAlignmentAnnotation(an);
605 Seg vSeg = new Seg(); // TODO: refactor to have a default
606 // rangeAnnotationType initer/updater that
607 // takes a set of int ranges.
609 vSeg.setInclusive(true);
610 vSeg.setEnd(jal.getWidth());
614 an.setGraph(true); // aa[i].graph);
616 an.setLabel(aa[i].label);
617 an.setProvenance(dummyProvenance());
618 if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
620 an.setGroup(Integer.toString(aa[i].graphGroup)); // // JBPNote
635 AnnotationElement ae;
637 for (int a = 0; a < aa[i].annotations.length; a++)
639 if ((aa[i] == null) || (aa[i].annotations[a] == null))
644 ae = new AnnotationElement();
645 ae.setDescription(aa[i].annotations[a].description);
646 ae.addGlyph(new Glyph());
648 .setContent(aa[i].annotations[a].displayCharacter); // assume
657 ae.addValue(aa[i].annotations[a].value);
659 ae.setPosition(a + 1);
660 if (aa[i].annotations[a].secondaryStructure != ' ')
662 Glyph ss = new Glyph();
664 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
665 ss.setContent(String.valueOf(
666 aa[i].annotations[a].secondaryStructure));
669 an.addAnnotationElement(ae);
673 // an.addProperty(newProperty("jalview:editable", null,
675 // an.setModifiable(""); // TODO: This is not the way the
676 // modifiable flag is supposed to be used.
678 setAnnotationType(an, aa[i]);
680 if (aa[i].graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
683 an.setGroup(Integer.toString(aa[i].graphGroup));
684 if (aa[i].threshold != null && aa[i].threshold.displayed)
686 an.addProperty(Properties.newProperty(THRESHOLD,
687 Properties.FLOATTYPE,
688 "" + aa[i].threshold.value));
689 if (aa[i].threshold.label != null)
691 an.addProperty(Properties.newProperty(
692 THRESHOLD + "Name", Properties.STRINGTYPE,
693 "" + aa[i].threshold.label));
702 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT
705 // verify annotation - update (perhaps)
707 "update alignment sequence annotation. not yet implemented.");
711 // verify annotation - update (perhaps)
713 "updated alignment sequence annotation added.");
719 // /////////////////////////////////////////////////////
721 // //////////////////////////////////////////////
723 // /////////////////////////////////
724 // FIND ANY ASSOCIATED TREES
725 if (Desktop.getDesktopPane() != null)
727 javax.swing.JInternalFrame[] frames = Desktop.getInstance()
730 for (int t = 0; t < frames.length; t++)
732 if (frames[t] instanceof TreePanel)
734 TreePanel tp = (TreePanel) frames[t];
736 if (tp.getViewPort().getSequenceSetId()
737 .equals(av.getSequenceSetId()))
739 DatastoreItem vtree = new jalview.io.vamsas.Tree(this, tp,
745 // Store Jalview specific stuff in the Jalview appData
746 // not implemented in the SimpleDoc interface.
751 ex.printStackTrace();
758 * very quick test to see if the viewport would be stored in the vamsas
759 * document. Reasons for not storing include the unaligned flag being false
760 * (for all sequences, including the hidden ones!)
763 * @return true if alignment associated with this view will be stored in
766 public boolean alignmentWillBeSkipped(AlignmentViewport av)
768 return (!av.getAlignment().isAligned());
771 private void addToSkipList(AlignmentViewport av)
773 if (skipList == null)
775 skipList = new Hashtable();
777 skipList.put(av.getSequenceSetId(), av);
781 * remove docseqs from the given alignment marking provenance appropriately
782 * and removing any references to the sequences.
787 private void removeValignmentSequences(Alignment alignment,
790 // delete these from document. This really needs to be a generic document
791 // API function derived by CASTOR.
792 Enumeration en = docseqs.elements();
793 while (en.hasMoreElements())
795 alignment.removeAlignmentSequence(
796 (AlignmentSequence) en.nextElement());
798 Entry pe = addProvenance(alignment.getProvenance(),
799 "Removed " + docseqs.size() + " sequences");
800 en = alignment.enumerateAlignmentAnnotation();
801 Vector toremove = new Vector();
802 while (en.hasMoreElements())
804 uk.ac.vamsas.objects.core.AlignmentAnnotation alan = (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
806 if (alan.getSeqrefsCount() > 0)
809 Vector storem = new Vector();
810 Enumeration sr = alan.enumerateSeqrefs();
811 while (sr.hasMoreElements())
813 Object alsr = sr.nextElement();
814 if (docseqs.contains(alsr))
816 storem.addElement(alsr);
819 // remove references to the deleted sequences
820 sr = storem.elements();
821 while (sr.hasMoreElements())
823 alan.removeSeqrefs(sr.nextElement());
826 if (alan.getSeqrefsCount() == 0)
828 // should then delete alan from dataset
829 toremove.addElement(alan);
833 // remove any annotation that used to be associated to a specific bunch of
835 en = toremove.elements();
836 while (en.hasMoreElements())
838 alignment.removeAlignmentAnnotation(
839 (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
842 // TODO: search through alignment annotations to remove any references to
843 // this alignment sequence
847 * sync a jalview alignment seuqence into a vamsas alignment assumes all lock
848 * transformation/bindings have been sorted out before hand. creates/syncs the
849 * vamsas alignment sequence for jvalsq and adds it to the alignment if
850 * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
851 * and these are removed after being processed w.r.t a bound jvalsq
854 private boolean syncToAlignmentSequence(SequenceI jvalsq,
855 Alignment alignment, Vector unbounddocseq)
857 boolean modal = false;
858 // todo: islocked method here
859 boolean up2doc = false;
860 AlignmentSequence alseq = (AlignmentSequence) getjv2vObj(jvalsq);
863 alseq = new AlignmentSequence();
868 if (unbounddocseq != null)
870 unbounddocseq.removeElement(alseq);
873 // boolean locked = (alignment.getModifiable()==null ||
874 // alignment.getModifiable().length()>0);
875 // TODO: VAMSAS: translate lowercase symbols to annotation ?
876 if (up2doc || !alseq.getSequence().equals(jvalsq.getSequenceAsString()))
878 alseq.setSequence(jvalsq.getSequenceAsString());
879 alseq.setStart(jvalsq.getStart());
880 alseq.setEnd(jvalsq.getEnd());
883 if (up2doc || !alseq.getName().equals(jvalsq.getName()))
886 alseq.setName(jvalsq.getName());
888 if (jvalsq.getDescription() != null && (alseq.getDescription() == null
889 || !jvalsq.getDescription().equals(alseq.getDescription())))
892 alseq.setDescription(jvalsq.getDescription());
894 if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
897 "Serious Implementation error - Unbound dataset sequence in alignment: "
898 + jvalsq.getDatasetSequence());
900 alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
904 alignment.addAlignmentSequence(alseq);
905 bindjvvobj(jvalsq, alseq);
907 return up2doc || modal;
911 * locally sync a jalview alignment seuqence from a vamsas alignment assumes
912 * all lock transformation/bindings have been sorted out before hand.
913 * creates/syncs the jvalsq from the alignment sequence
915 private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
916 char valGapchar, char gapChar, List<SequenceI> dsseqs)
919 boolean modal = false;
920 // todo: islocked method here
921 boolean upFromdoc = false;
922 jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
930 // boolean locked = (alignment.getModifiable()==null ||
931 // alignment.getModifiable().length()>0);
932 // TODO: VAMSAS: translate lowercase symbols to annotation ?
934 || !valseq.getSequence().equals(alseq.getSequenceAsString()))
936 // this might go *horribly* wrong
937 alseq.setSequence(new String(valseq.getSequence())
938 .replace(valGapchar, gapChar));
939 alseq.setStart((int) valseq.getStart());
940 alseq.setEnd((int) valseq.getEnd());
943 if (!valseq.getName().equals(alseq.getName()))
946 alseq.setName(valseq.getName());
948 if (alseq.getDescription() == null || (valseq.getDescription() != null
949 && !alseq.getDescription().equals(valseq.getDescription())))
951 alseq.setDescription(valseq.getDescription());
954 if (modal && Cache.log.isDebugEnabled())
957 "Updating apparently edited sequence " + alseq.getName());
962 alseq = new jalview.datamodel.Sequence(valseq.getName(),
963 valseq.getSequence().replace(valGapchar, gapChar),
964 (int) valseq.getStart(), (int) valseq.getEnd());
966 Vobject datsetseq = (Vobject) valseq.getRefid();
967 if (datsetseq != null)
969 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
970 if (valseq.getDescription() != null)
972 alseq.setDescription(valseq.getDescription());
976 // inherit description line from dataset.
977 if (alseq.getDatasetSequence().getDescription() != null)
979 alseq.setDescription(
980 alseq.getDatasetSequence().getDescription());
994 "Invalid dataset sequence id (null) for alignment sequence "
995 + valseq.getVorbaId());
997 bindjvvobj(alseq, valseq);
998 alseq.setVamsasId(valseq.getVorbaId().getId());
1001 Vobject datsetseq = (Vobject) valseq.getRefid();
1002 if (datsetseq != null)
1004 if (datsetseq != alseq.getDatasetSequence())
1008 alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
1010 return upFromdoc || modal;
1013 private void initRangeAnnotationType(RangeAnnotation an,
1014 AlignmentAnnotation alan, int[] gapMap)
1016 Seg vSeg = new Seg();
1018 vSeg.setInclusive(true);
1019 vSeg.setEnd(gapMap.length);
1022 // LATER: much of this is verbatim from the alignmentAnnotation
1023 // method below. suggests refactoring to make rangeAnnotation the
1025 an.setDescription(alan.description);
1026 an.setLabel(alan.label);
1027 an.setGroup(Integer.toString(alan.graphGroup));
1036 AnnotationElement ae;
1037 for (int a = 0; a < alan.annotations.length; a++)
1039 if (alan.annotations[a] == null)
1044 ae = new AnnotationElement();
1045 ae.setDescription(alan.annotations[a].description);
1046 ae.addGlyph(new Glyph());
1047 ae.getGlyph(0).setContent(alan.annotations[a].displayCharacter); // assume
1054 if (alan.graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
1056 ae.addValue(alan.annotations[a].value);
1058 ae.setPosition(gapMap[a] + 1); // position w.r.t. AlignmentSequence
1060 if (alan.annotations[a].secondaryStructure != ' ')
1062 // we only write an annotation where it really exists.
1063 Glyph ss = new Glyph();
1065 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
1067 String.valueOf(alan.annotations[a].secondaryStructure));
1070 an.addAnnotationElement(ae);
1075 private void saveDatasetSequenceAnnotation(HashMap AlSeqMaps,
1076 uk.ac.vamsas.objects.core.Sequence sref, AlignmentAnnotation alan)
1080 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1081 // objects.core.AlignmentSequence) sref;
1082 uk.ac.vamsas.objects.core.DataSetAnnotations an = (uk.ac.vamsas.objects.core.DataSetAnnotations) getjv2vObj(
1084 int[] gapMap = getGapMap(AlSeqMaps, alan);
1087 an = new uk.ac.vamsas.objects.core.DataSetAnnotations();
1088 initRangeAnnotationType(an, alan, gapMap);
1090 an.setProvenance(dummyProvenance()); // get provenance as user
1091 // created, or jnet, or
1093 setAnnotationType(an, alan);
1094 an.setGroup(Integer.toString(alan.graphGroup)); // // JBPNote -
1102 if (alan.getThreshold() != null && alan.getThreshold().displayed)
1104 an.addProperty(Properties.newProperty(THRESHOLD,
1105 Properties.FLOATTYPE, "" + alan.getThreshold().value));
1106 if (alan.getThreshold().label != null)
1108 an.addProperty(Properties.newProperty(THRESHOLD + "Name",
1109 Properties.STRINGTYPE, "" + alan.getThreshold().label));
1112 ((DataSet) sref.getV_parent()).addDataSetAnnotations(an);
1113 bindjvvobj(alan, an);
1117 // update reference sequence Annotation
1118 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1121 // verify existing alignment sequence annotation is up to date
1122 System.out.println("update dataset sequence annotation.");
1126 // verify existing alignment sequence annotation is up to date
1128 "make new alignment dataset sequence annotation if modification has happened.");
1134 private int[] getGapMap(HashMap AlSeqMaps, AlignmentAnnotation alan)
1137 if (AlSeqMaps.containsKey(alan.sequenceRef))
1139 gapMap = (int[]) AlSeqMaps.get(alan.sequenceRef);
1143 gapMap = new int[alan.sequenceRef.getLength()];
1144 // map from alignment position to sequence position.
1145 int[] sgapMap = alan.sequenceRef.gapMap();
1146 for (int a = 0; a < sgapMap.length; a++)
1148 gapMap[sgapMap[a]] = a;
1154 private void saveAlignmentSequenceAnnotation(HashMap AlSeqMaps,
1155 AlignmentSequence alsref, AlignmentAnnotation alan)
1159 // objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
1160 // objects.core.AlignmentSequence) sref;
1161 uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation an = (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) getjv2vObj(
1163 int[] gapMap = getGapMap(AlSeqMaps, alan);
1166 an = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation();
1167 initRangeAnnotationType(an, alan, gapMap);
1169 * I mean here that we don't actually have a semantic 'type' for the
1170 * annotation (this might be - score, intrinsic property, measurement,
1171 * something extracted from another program, etc)
1173 an.setType(JALVIEW_ANNOTATION_ROW); // TODO: better fix
1174 // this rough guess ;)
1175 alsref.addAlignmentSequenceAnnotation(an);
1176 bindjvvobj(alan, an);
1177 // These properties are directly supported by the
1178 // AlignmentSequenceAnnotation type.
1179 setAnnotationType(an, alan);
1180 an.setProvenance(dummyProvenance()); // get provenance as user
1181 // created, or jnet, or
1186 // update reference sequence Annotation
1187 if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
1190 // verify existing alignment sequence annotation is up to date
1191 System.out.println("update alignment sequence annotation.");
1195 // verify existing alignment sequence annotation is up to date
1197 "make new alignment sequence annotation if modification has happened.");
1203 * set vamsas annotation object type from jalview annotation
1208 private void setAnnotationType(RangeAnnotation an,
1209 AlignmentAnnotation alan)
1211 if (an instanceof AlignmentSequenceAnnotation)
1213 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1215 ((AlignmentSequenceAnnotation) an).setGraph(true);
1219 ((AlignmentSequenceAnnotation) an).setGraph(false);
1222 if (an instanceof uk.ac.vamsas.objects.core.AlignmentAnnotation)
1224 if (alan.graph != AlignmentAnnotation.NO_GRAPH)
1226 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an).setGraph(true);
1230 ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an)
1236 case AlignmentAnnotation.BAR_GRAPH:
1237 an.addProperty(Properties.newProperty(DISCRETE_ANNOTATION,
1238 Properties.BOOLEANTYPE, "true"));
1240 case AlignmentAnnotation.LINE_GRAPH:
1241 an.addProperty(Properties.newProperty(CONTINUOUS_ANNOTATION,
1242 Properties.BOOLEANTYPE, "true"));
1245 // don't add any kind of discrete or continous property info.
1250 * get start<end range of segment, adjusting for inclusivity flag and
1254 * @param ensureDirection
1255 * when true - always ensure start is less than end.
1256 * @return int[] { start, end, direction} where direction==1 for range running
1257 * from end to start.
1259 private int[] getSegRange(Seg visSeg, boolean ensureDirection)
1261 boolean incl = visSeg.getInclusive();
1262 // adjust for inclusive flag.
1263 int pol = (visSeg.getStart() <= visSeg.getEnd()) ? 1 : -1; // polarity of
1265 int start = visSeg.getStart() + (incl ? 0 : pol);
1266 int end = visSeg.getEnd() + (incl ? 0 : -pol);
1267 if (ensureDirection && pol == -1)
1269 // jalview doesn't deal with inverted ranges, yet.
1274 return new int[] { start, end, pol < 0 ? 1 : 0 };
1280 * @return true if annotation is not to be stored in document
1282 private boolean isJalviewOnly(AlignmentAnnotation annotation)
1284 return annotation.autoCalculated || annotation.label.equals("Quality")
1285 || annotation.label.equals("Conservation")
1286 || annotation.label.equals("Consensus");
1289 boolean dojvsync = true;
1291 // boolean dojvsync = false; // disables Jalview AppData IO
1293 * list of alignment views created when updating Jalview from document.
1295 private final Vector newAlignmentViews = new Vector();
1298 * update local jalview view settings from the stored appdata (if any)
1300 public void updateJalviewFromAppdata()
1302 // recover any existing Jalview data from appdata
1303 // TODO: recover any PDB files stored as attachments in the vamsas session
1304 // and initialise the Jalview2XML.alreadyLoadedPDB hashtable with mappings
1307 final IClientAppdata cappdata = cdoc.getClientAppdata();
1308 if (cappdata != null)
1310 if (cappdata.hasClientAppdata())
1312 // TODO: how to check version of Jalview client app data and whether
1313 // it has been modified
1314 // client data is shared over all app clients
1317 // jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
1318 Jalview2XML fromxml = new Jalview2XML();
1319 fromxml.attemptversion1parse = false;
1320 fromxml.setUniqueSetSuffix("");
1321 fromxml.setObjectMappingTables(vobj2jv, jv2vobj); // mapKeysToString
1323 // mapValuesToString
1324 fromxml.setSkipList(skipList);
1325 jarInputStreamProvider jprovider = new jarInputStreamProvider()
1329 public String getFilename()
1332 // TODO Get the vamsas session ID here
1333 return "Jalview Vamsas Document Client Data";
1337 public JarInputStream getJarInputStream() throws IOException
1339 jalview.bin.Cache.log.debug(
1340 "Returning client input stream for Jalview from Vamsas Document.");
1341 return new JarInputStream(cappdata.getClientInputStream());
1345 public File getFile()
1352 fromxml.loadJalviewAlign(jprovider);
1354 } catch (Exception e)
1357 } catch (OutOfMemoryError e)
1366 if (cappdata.hasUserAppdata())
1368 // TODO: how to check version of Jalview user app data and whether it
1369 // has been modified
1370 // user data overrides data shared over all app clients ?
1373 Jalview2XML fromxml = new Jalview2XML();
1374 fromxml.attemptversion1parse = false;
1375 fromxml.setUniqueSetSuffix("");
1376 fromxml.setSkipList(skipList);
1377 fromxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1378 mapValuesToString(jv2vobj));
1379 jarInputStreamProvider jarstream = new jarInputStreamProvider()
1383 public String getFilename()
1386 // TODO Get the vamsas session ID here
1387 return "Jalview Vamsas Document User Data";
1391 public JarInputStream getJarInputStream() throws IOException
1393 jalview.bin.Cache.log.debug(
1394 "Returning user input stream for Jalview from Vamsas Document.");
1395 return new JarInputStream(cappdata.getUserInputStream());
1399 public File getFile()
1406 fromxml.loadJalviewAlign(jarstream);
1408 } catch (Exception e)
1411 } catch (OutOfMemoryError e)
1421 flushAlignViewports();
1425 * remove any spurious views generated by document synchronization
1427 private void flushAlignViewports()
1429 // remove any additional viewports originally recovered from the vamsas
1431 // search for all alignframes containing viewports generated from document
1433 // and if any contain more than one view, then remove the one generated by
1435 AlignmentViewport views[], av = null;
1436 AlignFrame af = null;
1437 Iterator newviews = newAlignmentViews.iterator();
1438 while (newviews.hasNext())
1440 av = (AlignmentViewport) newviews.next();
1441 af = Desktop.getAlignFrameFor(av);
1442 // TODO implement this : af.getNumberOfViews
1443 String seqsetidobj = av.getSequenceSetId();
1444 views = Desktop.getViewports(seqsetidobj);
1446 .debug("Found " + (views == null ? " no " : "" + views.length)
1447 + " views for '" + av.getSequenceSetId() + "'");
1448 if (views.length > 1)
1450 // we need to close the original document view.
1452 // work out how to do this by seeing if the views are gathered.
1453 // pretty clunky but the only way to do this without adding more flags
1454 // to the align frames.
1455 boolean gathered = false;
1456 String newviewid = null;
1457 List<AlignedCodonFrame> mappings = av.getAlignment()
1459 for (int i = 0; i < views.length; i++)
1463 AlignFrame viewframe = Desktop.getAlignFrameFor(views[i]);
1464 if (viewframe == af)
1468 newviewid = views[i].getSequenceSetId();
1472 // lose the reference to the vamsas document created view
1476 // close the view generated by the vamsas document synchronization
1483 af.closeMenuItem_actionPerformed(false);
1485 replaceJvObjMapping(seqsetidobj, newviewid);
1486 seqsetidobj = newviewid;
1487 // not sure if we need to do this:
1489 if (false) // mappings != null)
1491 // ensure sequence mappings from vamsas document view still
1493 if (mappings != null)
1495 jalview.structure.StructureSelectionManager
1496 .getStructureSelectionManager(Desktop.getInstance())
1497 .registerMappings(mappings);
1501 // ensure vamsas object binds to the stored views retrieved from
1503 // jalview.structure.StructureSelectionManager
1504 // .getStructureSelectionManager()
1505 // .addStructureViewerListener(viewframe.alignPanel);
1510 newAlignmentViews.clear();
1514 * replaces oldjvobject with newjvobject in the Jalview Object <> VorbaID
1517 * @param oldjvobject
1518 * @param newjvobject
1521 private void replaceJvObjMapping(Object oldjvobject, Object newjvobject)
1523 Object vobject = jv2vobj.remove(oldjvobject);
1524 if (vobject == null)
1526 // NOTE: this happens if user deletes object in one session then updates
1527 // from another client
1528 throw new Error(MessageManager.formatMessage(
1529 "error.implementation_error_old_jalview_object_not_bound",
1531 { oldjvobject.toString() }));
1533 if (newjvobject != null)
1535 jv2vobj.put(newjvobject, vobject);
1536 vobj2jv.put(vobject, newjvobject);
1541 * Update the jalview client and user appdata from the local jalview settings
1543 public void updateJalviewClientAppdata()
1545 final IClientAppdata cappdata = cdoc.getClientAppdata();
1546 if (cappdata != null)
1550 Jalview2XML jxml = new Jalview2XML();
1551 jxml.setObjectMappingTables(mapKeysToString(vobj2jv),
1552 mapValuesToString(jv2vobj));
1553 jxml.setSkipList(skipList);
1557 new JarOutputStream(cappdata.getClientOutputStream()));
1560 } catch (Exception e)
1562 // TODO raise GUI warning if user requests it.
1563 jalview.bin.Cache.log.error(
1564 "Couldn't update jalview client application data. Giving up - local settings probably lost.",
1570 jalview.bin.Cache.log.error(
1571 "Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
1576 * translate the Vobject keys to strings for use in Jalview2XML
1581 private IdentityHashMap mapValuesToString(IdentityHashMap jv2vobj2)
1583 IdentityHashMap mapped = new IdentityHashMap();
1584 Iterator keys = jv2vobj2.keySet().iterator();
1585 while (keys.hasNext())
1587 Object key = keys.next();
1588 mapped.put(key, jv2vobj2.get(key).toString());
1594 * translate the Vobject values to strings for use in Jalview2XML
1597 * @return hashtable with string values
1599 private Hashtable mapKeysToString(Hashtable vobj2jv2)
1601 Hashtable mapped = new Hashtable();
1602 Iterator keys = vobj2jv2.keySet().iterator();
1603 while (keys.hasNext())
1605 Object key = keys.next();
1606 mapped.put(key.toString(), vobj2jv2.get(key));
1612 * synchronize Jalview from the vamsas document
1614 * @return number of new views from document
1616 public int updateToJalview()
1618 VAMSAS _roots[] = cdoc.getVamsasRoots();
1620 for (int _root = 0; _root < _roots.length; _root++)
1622 VAMSAS root = _roots[_root];
1623 boolean newds = false;
1624 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
1626 // ///////////////////////////////////
1628 DataSet dataset = root.getDataSet(_ds);
1629 int i, iSize = dataset.getSequenceCount();
1630 List<SequenceI> dsseqs;
1631 jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(
1634 if (jdataset == null)
1636 Cache.log.debug("Initialising new jalview dataset fields");
1638 dsseqs = new Vector();
1642 Cache.log.debug("Update jalview dataset from vamsas.");
1643 jremain = jdataset.getHeight();
1644 dsseqs = jdataset.getSequences();
1647 // TODO: test sequence merging - we preserve existing non vamsas
1648 // sequences but add in any new vamsas ones, and don't yet update any
1649 // sequence attributes
1650 for (i = 0; i < iSize; i++)
1652 Sequence vdseq = dataset.getSequence(i);
1653 jalview.io.vamsas.Datasetsequence dssync = new Datasetsequence(
1656 jalview.datamodel.SequenceI dsseq = (SequenceI) dssync.getJvobj();
1657 if (dssync.isAddfromdoc())
1661 if (vdseq.getDbRefCount() > 0)
1663 DbRef[] dbref = vdseq.getDbRef();
1664 for (int db = 0; db < dbref.length; db++)
1666 new jalview.io.vamsas.Dbref(this, dbref[db], vdseq, dsseq);
1669 dsseq.updatePDBIds();
1675 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1676 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1678 seqs[i] = dsseqs.get(i);
1679 dsseqs.set(i, null);
1681 jdataset = new jalview.datamodel.Alignment(seqs);
1682 Cache.log.debug("New vamsas dataset imported into jalview.");
1683 bindjvvobj(jdataset, dataset);
1686 // add any new dataset sequence feature annotations
1687 if (dataset.getDataSetAnnotations() != null)
1689 for (int dsa = 0; dsa < dataset
1690 .getDataSetAnnotationsCount(); dsa++)
1692 DataSetAnnotations dseta = dataset.getDataSetAnnotations(dsa);
1693 // TODO: deal with group annotation on datset sequences.
1694 if (dseta.getSeqRefCount() == 1)
1696 SequenceI dsSeq = (SequenceI) getvObj2jv(
1697 (Vobject) dseta.getSeqRef(0)); // TODO: deal with group
1702 jalview.bin.Cache.log.warn(
1703 "Couldn't resolve jalview sequenceI for dataset object reference "
1704 + ((Vobject) dataset
1705 .getDataSetAnnotations(dsa)
1706 .getSeqRef(0)).getVorbaId()
1711 if (dseta.getAnnotationElementCount() == 0)
1713 new jalview.io.vamsas.Sequencefeature(this, dseta, dsSeq);
1718 // TODO: deal with alignmentAnnotation style annotation
1719 // appearing on dataset sequences.
1720 // JBPNote: we could just add them to all alignments but
1721 // that may complicate cross references in the jalview
1724 "Ignoring dataset annotation with annotationElements. Not yet supported in jalview.");
1731 "Ignoring multiply referenced dataset sequence annotation for binding to datsaet sequence features.");
1735 if (dataset.getAlignmentCount() > 0)
1737 // LOAD ALIGNMENTS from DATASET
1739 for (int al = 0, nal = dataset
1740 .getAlignmentCount(); al < nal; al++)
1742 uk.ac.vamsas.objects.core.Alignment alignment = dataset
1744 // TODO check this handles multiple views properly
1745 AlignmentViewport av = findViewport(alignment);
1747 jalview.datamodel.AlignmentI jal = null;
1750 // TODO check that correct alignment object is retrieved when
1751 // hidden seqs exist.
1752 jal = (av.hasHiddenRows()) ? av.getAlignment()
1753 .getHiddenSequences().getFullAlignment()
1754 : av.getAlignment();
1756 iSize = alignment.getAlignmentSequenceCount();
1757 boolean refreshal = false;
1758 Vector newasAnnots = new Vector();
1759 char gapChar = ' '; // default for new alignments read in from the
1763 dsseqs = jal.getSequences(); // for merge/update
1764 gapChar = jal.getGapCharacter();
1768 dsseqs = new Vector();
1770 char valGapchar = alignment.getGapChar().charAt(0);
1771 for (i = 0; i < iSize; i++)
1773 AlignmentSequence valseq = alignment.getAlignmentSequence(i);
1774 jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(
1776 if (syncFromAlignmentSequence(valseq, valGapchar, gapChar,
1777 dsseqs) && alseq != null)
1780 // updated to sequence from the document
1784 if (valseq.getAlignmentSequenceAnnotationCount() > 0)
1786 AlignmentSequenceAnnotation[] vasannot = valseq
1787 .getAlignmentSequenceAnnotation();
1788 for (int a = 0; a < vasannot.length; a++)
1790 jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
1791 vasannot[a]); // TODO:
1799 int se[] = getBounds(vasannot[a]);
1800 asa = getjAlignmentAnnotation(jal, vasannot[a]);
1801 asa.setSequenceRef(alseq);
1802 asa.createSequenceMapping(alseq, se[0], false); // TODO:
1813 alseq.addAlignmentAnnotation(asa);
1814 bindjvvobj(asa, vasannot[a]);
1816 newasAnnots.add(asa);
1820 // update existing annotation - can do this in place
1821 if (vasannot[a].getModifiable() == null) // TODO: USE
1827 "UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
1828 // TODO: should at least replace with new one - otherwise
1829 // things will break
1830 // basically do this:
1831 // int se[] = getBounds(vasannot[a]);
1832 // asa.update(getjAlignmentAnnotation(jal, vasannot[a]));
1833 // // update from another annotation object in place.
1834 // asa.createSequenceMapping(alseq, se[0], false);
1843 SequenceI[] seqs = new SequenceI[dsseqs.size()];
1844 for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
1846 seqs[i] = dsseqs.get(i);
1847 dsseqs.set(i, null);
1849 jal = new jalview.datamodel.Alignment(seqs);
1850 Cache.log.debug("New vamsas alignment imported into jalview "
1851 + alignment.getVorbaId().getId());
1852 jal.setDataset(jdataset);
1854 if (newasAnnots != null && newasAnnots.size() > 0)
1856 // Add the new sequence annotations in to the alignment.
1857 for (int an = 0, anSize = newasAnnots
1858 .size(); an < anSize; an++)
1861 (AlignmentAnnotation) newasAnnots.elementAt(an));
1862 // TODO: check if anything has to be done - like calling
1863 // adjustForAlignment or something.
1864 newasAnnots.setElementAt(null, an);
1868 // //////////////////////////////////////////
1869 // //LOAD ANNOTATIONS FOR THE ALIGNMENT
1870 // ////////////////////////////////////
1871 if (alignment.getAlignmentAnnotationCount() > 0)
1873 uk.ac.vamsas.objects.core.AlignmentAnnotation[] an = alignment
1874 .getAlignmentAnnotation();
1876 for (int j = 0; j < an.length; j++)
1878 jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
1882 // update or stay the same.
1883 // TODO: should at least replace with a new one - otherwise
1884 // things will break
1885 // basically do this:
1886 // jan.update(getjAlignmentAnnotation(jal, an[a])); // update
1887 // from another annotation object in place.
1890 "update from vamsas alignment annotation to existing jalview alignment annotation.");
1891 if (an[j].getModifiable() == null) // TODO: USE VAMSAS
1892 // LIBRARY OBJECT LOCK
1895 // TODO: user defined annotation is totally mutable... - so
1896 // load it up or throw away if locally edited.
1898 "NOT IMPLEMENTED - Recovering user-modifiable annotation - yet...");
1900 // TODO: compare annotation element rows
1901 // TODO: compare props.
1905 jan = getjAlignmentAnnotation(jal, an[j]);
1906 // TODO: ensure we add the alignment annotation before the
1907 // automatic annotation rows
1908 jal.addAnnotation(jan);
1909 bindjvvobj(jan, an[j]);
1914 AlignFrame alignFrame;
1917 Cache.log.debug("New alignframe for alignment "
1918 + alignment.getVorbaId());
1919 // ///////////////////////////////
1920 // construct alignment view
1921 alignFrame = new AlignFrame(jal, AlignFrame.DEFAULT_WIDTH,
1922 AlignFrame.DEFAULT_HEIGHT,
1923 alignment.getVorbaId().toString());
1924 av = alignFrame.getViewport();
1925 newAlignmentViews.addElement(av);
1926 String title = alignment.getProvenance()
1928 alignment.getProvenance().getEntryCount() - 1)
1930 if (alignment.getPropertyCount() > 0)
1932 for (int p = 0, pe = alignment
1933 .getPropertyCount(); p < pe; p++)
1935 if (alignment.getProperty(p).getName().equals("title"))
1937 title = alignment.getProperty(p).getContent();
1941 // TODO: automatically create meaningful title for a vamsas
1942 // alignment using its provenance.
1943 if (Cache.log.isDebugEnabled())
1945 title = title + "(" + alignment.getVorbaId() + ")";
1948 jalview.gui.Desktop.addInternalFrame(alignFrame, title,
1949 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1950 bindjvvobj(av.getSequenceSetId(), alignment);
1954 // find the alignFrame for jal.
1955 // TODO: fix this so we retrieve the alignFrame handing av
1956 // *directly* (JBPNote - don't understand this now)
1957 // TODO: make sure all associated views are refreshed
1958 alignFrame = Desktop.getAlignFrameFor(av);
1961 av.alignmentChanged(alignFrame.alignPanel);
1962 alignFrame.alignPanel.adjustAnnotationHeight();
1966 // /////////////////////////////////////
1967 if (alignment.getTreeCount() > 0)
1970 for (int t = 0; t < alignment.getTreeCount(); t++)
1972 jalview.io.vamsas.Tree vstree = new jalview.io.vamsas.Tree(
1973 this, alignFrame, alignment.getTree(t));
1974 TreePanel tp = null;
1975 if (vstree.isValidTree())
1977 tp = alignFrame.showNewickTree(vstree.getNewickTree(),
1978 vstree.getTitle(), vstree.getInputData(), 600,
1979 500, t * 20 + 50, t * 20 + 50);
1984 bindjvvobj(tp, alignment.getTree(t));
1987 vstree.UpdateSequenceTreeMap(tp);
1988 } catch (RuntimeException e)
1990 Cache.log.warn("update of labels failed.", e);
1995 Cache.log.warn("Cannot create tree for tree " + t
1997 + alignment.getTree(t).getVorbaId());
2005 // we do sequenceMappings last because they span all datasets in a vamsas
2007 for (int _ds = 0, _nds = root.getDataSetCount(); _ds < _nds; _ds++)
2009 DataSet dataset = root.getDataSet(_ds);
2010 if (dataset.getSequenceMappingCount() > 0)
2012 for (int sm = 0, smCount = dataset
2013 .getSequenceMappingCount(); sm < smCount; sm++)
2015 Rangetype seqmap = new jalview.io.vamsas.Sequencemapping(this,
2016 dataset.getSequenceMapping(sm));
2021 return newAlignmentViews.size();
2024 public AlignmentViewport findViewport(Alignment alignment)
2026 AlignmentViewport av = null;
2027 AlignmentViewport[] avs = Desktop
2028 .getViewports((String) getvObj2jv(alignment));
2036 // bitfields - should be a template in j1.5
2037 private static int HASSECSTR = 0;
2039 private static int HASVALS = 1;
2041 private static int HASHPHOB = 2;
2043 private static int HASDC = 3;
2045 private static int HASDESCSTR = 4;
2047 private static int HASTWOSTATE = 5; // not used yet.
2050 * parses the AnnotationElements - if they exist - into
2051 * jalview.datamodel.Annotation[] rows Two annotation rows are made if there
2052 * are distinct annotation for both at 'pos' and 'after pos' at any particular
2056 * @return { boolean[static int constants ], int[ae.length] - map to annotated
2057 * object frame, jalview.datamodel.Annotation[],
2058 * jalview.datamodel.Annotation[] (after)}
2060 private Object[] parseRangeAnnotation(
2061 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2063 // set these attributes by looking in the annotation to decide what kind of
2064 // alignment annotation rows will be made
2065 // TODO: potentially we might make several annotation rows from one vamsas
2066 // alignment annotation. the jv2Vobj binding mechanism
2067 // may not quite cope with this (without binding an array of annotations to
2068 // a vamsas alignment annotation)
2069 // summary flags saying what we found over the set of annotation rows.
2070 boolean[] AeContent = new boolean[] { false, false, false, false,
2072 int[] rangeMap = getMapping(annotation);
2073 jalview.datamodel.Annotation[][] anot = new jalview.datamodel.Annotation[][] {
2074 new jalview.datamodel.Annotation[rangeMap.length],
2075 new jalview.datamodel.Annotation[rangeMap.length] };
2076 boolean mergeable = true; // false if 'after positions cant be placed on
2077 // same annotation row as positions.
2079 if (annotation.getAnnotationElementCount() > 0)
2081 AnnotationElement ae[] = annotation.getAnnotationElement();
2082 for (int aa = 0; aa < ae.length; aa++)
2084 int pos = (int) ae[aa].getPosition() - 1; // pos counts from 1 to
2085 // (|seg.start-seg.end|+1)
2086 if (pos >= 0 && pos < rangeMap.length)
2088 int row = ae[aa].getAfter() ? 1 : 0;
2089 if (anot[row][pos] != null)
2091 // only time this should happen is if the After flag is set.
2092 Cache.log.debug("Ignoring duplicate annotation site at " + pos);
2095 if (anot[1 - row][pos] != null)
2100 if (ae[aa].getDescription() != null)
2102 desc = ae[aa].getDescription();
2103 if (desc.length() > 0)
2105 // have imported valid description string
2106 AeContent[HASDESCSTR] = true;
2109 String dc = null; // ae[aa].getDisplayCharacter()==null ? "dc" :
2110 // ae[aa].getDisplayCharacter();
2111 String ss = null; // ae[aa].getSecondaryStructure()==null ? "ss" :
2112 // ae[aa].getSecondaryStructure();
2113 java.awt.Color colour = null;
2114 if (ae[aa].getGlyphCount() > 0)
2116 Glyph[] glyphs = ae[aa].getGlyph();
2117 for (int g = 0; g < glyphs.length; g++)
2119 if (glyphs[g].getDict().equals(
2120 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE))
2122 ss = glyphs[g].getContent();
2123 AeContent[HASSECSTR] = true;
2125 else if (glyphs[g].getDict().equals(
2126 uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO))
2128 Cache.log.debug("ignoring hydrophobicity glyph marker.");
2129 AeContent[HASHPHOB] = true;
2130 char c = (dc = glyphs[g].getContent()).charAt(0);
2131 // dc may get overwritten - but we still set the colour.
2132 colour = new java.awt.Color(c == '+' ? 255 : 0,
2133 c == '.' ? 255 : 0, c == '-' ? 255 : 0);
2136 else if (glyphs[g].getDict().equals(
2137 uk.ac.vamsas.objects.utils.GlyphDictionary.DEFAULT))
2139 dc = glyphs[g].getContent();
2140 AeContent[HASDC] = true;
2145 "IMPLEMENTATION TODO: Ignoring unknown glyph type "
2146 + glyphs[g].getDict());
2151 if (ae[aa].getValueCount() > 0)
2153 AeContent[HASVALS] = true;
2154 if (ae[aa].getValueCount() > 1)
2157 "ignoring additional " + (ae[aa].getValueCount() - 1)
2158 + " values in annotation element.");
2160 val = ae[aa].getValue(0);
2164 anot[row][pos] = new jalview.datamodel.Annotation(
2165 (dc != null) ? dc : "", desc,
2166 (ss != null) ? ss.charAt(0) : ' ', val);
2170 anot[row][pos] = new jalview.datamodel.Annotation(
2171 (dc != null) ? dc : "", desc,
2172 (ss != null) ? ss.charAt(0) : ' ', val, colour);
2177 Cache.log.warn("Ignoring out of bound annotation element " + aa
2178 + " in " + annotation.getVorbaId().getId());
2181 // decide on how many annotation rows are needed.
2184 for (int i = 0; i < anot[0].length; i++)
2186 if (anot[1][i] != null)
2188 anot[0][i] = anot[1][i];
2189 anot[0][i].description = anot[0][i].description + " (after)";
2190 AeContent[HASDESCSTR] = true; // we have valid description string
2199 for (int i = 0; i < anot[0].length; i++)
2201 anot[1][i].description = anot[1][i].description + " (after)";
2204 return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
2208 // no annotations to parse. Just return an empty annotationElement[]
2210 return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
2217 * the jalview alignment to which the annotation will be attached
2218 * (ideally - freshly updated from corresponding vamsas alignment)
2220 * @return unbound jalview alignment annotation object.
2222 private jalview.datamodel.AlignmentAnnotation getjAlignmentAnnotation(
2223 jalview.datamodel.AlignmentI jal,
2224 uk.ac.vamsas.objects.core.RangeAnnotation annotation)
2226 if (annotation == null)
2231 // hasSequenceRef=annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class);
2232 // boolean hasProvenance=hasSequenceRef ||
2233 // (annotation.getClass().equals(uk.ac.vamsas.objects.core.AlignmentAnnotation.class));
2235 * int se[] = getBounds(annotation); if (se==null) se=new int[]
2236 * {0,jal.getWidth()-1};
2238 Object[] parsedRangeAnnotation = parseRangeAnnotation(annotation);
2239 String a_label = annotation.getLabel();
2240 String a_descr = annotation.getDescription();
2241 GraphLine gl = null;
2243 boolean interp = true; // cleared if annotation is DISCRETE
2244 // set type and other attributes from properties
2245 if (annotation.getPropertyCount() > 0)
2247 // look for special jalview properties
2248 uk.ac.vamsas.objects.core.Property[] props = annotation.getProperty();
2249 for (int p = 0; p < props.length; p++)
2251 if (props[p].getName().equalsIgnoreCase(DISCRETE_ANNOTATION))
2253 type = AlignmentAnnotation.BAR_GRAPH;
2256 else if (props[p].getName().equalsIgnoreCase(CONTINUOUS_ANNOTATION))
2258 type = AlignmentAnnotation.LINE_GRAPH;
2260 else if (props[p].getName().equalsIgnoreCase(THRESHOLD))
2265 val = Float.valueOf(props[p].getContent());
2266 } catch (Exception e)
2268 Cache.log.warn("Failed to parse threshold property");
2274 gl = new GraphLine(val.floatValue(), "",
2275 java.awt.Color.black);
2279 gl.value = val.floatValue();
2283 else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name"))
2287 gl = new GraphLine(0, "", java.awt.Color.black);
2289 gl.label = props[p].getContent();
2293 jalview.datamodel.AlignmentAnnotation jan = null;
2294 if (a_label == null || a_label.length() == 0)
2296 a_label = annotation.getType();
2297 if (a_label.length() == 0)
2299 a_label = "Unamed annotation";
2302 if (a_descr == null || a_descr.length() == 0)
2304 a_descr = "Annotation of type '" + annotation.getType() + "'";
2306 if (parsedRangeAnnotation == null)
2309 "Inserting empty annotation row elements for a whole-alignment annotation.");
2313 if (parsedRangeAnnotation[3] != null)
2315 Cache.log.warn("Ignoring 'After' annotation row in "
2316 + annotation.getVorbaId());
2318 jalview.datamodel.Annotation[] arow = (jalview.datamodel.Annotation[]) parsedRangeAnnotation[2];
2319 boolean[] has = (boolean[]) parsedRangeAnnotation[0];
2320 // VAMSAS: getGraph is only on derived annotation for alignments - in this
2321 // way its 'odd' - there is already an existing TODO about removing this
2322 // flag as being redundant
2324 * if((annotation.getClass().equals(uk.ac.vamsas.objects.core.
2325 * AlignmentAnnotation.class) &&
2326 * ((uk.ac.vamsas.objects.core.AlignmentAnnotation)annotation).getGraph())
2327 * || (hasSequenceRef=true &&
2328 * ((uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation
2329 * )annotation).getGraph())) {
2335 type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default
2341 // no hints - so we ensure HPHOB display is like this.
2342 type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH;
2345 // make bounds and automatic description strings for jalview user's
2346 // benefit (these shouldn't be written back to vamsas document)
2347 boolean first = true;
2348 float min = 0, max = 1;
2350 for (int i = 0; i < arow.length; i++)
2352 if (arow[i] != null)
2354 if (i - lastval > 1 && interp)
2356 // do some interpolation *between* points
2357 if (arow[lastval] != null)
2359 float interval = arow[i].value - arow[lastval].value;
2360 interval /= i - lastval;
2361 float base = arow[lastval].value;
2362 for (int ip = lastval + 1, np = 0; ip < i; np++, ip++)
2364 arow[ip] = new jalview.datamodel.Annotation("", "", ' ',
2365 interval * np + base);
2366 // NB - Interpolated points don't get a tooltip and
2372 // check range - shouldn't we have a min and max property in the
2373 // annotation object ?
2376 min = max = arow[i].value;
2381 if (arow[i].value < min)
2383 min = arow[i].value;
2385 else if (arow[i].value > max)
2387 max = arow[i].value;
2390 // make tooltip and display char value
2391 if (!has[HASDESCSTR])
2393 arow[i].description = arow[i].value + "";
2399 if (arow[i].description != null
2400 && arow[i].description.length() < 3)
2402 // copy over the description as the display char.
2403 arow[i].displayCharacter = new String(
2404 arow[i].description);
2409 // mark the position as a point used for the interpolation.
2410 arow[i].displayCharacter = arow[i].value + "";
2415 jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
2416 arow, min, max, type);
2420 if (annotation.getAnnotationElementCount() == 0)
2422 // empty annotation array
2423 // TODO: alignment 'features' compare rangeType spec to alignment
2424 // width - if it is not complete, then mark regions on the annotation
2427 jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
2429 jan.setThreshold(null);
2430 jan.annotationId = annotation.getVorbaId().toString(); // keep all the
2433 if (annotation.getLinkCount() > 0)
2435 Cache.log.warn("Ignoring " + annotation.getLinkCount()
2436 + "links added to AlignmentAnnotation.");
2438 if (annotation.getModifiable() == null
2439 || annotation.getModifiable().length() == 0) // TODO: USE VAMSAS
2443 jan.editable = true;
2447 if (annotation.getGroup() != null
2448 && annotation.getGroup().length() > 0)
2450 jan.graphGroup = Integer.parseInt(annotation.getGroup()); // TODO:
2458 } catch (Exception e)
2461 "UNIMPLEMENTED : Couldn't parse non-integer group value for setting graphGroup correctly.");
2471 * get real bounds of a RangeType's specification. start and end are an
2472 * inclusive range within which all segments and positions lie. TODO: refactor
2476 * @return int[] { start, end}
2478 private int[] getBounds(RangeType dseta)
2483 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2485 throw new Error(MessageManager.getString(
2486 "error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2488 if (dseta.getSegCount() > 0)
2490 se = getSegRange(dseta.getSeg(0), true);
2491 for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++)
2493 int nse[] = getSegRange(dseta.getSeg(s), true);
2504 if (dseta.getPosCount() > 0)
2506 // could do a polarity for pos range too. and pass back indication of
2508 int pos = dseta.getPos(0).getI();
2509 se = new int[] { pos, pos };
2510 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2512 pos = dseta.getPos(p).getI();
2529 * map from a rangeType's internal frame to the referenced object's coordinate
2533 * @return int [] { ref(pos)...} for all pos in rangeType's frame.
2535 private int[] getMapping(RangeType dseta)
2537 Vector posList = new Vector();
2541 if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
2543 throw new Error(MessageManager.getString(
2544 "error.invalid_vamsas_rangetype_cannot_resolve_lists"));
2546 if (dseta.getSegCount() > 0)
2548 for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++)
2550 se = getSegRange(dseta.getSeg(s), false);
2551 int se_end = se[1 - se[2]] + (se[2] == 0 ? 1 : -1);
2552 for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1)
2554 posList.add(Integer.valueOf(p));
2558 else if (dseta.getPosCount() > 0)
2560 int pos = dseta.getPos(0).getI();
2562 for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
2564 pos = dseta.getPos(p).getI();
2565 posList.add(Integer.valueOf(pos));
2569 if (posList != null && posList.size() > 0)
2571 int[] range = new int[posList.size()];
2572 for (int i = 0; i < range.length; i++)
2574 range[i] = ((Integer) posList.elementAt(i)).intValue();
2585 * where the from range is the local mapped range, and the to range
2586 * is the 'mapped' range in the MapRangeType
2593 private jalview.util.MapList parsemapType(MapType maprange, int localu,
2596 jalview.util.MapList ml = null;
2597 int[] localRange = getMapping(maprange.getLocal());
2598 int[] mappedRange = getMapping(maprange.getMapped());
2599 long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit()
2601 long mu = maprange.getMapped().hasUnit()
2602 ? maprange.getMapped().getUnit()
2604 ml = new jalview.util.MapList(localRange, mappedRange, (int) lu,
2610 * initialise a range type object from a set of start/end inclusive intervals
2615 private void initRangeType(RangeType mrt, List<int[]> ranges)
2617 for (int[] range : ranges)
2619 Seg vSeg = new Seg();
2620 vSeg.setStart(range[0]);
2621 vSeg.setEnd(range[1]);
2627 * initialise a MapType object from a MapList object.
2633 private void initMapType(MapType maprange, jalview.util.MapList ml,
2636 maprange.setLocal(new Local());
2637 maprange.setMapped(new Mapped());
2638 initRangeType(maprange.getLocal(), ml.getFromRanges());
2639 initRangeType(maprange.getMapped(), ml.getToRanges());
2642 maprange.getLocal().setUnit(ml.getFromRatio());
2643 maprange.getLocal().setUnit(ml.getToRatio());
2648 * not needed now. Provenance getVamsasProvenance(jalview.datamodel.Provenance
2649 * jprov) { jalview.datamodel.ProvenanceEntry[] entries = null; // TODO: fix
2650 * App and Action here. Provenance prov = new Provenance();
2651 * org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( new
2652 * java.util.Date()); Entry provEntry;
2654 * if (jprov != null) { entries = jprov.getEntries(); for (int i = 0; i <
2655 * entries.length; i++) { provEntry = new Entry(); try { date = new
2656 * org.exolab.castor.types.Date(entries[i].getDate()); } catch (Exception ex)
2657 * { ex.printStackTrace();
2659 * date = new org.exolab.castor.types.Date(entries[i].getDate()); }
2660 * provEntry.setDate(date); provEntry.setUser(entries[i].getUser());
2661 * provEntry.setAction(entries[i].getAction()); prov.addEntry(provEntry); } }
2662 * else { provEntry = new Entry(); provEntry.setDate(date);
2663 * provEntry.setUser(System.getProperty("user.name")); // TODO: ext string
2664 * provEntry.setApp("JVAPP"); // TODO: ext string provEntry.setAction(action);
2665 * prov.addEntry(provEntry); }
2669 jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
2671 // TODO: fix App and Action entries and check use of provenance in jalview.
2672 jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
2673 for (int i = 0; i < prov.getEntryCount(); i++)
2675 jprov.addEntry(prov.getEntry(i).getUser(),
2676 prov.getEntry(i).getAction(), prov.getEntry(i).getDate(),
2677 prov.getEntry(i).getId());
2685 * @return default initial provenance list for a Jalview created vamsas
2688 Provenance dummyProvenance()
2690 return dummyProvenance(null);
2693 Entry dummyPEntry(String action)
2695 Entry entry = new Entry();
2696 entry.setApp(this.provEntry.getApp());
2699 entry.setAction(action);
2703 entry.setAction("created.");
2705 entry.setDate(new java.util.Date());
2706 entry.setUser(this.provEntry.getUser());
2710 Provenance dummyProvenance(String action)
2712 Provenance prov = new Provenance();
2713 prov.addEntry(dummyPEntry(action));
2717 Entry addProvenance(Provenance p, String action)
2719 Entry dentry = dummyPEntry(action);
2724 public Entry getProvEntry()
2729 public IClientDocument getClientDocument()
2734 public IdentityHashMap getJvObjectBinding()
2739 public Hashtable getVamsasObjectBinding()
2744 public void storeSequenceMappings(AlignmentViewport viewport,
2745 String title) throws Exception
2747 AlignmentViewport av = viewport;
2750 jalview.datamodel.AlignmentI jal = av.getAlignment();
2751 // /////////////////////////////////////////
2753 DataSet dataset = null;
2754 if (jal.getDataset() == null)
2756 Cache.log.warn("Creating new dataset for an alignment.");
2757 jal.setDataset(null);
2759 dataset = (DataSet) ((Alignment) getjv2vObj(
2760 viewport.getSequenceSetId())).getV_parent(); // jal.getDataset());
2761 if (dataset == null)
2763 dataset = (DataSet) getjv2vObj(jal.getDataset());
2765 "Can't find the correct dataset for the alignment in this view. Creating new one.");
2768 // Store any sequence mappings.
2769 List<AlignedCodonFrame> cframes = av.getAlignment().getCodonFrames();
2770 if (cframes != null)
2772 for (AlignedCodonFrame acf : cframes)
2774 if (acf.getdnaSeqs() != null && acf.getdnaSeqs().length > 0)
2776 jalview.datamodel.SequenceI[] dmps = acf.getdnaSeqs();
2777 jalview.datamodel.Mapping[] mps = acf.getProtMappings();
2778 for (int smp = 0; smp < mps.length; smp++)
2780 uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(
2784 new jalview.io.vamsas.Sequencemapping(this, mps[smp], mfrom,
2790 "NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
2791 + dmps[smp].getDisplayId(true) + " to "
2792 + mps[smp].getTo().getName());
2798 } catch (Exception e)
2800 throw new Exception(MessageManager.formatMessage(
2801 "exception.couldnt_store_sequence_mappings", new String[]
2806 public void clearSkipList()
2808 if (skipList != null)
2815 * @return the skipList
2817 public Hashtable getSkipList()
2824 * the skipList to set
2826 public void setSkipList(Hashtable skipList)
2828 this.skipList = skipList;
2832 * registry for datastoreItems
2834 DatastoreRegistry dsReg = new DatastoreRegistry();
2836 public DatastoreRegistry getDatastoreRegisty()
2840 dsReg = new DatastoreRegistry();