/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
package jalview.io;
import jalview.bin.Cache;
public static final String JALVIEW_ANNOTATION_ROW = "JalviewAnnotation";
/**
- * AlignmentAnnotation property to indicate that values should not be interpolated
+ * AlignmentAnnotation property to indicate that values should not be
+ * interpolated
*/
public static final String DISCRETE_ANNOTATION = "discrete";
+
/**
- * continuous property - optional to specify that annotation should be represented
- * as a continous graph line
+ * continuous property - optional to specify that annotation should be
+ * represented as a continous graph line
*/
private static final String CONTINUOUS_ANNOTATION = "continuous";
- private static final String THRESHOLD = "threshold";
-
+ private static final String THRESHOLD = "threshold";
Entry provEntry = null;
IdentityHashMap jv2vobj;
+ Hashtable alignRDHash;
+
public VamsasAppDatastore(IClientDocument cdoc, Hashtable vobj2jv,
- IdentityHashMap jv2vobj, Entry provEntry)
+ IdentityHashMap jv2vobj, Entry provEntry, Hashtable alignRDHash)
{
this.cdoc = cdoc;
this.vobj2jv = vobj2jv;
this.jv2vobj = jv2vobj;
this.provEntry = provEntry;
+ this.alignRDHash = alignRDHash;
}
/**
* put the alignment viewed by AlignViewport into cdoc.
*
* @param av
- * alignViewport to be stored
+ * alignViewport to be stored
* @param aFtitle
- * title for alignment
+ * title for alignment
*/
public void storeVAMSAS(AlignViewport av, String aFtitle)
{
root.addDataSet(dataset);
bindjvvobj(jal.getDataset(), dataset);
dataset.setProvenance(dummyProvenance());
- dataset.getProvenance().addEntry(provEntry);
+ // dataset.getProvenance().addEntry(provEntry);
nw = true;
}
else
// acid sequences.
String dict = jal.isNucleotide() ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
: uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA;
+ Vector dssmods = new Vector();
for (int i = 0; i < jal.getHeight(); i++)
{
SequenceI sq = jal.getSequenceAt(i).getDatasetSequence(); // only insert
sq.setVamsasId(sequence.getVorbaId().getId());
sequence.setSequence(sq.getSequenceAsString());
sequence.setDictionary(dict);
- sequence.setName(jal.getDataset().getSequenceAt(i).getName());
- sequence.setStart(jal.getDataset().getSequenceAt(i).getStart());
- sequence.setEnd(jal.getDataset().getSequenceAt(i).getEnd());
- sequence.setDescription(jal.getDataset().getSequenceAt(i)
- .getDescription());
+ sequence.setName(sq.getName());
+ sequence.setStart(sq.getStart());
+ sequence.setEnd(sq.getEnd());
+ sequence.setDescription(sq.getDescription());
dataset.addSequence(sequence);
+ dssmods.addElement(dssmods);
}
else
{
- // verify principal attributes. and update any new
- // features/references.
- System.out.println("update dataset sequence object.");
+ boolean dsmod = false;
+ // verify and update principal attributes.
+ if (sq.getDescription() != null
+ && (sequence.getDescription() == null || !sequence
+ .getDescription().equals(sq.getDescription())))
+ {
+ sequence.setDescription(sq.getDescription());
+ dsmod = true;
+ }
+ if (sequence.getSequence() == null
+ || !sequence.getSequence().equals(
+ sq.getSequenceAsString()))
+ {
+ if (sequence.getStart() != sq.getStart()
+ || sequence.getEnd() != sq.getEnd())
+ {
+ // update modified sequence.
+ sequence.setSequence(sq.getSequenceAsString());
+ sequence.setStart(sq.getStart());
+ sequence.setEnd(sq.getEnd());
+ dsmod = true;
+ }
+ }
+ if (!dict.equals(sequence.getDictionary()))
+ {
+ sequence.setDictionary(dict);
+ dsmod = true;
+ }
+ if (!sequence.getName().equals(sq.getName()))
+ {
+ sequence.setName(sq.getName());
+ dsmod = true;
+ }
+ if (dsmod)
+ {
+ dssmods.addElement(sequence);
+ }
}
+ // add or update any new features/references on dataset sequence
if (sq.getSequenceFeatures() != null)
{
int sfSize = sq.getSequenceFeatures().length;
for (int sf = 0; sf < sfSize; sf++)
{
+ // TODO: update/modifiable synchronizer
jalview.datamodel.SequenceFeature feature = (jalview.datamodel.SequenceFeature) sq
.getSequenceFeatures()[sf];
addProvenance(dsa.getProvenance(), "created"); // JBPNote - need
// to update
dsa.addSeqRef(sequence); // we have just created this annotation
- // - so safe to use this
+ // - so safe to use this
bindjvvobj(feature, dsa);
dataset.addDataSetAnnotations(dsa);
}
}
}
}
-
- if (sq.getDBRef() != null)
+ if (sq.getDatasetSequence() == null && sq.getDBRef() != null)
{
+ // only sync database references for dataset sequences
DBRefEntry[] entries = sq.getDBRef();
jalview.datamodel.DBRefEntry dbentry;
for (int db = 0; db < entries.length; db++)
}
}
+ if (dssmods.size() > 0)
+ {
+ if (!nw)
+ {
+ Entry pentry = this.addProvenance(dataset.getProvenance(),
+ "updated sequences");
+ // pentry.addInput(vInput); could write in which sequences were
+ // modified.
+ dssmods.removeAllElements();
+ }
+ }
// dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));
// ////////////////////////////////////////////
if (!av.getAlignment().isAligned())
- return; // TODO: trees could be written - but for the moment we just skip
-
+ return; // TODO: trees could be written - but for the moment we just
+ // skip
// ////////////////////////////////////////////
// Save the Alignments
- Alignment alignment = (Alignment) getjv2vObj(av); // this is so we can get
- // the alignviewport
- // back
+ Alignment alignment = (Alignment) getjv2vObj(av.getSequenceSetId()); // bind
+ // to
+ // the
+ // value
+ // used
+ // to
+ // associate
+ // different
+ // views
+ // to
+ // same
+ // alignment
+
if (alignment == null)
{
alignment = new Alignment();
- bindjvvobj(av, alignment);
+ bindjvvobj(av.getSequenceSetId(), alignment);
if (alignment.getProvenance() == null)
{
alignment.setProvenance(new Provenance());
alignment.addProperty(title);
}
alignment.setGapChar(String.valueOf(av.getGapCharacter()));
- AlignmentSequence alseq = null;
for (int i = 0; i < jal.getHeight(); i++)
{
- alseq = new AlignmentSequence();
- // TODO: VAMSAS: translate lowercase symbols to annotation ?
- alseq.setSequence(jal.getSequenceAt(i).getSequenceAsString());
- alseq.setName(jal.getSequenceAt(i).getName());
- alseq.setStart(jal.getSequenceAt(i).getStart());
- alseq.setEnd(jal.getSequenceAt(i).getEnd());
- if (getjv2vObj(jal.getSequenceAt(i).getDatasetSequence()) == null)
- {
- Cache.log
- .warn("Serious. Unbound dataset sequence in alignment: "
- + jal.getSequenceAt(i).getDatasetSequence());
- }
- alseq.setRefid(getjv2vObj(jal.getSequenceAt(i)
- .getDatasetSequence()));
- alignment.addAlignmentSequence(alseq);
- bindjvvobj(jal.getSequenceAt(i), alseq);
+ syncToAlignmentSequence(jal.getSequenceAt(i), alignment, null);
}
+ alignRDHash.put(av.getSequenceSetId(), av.getUndoRedoHash());
}
else
{
+ // always prepare to clone the alignment
+ boolean alismod = av.isUndoRedoHashModified((long[]) alignRDHash
+ .get(av.getSequenceSetId()));
// todo: verify and update mutable alignment props.
- if (alignment.getModifiable() == null) // TODO: USE VAMSAS LIBRARY
- // OBJECT LOCK METHODS
+ // TODO: Use isLocked methods
+ if (alignment.getModifiable() == null
+ || alignment.getModifiable().length() == 0)
+ // && !alignment.isDependedOn())
{
- System.out.println("update alignment in document.");
+ boolean modified = false;
+ // check existing sequences in local and in document.
+ Vector docseqs = new Vector(alignment
+ .getAlignmentSequenceAsReference());
+ for (int i = 0; i < jal.getHeight(); i++)
+ {
+ modified |= syncToAlignmentSequence(jal.getSequenceAt(i),
+ alignment, docseqs);
+ }
+ if (docseqs.size() > 0)
+ {
+ // removeValignmentSequences(alignment, docseqs);
+ docseqs.removeAllElements();
+ System.out
+ .println("Sequence deletion from alignment is not implemented.");
+
+ }
+ if (modified)
+ {
+ if (alismod)
+ {
+ // info in the undo
+ addProvenance(alignment.getProvenance(), "Edited"); // TODO:
+ // insert
+ // something
+ // sensible
+ // here again
+ }
+ else
+ {
+ // info in the undo
+ addProvenance(alignment.getProvenance(), "Attributes Edited"); // TODO:
+ // insert
+ // something
+ // sensible
+ // here
+ // again
+ }
+ }
+ if (alismod)
+ {
+ System.out.println("update alignment in document.");
+ }
+ else
+ {
+ System.out.println("alignment in document left unchanged.");
+ }
}
else
{
+ // unbind alignment from view.
+ // create new binding and new alignment.
+ // mark trail on new alignment as being derived from old ?
System.out
.println("update edited alignment to new alignment in document.");
}
* if (valseqf.getProvenance() == null) { valseqf.setProvenance(new
* Provenance()); } addProvenance(valseqf.getProvenance(), "created"); //
* JBPNote - // need to // update bindjvvobj(features[i], valseqf);
- * valseq.addAlignmentSequenceAnnotation(valseqf); } }
- * }
+ * valseq.addAlignmentSequenceAnnotation(valseqf); } } }
*/
}
}
an.setDescription(aa[i].description);
alignment.addAlignmentAnnotation(an);
Seg vSeg = new Seg(); // TODO: refactor to have a default
- // rangeAnnotationType initer/updater that
- // takes a set of int ranges.
+ // rangeAnnotationType initer/updater that
+ // takes a set of int ranges.
vSeg.setStart(1);
vSeg.setInclusive(true);
vSeg.setEnd(jal.getWidth());
if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
{
an.setGroup(Integer.toString(aa[i].graphGroup)); // // JBPNote
- // -
+ // -
// originally we
// were going to
// store
// of
// utf8
// translation
- ae.addValue(aa[i].annotations[a].value);
+ if (an.isGraph())
+ {
+ ae.addValue(aa[i].annotations[a].value);
+ }
ae.setPosition(a + 1);
if (aa[i].annotations[a].secondaryStructure != ' ')
{
// modifiable flag is supposed to be used.
}
setAnnotationType(an, aa[i]);
-
+
if (aa[i].graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
{
an.setGraph(true);
an.setGroup(Integer.toString(aa[i].graphGroup));
- if (aa[i].threshold!=null && aa[i].threshold.displayed)
- an.addProperty(newProperty(THRESHOLD, "float", ""+aa[i].threshold.value));
- if (aa[i].threshold.label!=null)
- an.addProperty(newProperty(THRESHOLD+"Name", "string", ""+aa[i].threshold.label));
+ if (aa[i].threshold != null && aa[i].threshold.displayed)
+ {
+ an.addProperty(newProperty(THRESHOLD, "float", ""
+ + aa[i].threshold.value));
+ if (aa[i].threshold.label != null)
+ {
+ an.addProperty(newProperty(THRESHOLD + "Name",
+ "string", "" + aa[i].threshold.label));
+ }
}
-
}
-
+
+ }
+
else
{
if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT
- // LOCK METHODS)
+ // LOCK METHODS)
{
// verify annotation - update (perhaps)
Cache.log
}
+ /**
+ * remove docseqs from the given alignment marking provenance appropriately
+ * and removing any references to the sequences.
+ *
+ * @param alignment
+ * @param docseqs
+ */
+ private void removeValignmentSequences(Alignment alignment, Vector docseqs)
+ {
+ // delete these from document. This really needs to be a generic document
+ // API function derived by CASTOR.
+ Enumeration en = docseqs.elements();
+ while (en.hasMoreElements())
+ {
+ alignment.removeAlignmentSequence((AlignmentSequence) en
+ .nextElement());
+ }
+ Entry pe = addProvenance(alignment.getProvenance(), "Removed "
+ + docseqs.size() + " sequences");
+ en = alignment.enumerateAlignmentAnnotation();
+ Vector toremove = new Vector();
+ while (en.hasMoreElements())
+ {
+ uk.ac.vamsas.objects.core.AlignmentAnnotation alan = (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
+ .nextElement();
+ if (alan.getSeqrefsCount() > 0)
+ {
+ int p = 0;
+ Vector storem = new Vector();
+ Enumeration sr = alan.enumerateSeqrefs();
+ while (sr.hasMoreElements())
+ {
+ Object alsr = sr.nextElement();
+ if (docseqs.contains(alsr))
+ {
+ storem.addElement(alsr);
+ }
+ }
+ // remove references to the deleted sequences
+ sr = storem.elements();
+ while (sr.hasMoreElements())
+ {
+ alan.removeSeqrefs(sr.nextElement());
+ }
+
+ if (alan.getSeqrefsCount() == 0)
+ {
+ // should then delete alan from dataset
+ toremove.addElement(alan);
+ }
+ }
+ }
+ // remove any annotation that used to be associated to a specific bunch of
+ // sequences
+ en = toremove.elements();
+ while (en.hasMoreElements())
+ {
+ alignment
+ .removeAlignmentAnnotation((uk.ac.vamsas.objects.core.AlignmentAnnotation) en
+ .nextElement());
+ }
+ // TODO: search through alignment annotations to remove any references to
+ // this alignment sequence
+ }
+
+ /**
+ * sync a jalview alignment seuqence into a vamsas alignment assumes all lock
+ * transformation/bindings have been sorted out before hand. creates/syncs the
+ * vamsas alignment sequence for jvalsq and adds it to the alignment if
+ * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
+ * and these are removed after being processed w.r.t a bound jvalsq
+ *
+ */
+ private boolean syncToAlignmentSequence(SequenceI jvalsq,
+ Alignment alignment, Vector unbounddocseq)
+ {
+ boolean modal = false;
+ // todo: islocked method here
+ boolean up2doc = false;
+ AlignmentSequence alseq = (AlignmentSequence) getjv2vObj(jvalsq);
+ if (alseq == null)
+ {
+ alseq = new AlignmentSequence();
+ up2doc = true;
+ }
+ else
+ {
+ if (unbounddocseq != null)
+ {
+ unbounddocseq.removeElement(alseq);
+ }
+ }
+ // boolean locked = (alignment.getModifiable()==null ||
+ // alignment.getModifiable().length()>0);
+ // TODO: VAMSAS: translate lowercase symbols to annotation ?
+ if (up2doc || !alseq.getSequence().equals(jvalsq.getSequenceAsString()))
+ {
+ alseq.setSequence(jvalsq.getSequenceAsString());
+ alseq.setStart(jvalsq.getStart());
+ alseq.setEnd(jvalsq.getEnd());
+ modal = true;
+ }
+ if (up2doc || !alseq.getName().equals(jvalsq.getName()))
+ {
+ modal = true;
+ alseq.setName(jvalsq.getName());
+ }
+ if (jvalsq.getDescription() != null
+ && (alseq.getDescription() == null || !jvalsq.getDescription()
+ .equals(alseq.getDescription())))
+ {
+ modal = true;
+ alseq.setDescription(jvalsq.getDescription());
+ }
+ if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
+ {
+ Cache.log
+ .warn("Serious Implementation error - Unbound dataset sequence in alignment: "
+ + jvalsq.getDatasetSequence());
+ }
+ alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
+ if (up2doc)
+ {
+
+ alignment.addAlignmentSequence(alseq);
+ bindjvvobj(jvalsq, alseq);
+ }
+ return up2doc || modal;
+ }
+
+ /**
+ * locally sync a jalview alignment seuqence from a vamsas alignment assumes
+ * all lock transformation/bindings have been sorted out before hand.
+ * creates/syncs the jvalsq from the alignment sequence
+ */
+ private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
+ char valGapchar, char gapChar, Vector dsseqs)
+
+ {
+ boolean modal = false;
+ // todo: islocked method here
+ boolean upFromdoc = false;
+ jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
+ if (alseq == null)
+ {
+ upFromdoc = true;
+ }
+ if (alseq != null)
+ {
+
+ // boolean locked = (alignment.getModifiable()==null ||
+ // alignment.getModifiable().length()>0);
+ // TODO: VAMSAS: translate lowercase symbols to annotation ?
+ if (upFromdoc
+ || !valseq.getSequence().equals(alseq.getSequenceAsString()))
+ {
+ // this might go *horribly* wrong
+ alseq.setSequence(new String(valseq.getSequence()).replace(
+ valGapchar, gapChar));
+ alseq.setStart((int) valseq.getStart());
+ alseq.setEnd((int) valseq.getEnd());
+ modal = true;
+ }
+ if (!valseq.getName().equals(alseq.getName()))
+ {
+ modal = true;
+ alseq.setName(valseq.getName());
+ }
+ if (alseq.getDescription() == null
+ || (valseq.getDescription() == null || alseq.getDescription()
+ .equals(valseq.getDescription())))
+ {
+ alseq.setDescription(valseq.getDescription());
+ modal = true;
+ }
+ if (modal && Cache.log.isDebugEnabled())
+ {
+ Cache.log.debug("Updating apparently edited sequence "
+ + alseq.getName());
+ }
+ }
+ else
+ {
+ alseq = new jalview.datamodel.Sequence(valseq.getName(), valseq
+ .getSequence().replace(valGapchar, gapChar), (int) valseq
+ .getStart(), (int) valseq.getEnd());
+
+ Vobject datsetseq = (Vobject) valseq.getRefid();
+ if (datsetseq != null)
+ {
+ alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
+ // if
+ // AlignemntSequence
+ // reference
+ // isn't
+ // a
+ // simple
+ // SequenceI
+ }
+ else
+ {
+ Cache.log
+ .error("Invalid dataset sequence id (null) for alignment sequence "
+ + valseq.getVorbaId());
+ }
+ bindjvvobj(alseq, valseq);
+ alseq.setVamsasId(valseq.getVorbaId().getId());
+ dsseqs.add(alseq);
+ }
+ Vobject datsetseq = (Vobject) valseq.getRefid();
+ if (datsetseq != null)
+ {
+ if (datsetseq != alseq.getDatasetSequence())
+ {
+ modal = true;
+ }
+ alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
+ }
+ return upFromdoc || modal;
+ }
+
private void initRangeAnnotationType(RangeAnnotation an,
AlignmentAnnotation alan, int[] gapMap)
{
// the Jalview
// specific
// bits.
- if (alan.getThreshold()!=null && alan.getThreshold().displayed)
+ if (alan.getThreshold() != null && alan.getThreshold().displayed)
{
- an.addProperty(newProperty(THRESHOLD, "float", ""+alan.getThreshold().value));
- if (alan.getThreshold().label!=null)
- an.addProperty(newProperty(THRESHOLD+"Name", "string", ""+alan.getThreshold().label));
+ an.addProperty(newProperty(THRESHOLD, "float", ""
+ + alan.getThreshold().value));
+ if (alan.getThreshold().label != null)
+ an.addProperty(newProperty(THRESHOLD + "Name", "string", ""
+ + alan.getThreshold().label));
}
((DataSet) sref.getV_parent()).addDataSetAnnotations(an);
bindjvvobj(alan, an);
{
// update reference sequence Annotation
if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
- // METHODS)
+ // METHODS)
{
// verify existing alignment sequence annotation is up to date
System.out.println("update dataset sequence annotation.");
* something extracted from another program, etc)
*/
an.setType(JALVIEW_ANNOTATION_ROW); // TODO: better fix
- // this rough guess ;)
+ // this rough guess ;)
alsref.addAlignmentSequenceAnnotation(an);
bindjvvobj(alan, an);
// These properties are directly supported by the
{
// update reference sequence Annotation
if (an.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT LOCK
- // METHODS)
+ // METHODS)
{
// verify existing alignment sequence annotation is up to date
System.out.println("update alignment sequence annotation.");
/**
* set vamsas annotation object type from jalview annotation
+ *
* @param an
* @param alan
*/
- private void setAnnotationType(RangeAnnotation an, AlignmentAnnotation alan)
+ private void setAnnotationType(RangeAnnotation an,
+ AlignmentAnnotation alan)
{
if (an instanceof AlignmentSequenceAnnotation)
{
if (alan.graph != AlignmentAnnotation.NO_GRAPH)
{
- ((AlignmentSequenceAnnotation)an).setGraph(true);
- } else
+ ((AlignmentSequenceAnnotation) an).setGraph(true);
+ }
+ else
{
- ((AlignmentSequenceAnnotation)an).setGraph(false);
+ ((AlignmentSequenceAnnotation) an).setGraph(false);
}
}
if (an instanceof uk.ac.vamsas.objects.core.AlignmentAnnotation)
{
if (alan.graph != AlignmentAnnotation.NO_GRAPH)
{
- ((uk.ac.vamsas.objects.core.AlignmentAnnotation)an).setGraph(true);
- } else
+ ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an).setGraph(true);
+ }
+ else
{
- ((uk.ac.vamsas.objects.core.AlignmentAnnotation)an).setGraph(false);
+ ((uk.ac.vamsas.objects.core.AlignmentAnnotation) an)
+ .setGraph(false);
}
}
switch (alan.graph)
{
- case AlignmentAnnotation.BAR_GRAPH:
- an.addProperty(newProperty(DISCRETE_ANNOTATION, "boolean","true"));
- break;
- case AlignmentAnnotation.LINE_GRAPH:
- an.addProperty(newProperty(CONTINUOUS_ANNOTATION, "boolean","true"));
- break;
- default:
- // don't add any kind of discrete or continous property info.
+ case AlignmentAnnotation.BAR_GRAPH:
+ an.addProperty(newProperty(DISCRETE_ANNOTATION, "boolean", "true"));
+ break;
+ case AlignmentAnnotation.LINE_GRAPH:
+ an.addProperty(newProperty(CONTINUOUS_ANNOTATION, "boolean", "true"));
+ break;
+ default:
+ // don't add any kind of discrete or continous property info.
}
}
* correctly create a RangeAnnotation from a jalview sequence feature
*
* @param dsa
- * (typically DataSetAnnotations or AlignmentSequenceAnnotation)
+ * (typically DataSetAnnotations or
+ * AlignmentSequenceAnnotation)
* @param feature
- * (the feature to be mapped from)
+ * (the feature to be mapped from)
* @return
*/
private RangeAnnotation getDSAnnotationFromJalview(RangeAnnotation dsa,
*
* @param visSeg
* @param ensureDirection
- * when true - always ensure start is less than end.
+ * when true - always ensure start is less than end.
* @return int[] { start, end, direction} where direction==1 for range running
* from end to start.
*/
new jalview.io.vamsas.Dbref(this, dbref[db], vdseq, dsseq);
}
+ dsseq.updatePDBIds();
}
}
{
SequenceI dsSeq = (SequenceI) getvObj2jv((Vobject) dseta
.getSeqRef(0)); // TODO: deal with group dataset
- // annotations
+ // annotations
if (dsSeq == null)
{
jalview.bin.Cache.log
{
uk.ac.vamsas.objects.core.Alignment alignment = dataset
.getAlignment(al);
- AlignViewport av = (AlignViewport) getvObj2jv(alignment);
+ AlignViewport av = findViewport(alignment);
+
jalview.datamodel.AlignmentI jal = null;
if (av != null)
{
}
iSize = alignment.getAlignmentSequenceCount();
boolean newal = (jal == null) ? true : false;
+ boolean refreshal = false;
Vector newasAnnots = new Vector();
char gapChar = ' '; // default for new alignments read in from the
- // document
+ // document
if (jal != null)
{
dsseqs = jal.getSequences(); // for merge/update
for (i = 0; i < iSize; i++)
{
AlignmentSequence valseq = alignment.getAlignmentSequence(i);
- jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
- if (alseq != null)
- {
- // TODO: upperCase/LowerCase situation here ? do we allow it ?
- // if (!alseq.getSequence().equals(valseq.getSequence())) {
- // throw new Error("Broken! - mismatch of dataset sequence and
- // jalview internal dataset sequence.");
- if (Cache.log.isDebugEnabled())
- {
- Cache.log.debug("Updating apparently edited sequence "
- + alseq.getName());
- }
- // this might go *horribly* wrong
- alseq.setSequence(new String(valseq.getSequence()).replace(
- valGapchar, gapChar));
- jremain--;
- }
- else
+ jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(valseq);
+ if (syncFromAlignmentSequence(valseq, valGapchar, gapChar,
+ dsseqs)
+ && alseq != null)
{
- alseq = new jalview.datamodel.Sequence(valseq.getName(),
- valseq.getSequence().replace(valGapchar, gapChar),
- (int) valseq.getStart(), (int) valseq.getEnd());
- Vobject datsetseq = (Vobject) valseq.getRefid();
- if (datsetseq != null)
- {
- alseq
- .setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
- // if
- // AlignemntSequence
- // reference
- // isn't
- // a
- // simple
- // SequenceI
- }
- else
- {
- Cache.log
- .error("Invalid dataset sequence id (null) for alignment sequence "
- + valseq.getVorbaId());
- }
- bindjvvobj(alseq, valseq);
- alseq.setVamsasId(valseq.getVorbaId().getId());
- dsseqs.add(alseq);
+ // updated to sequence from the document
+ jremain--;
+ refreshal = true;
}
if (valseq.getAlignmentSequenceAnnotationCount() > 0)
{
for (int a = 0; a < vasannot.length; a++)
{
jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO:
- // 1:many
- // jalview
- // alignment
- // sequence
- // annotations
+ // 1:many
+ // jalview
+ // alignment
+ // sequence
+ // annotations
if (asa == null)
{
int se[] = getBounds(vasannot[a]);
asa = getjAlignmentAnnotation(jal, vasannot[a]);
asa.setSequenceRef(alseq);
asa.createSequenceMapping(alseq, se[0], false); // TODO:
- // verify
- // that
- // positions
- // in
- // alseqAnnotation
- // correspond
- // to
- // ungapped
- // residue
- // positions.
+ // verify
+ // that
+ // positions
+ // in
+ // alseqAnnotation
+ // correspond
+ // to
+ // ungapped
+ // residue
+ // positions.
alseq.addAlignmentAnnotation(asa);
bindjvvobj(asa, vasannot[a]);
newasAnnots.add(asa);
{
// update existing annotation - can do this in place
if (vasannot[a].getModifiable() == null) // TODO: USE
- // VAMSAS LIBRARY
- // OBJECT LOCK
- // METHODS)
+ // VAMSAS LIBRARY
+ // OBJECT LOCK
+ // METHODS)
{
Cache.log
.info("UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
Cache.log
.debug("update from vamsas alignment annotation to existing jalview alignment annotation.");
if (an[j].getModifiable() == null) // TODO: USE VAMSAS
- // LIBRARY OBJECT LOCK
- // METHODS)
+ // LIBRARY OBJECT LOCK
+ // METHODS)
{
// TODO: user defined annotation is totally mutable... - so
// load it up or throw away if locally edited.
{
for (int p = 0, pe = alignment.getPropertyCount(); p < pe; p++)
{
- if (alignment.getProperty(p).getName().equals(
- "title"))
+ if (alignment.getProperty(p).getName().equals("title"))
{
title = alignment.getProperty(p).getContent();
}
// alignment using its provenance.
if (Cache.log.isDebugEnabled())
{
- title = title + "("
- + alignment.getVorbaId() + ")";
-
+ title = title + "(" + alignment.getVorbaId() + ")";
+
}
- jalview.gui.Desktop.addInternalFrame(alignFrame, title
- ,
+ jalview.gui.Desktop.addInternalFrame(alignFrame, title,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
- bindjvvobj(av, alignment);
+ bindjvvobj(av.getSequenceSetId(), alignment);
}
else
{
// TODO: fix this so we retrieve the alignFrame handing av
// *directly*
alignFrame = getAlignFrameFor(av);
+ if (refreshal)
+ {
+ av.alignmentChanged(alignFrame.alignPanel);
+ }
}
// LOAD TREES
// /////////////////////////////////////
this, alignFrame, alignment.getTree(t));
TreePanel tp = null;
if (vstree.isValidTree())
- {
- tp = alignFrame
- .ShowNewickTree(vstree.getNewickTree(), vstree
- .getTitle(), vstree.getInputData(), 600,
- 500, t * 20 + 50, t * 20 + 50);
+ {
+ tp = alignFrame.ShowNewickTree(vstree.getNewickTree(),
+ vstree.getTitle(), vstree.getInputData(), 600,
+ 500, t * 20 + 50, t * 20 + 50);
+
}
- if (tp!=null)
+ if (tp != null)
+ {
bindjvvobj(tp, alignment.getTree(t));
+ try
+ {
+ vstree.UpdateSequenceTreeMap(tp);
+ } catch (RuntimeException e)
+ {
+ Cache.log.warn("update of labels failed.", e);
+ }
+ }
else
{
- Cache.log.warn("Cannot create tree for tree "+t+" in document ("+alignment.getTree(t).getVorbaId());
+ Cache.log.warn("Cannot create tree for tree " + t
+ + " in document ("
+ + alignment.getTree(t).getVorbaId());
}
}
}
}
+ public AlignViewport findViewport(Alignment alignment)
+ {
+ AlignViewport av = null;
+ AlignViewport[] avs = findViewportForSequenceSetId((String) getvObj2jv(alignment));
+ if (avs != null)
+ {
+ av = avs[0];
+ }
+ return av;
+ }
+
+ private AlignViewport[] findViewportForSequenceSetId(String sequenceSetId)
+ {
+ Vector viewp = new Vector();
+ if (Desktop.desktop != null)
+ {
+ javax.swing.JInternalFrame[] frames = Desktop.instance.getAllFrames();
+
+ for (int t = 0; t < frames.length; t++)
+ {
+ if (frames[t] instanceof AlignFrame)
+ {
+ if (((AlignFrame) frames[t]).getViewport().getSequenceSetId()
+ .equals(sequenceSetId))
+ {
+ viewp.addElement(((AlignFrame) frames[t]).getViewport());
+ }
+ }
+ }
+ if (viewp.size() > 0)
+ {
+ AlignViewport[] vp = new AlignViewport[viewp.size()];
+ viewp.copyInto(vp);
+ return vp;
+ }
+ }
+ return null;
+ }
+
// bitfields - should be a template in j1.5
private static int HASSECSTR = 0;
{ new jalview.datamodel.Annotation[rangeMap.length],
new jalview.datamodel.Annotation[rangeMap.length] };
boolean mergeable = true; // false if 'after positions cant be placed on
- // same annotation row as positions.
+ // same annotation row as positions.
if (annotation.getAnnotationElementCount() > 0)
{
for (int aa = 0; aa < ae.length; aa++)
{
int pos = (int) ae[aa].getPosition() - 1; // pos counts from 1 to
- // (|seg.start-seg.end|+1)
+ // (|seg.start-seg.end|+1)
if (pos >= 0 && pos < rangeMap.length)
{
int row = ae[aa].getAfter() ? 1 : 0;
}
}
String dc = null; // ae[aa].getDisplayCharacter()==null ? "dc" :
- // ae[aa].getDisplayCharacter();
+ // ae[aa].getDisplayCharacter();
String ss = null; // ae[aa].getSecondaryStructure()==null ? "ss" :
- // ae[aa].getSecondaryStructure();
+ // ae[aa].getSecondaryStructure();
java.awt.Color colour = null;
if (ae[aa].getGlyphCount() > 0)
{
}
else
{
- Cache.log.debug("IMPLEMENTATION TODO: Ignoring unknown glyph type "
- + glyphs[g].getDict());
+ Cache.log
+ .debug("IMPLEMENTATION TODO: Ignoring unknown glyph type "
+ + glyphs[g].getDict());
}
}
}
anot[0][i] = anot[1][i];
anot[0][i].description = anot[0][i].description + " (after)";
AeContent[HASDESCSTR] = true; // we have valid description string
- // data
+ // data
anot[1][i] = null;
}
}
/**
* @param jal
- * the jalview alignment to which the annotation will be attached
- * (ideally - freshly updated from corresponding vamsas alignment)
+ * the jalview alignment to which the annotation will be
+ * attached (ideally - freshly updated from corresponding
+ * vamsas alignment)
* @param annotation
* @return unbound jalview alignment annotation object.
*/
Object[] parsedRangeAnnotation = parseRangeAnnotation(annotation);
String a_label = annotation.getLabel();
String a_descr = annotation.getDescription();
- GraphLine gl=null;
- int type=0;
- boolean interp=true; // cleared if annotation is DISCRETE
+ GraphLine gl = null;
+ int type = 0;
+ boolean interp = true; // cleared if annotation is DISCRETE
// set type and other attributes from properties
if (annotation.getPropertyCount() > 0)
{
// look for special jalview properties
- uk.ac.vamsas.objects.core.Property[] props = annotation
- .getProperty();
+ uk.ac.vamsas.objects.core.Property[] props = annotation.getProperty();
for (int p = 0; p < props.length; p++)
{
if (props[p].getName().equalsIgnoreCase(DISCRETE_ANNOTATION))
{
type = AlignmentAnnotation.BAR_GRAPH;
- interp=false;
- } else if
- (props[p].getName().equalsIgnoreCase(CONTINUOUS_ANNOTATION)) {
+ interp = false;
+ }
+ else if (props[p].getName().equalsIgnoreCase(CONTINUOUS_ANNOTATION))
+ {
type = AlignmentAnnotation.LINE_GRAPH;
- } else if
- (props[p].getName().equalsIgnoreCase(THRESHOLD))
+ }
+ else if (props[p].getName().equalsIgnoreCase(THRESHOLD))
{
- Float val=null;
- try {
+ Float val = null;
+ try
+ {
val = new Float(props[p].getContent());
- }catch (Exception e)
+ } catch (Exception e)
{
Cache.log.warn("Failed to parse threshold property");
}
- if (val!=null)
- if (gl==null)
- {
- gl = new GraphLine(val.floatValue(), "", java.awt.Color.black);
- } else
- {
- gl.value = val.floatValue();
- }
+ if (val != null)
+ if (gl == null)
+ {
+ gl = new GraphLine(val.floatValue(), "", java.awt.Color.black);
+ }
+ else
+ {
+ gl.value = val.floatValue();
+ }
}
- else if (props[p].getName().equalsIgnoreCase(THRESHOLD+"Name"))
+ else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name"))
{
- if (gl==null)
+ if (gl == null)
gl = new GraphLine(0, "", java.awt.Color.black);
gl.label = props[p].getContent();
}
*/
if (has[HASVALS])
{
- if (type==0)
+ if (type == 0)
{
- type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default type of value annotation
+ type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default
+ // type of
+ // value
+ // annotation
if (has[HASHPHOB])
{
// no hints - so we ensure HPHOB display is like this.
if (!has[HASDC])
{
if (!interp)
- {
- if (arow[i].description!=null && arow[i].description.length()<3)
+ {
+ if (arow[i].description != null
+ && arow[i].description.length() < 3)
{
// copy over the description as the display char.
arow[i].displayCharacter = new String(arow[i].description);
}
- } else
- {
- // mark the position as a point used for the interpolation.
+ }
+ else
+ {
+ // mark the position as a point used for the interpolation.
arow[i].displayCharacter = arow[i].value + "";
- }
+ }
}
}
}
}
else
{
- if (annotation.getAnnotationElementCount()==0)
+ if (annotation.getAnnotationElementCount() == 0)
{
// empty annotation array
- // TODO: alignment 'features' compare rangeType spec to alignment width - if it is not complete, then mark regions on the annotation row.
+ // TODO: alignment 'features' compare rangeType spec to alignment
+ // width - if it is not complete, then mark regions on the annotation
+ // row.
}
jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
arow);
Cache.log.warn("Ignoring " + annotation.getLinkCount()
+ "links added to AlignmentAnnotation.");
}
- if (annotation.getModifiable() == null) // TODO: USE VAMSAS LIBRARY OBJECT
- // LOCK METHODS)
+ if (annotation.getModifiable() == null
+ || annotation.getModifiable().length() == 0) // TODO: USE VAMSAS
+ // LIBRARY OBJECT
+ // LOCK METHODS)
{
jan.editable = true;
}
if (annotation.getGroup() != null
&& annotation.getGroup().length() > 0)
{
- jan.graphGroup = Integer.parseInt(annotation.getGroup());
+ jan.graphGroup = Integer.parseInt(annotation.getGroup()); // TODO:
+ // group
+ // similarly
+ // named
+ // annotation
+ // together
+ // ?
}
} catch (Exception e)
{
/**
*
* @param maprange
- * where the from range is the local mapped range, and the to range
- * is the 'mapped' range in the MapRangeType
+ * where the from range is the local mapped range, and the to
+ * range is the 'mapped' range in the MapRangeType
* @param default
- * unit for local
+ * unit for local
* @param default
- * unit for mapped
+ * unit for mapped
* @return MapList
*/
private jalview.util.MapList parsemapType(MapType maprange, int localu,
return prov;
}
- void addProvenance(Provenance p, String action)
+ Entry addProvenance(Provenance p, String action)
{
- p.addEntry(dummyPEntry(action));
+ Entry dentry = dummyPEntry(action);
+ p.addEntry(dentry);
+ return dentry;
}
public Entry getProvEntry()
{
Cache.log
.warn("NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
- + mfrom.getName()
+ + dmps[smp].getDisplayId(true)
+ " to "
+ mps[smp].getTo().getName());
}