From 29ea678048298c63f589674ff35f6c026497550c Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 19 Jun 2009 10:10:46 +0000 Subject: [PATCH] debug and cyclefix for dbrefs with embedded sequences --- src/jalview/io/vamsas/Dbref.java | 69 +++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/src/jalview/io/vamsas/Dbref.java b/src/jalview/io/vamsas/Dbref.java index 5698228..d930f14 100644 --- a/src/jalview/io/vamsas/Dbref.java +++ b/src/jalview/io/vamsas/Dbref.java @@ -24,6 +24,7 @@ import uk.ac.vamsas.objects.core.DataSet; import uk.ac.vamsas.objects.core.DbRef; import uk.ac.vamsas.objects.core.Map; import uk.ac.vamsas.objects.core.Sequence; +import uk.ac.vamsas.objects.core.SequenceType; import jalview.io.VamsasAppDatastore; public class Dbref extends Rangetype @@ -87,43 +88,62 @@ public class Dbref extends Rangetype updateMapTo(mp); } } - else - { - jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map " - + jvobj.getSrcAccString()); - } - + else + { + jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map " + + jvobj.getSrcAccString()); + } + } + /** - * ugly hack to try to get the embedded sequences within a database reference to be stored in the document's dataset. + * ugly hack to try to get the embedded sequences within a database reference + * to be stored in the document's dataset. + * * @param mp */ private void updateMapTo(jalview.datamodel.Mapping mp) { - log.info("Performing updateMapTo remove this message when we know what we're doing."); - // TODO determine how sequences associated with database mappings are stored in the document - if (mp!=null && mp.getTo() != null) + log + .info("Performing updateMapTo remove this message when we know what we're doing."); + // TODO determine how sequences associated with database mappings are stored + // in the document + if (mp != null && mp.getTo() != null) { if (mp.getTo().getDatasetSequence() == null) { - if (!dsReg.isInvolvedInDsitem(mp.getTo())) + // TODO: fix this hinky sh!t + DatastoreItem dssync = dsReg.getDatastoreItemFor(mp.getTo()); + if (dssync == null) { // sync the dataset sequence, if it hasn't been done already. - Datasetsequence dssync = new Datasetsequence( - datastore, mp.getTo(), - (mp.getMappedWidth() == mp.getWidth()) ? sequence - .getDictionary() - : ((mp.getMappedWidth() == 3) ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA - : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA), - ds); - // add a mapping between new dataset sequence and sequence associated with the database reference + // TODO: ensure real dataset sequence corresponding to getTo is + // recovered + dssync = new Datasetsequence( + datastore, + mp.getTo(), + (mp.getMappedWidth() == mp.getWidth()) ? sequence + .getDictionary() + : ((mp.getMappedWidth() == 3) ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA + : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA), + ds); } + // + // TODO: NOW add a mapping between new dataset sequence and sequence + // associated with the database reference - } else { - log.debug("Ignoring non-dataset sequence mapping."); + // dna mappings only... + // new jalview.io.vamsas.Sequencemapping(datastore, mp, sequence, ds); + } + + } + else + { + log.debug("Ignoring non-dataset sequence mapping."); } } + public void updateFromDoc() { DbRef vobj = (DbRef) this.vobj; @@ -143,13 +163,13 @@ public class Dbref extends Rangetype } jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping( parsemapType(vobj.getMap(0))); - if (jvobj.getMap()==null || !mp.equals(jvobj.getMap())) + if (jvobj.getMap() == null || !mp.equals(jvobj.getMap())) { jvobj.setMap(mp); } } } - + public void conflict() { DbRef vobj = (DbRef) this.vobj; @@ -196,6 +216,7 @@ public class Dbref extends Rangetype dbref.setAccessionId(jvobj.getAccessionId()); dbref.setSource(jvobj.getSource()); dbref.setVersion(jvobj.getVersion()); + sequence.addDbRef(dbref); if (jvobj.getMap() != null) { jalview.datamodel.Mapping mp = jvobj.getMap(); @@ -204,6 +225,7 @@ public class Dbref extends Rangetype Map vMap = new Map(); initMapType(vMap, mp.getMap(), true); dbref.addMap(vMap); + updateMapTo(mp); } else { @@ -211,7 +233,6 @@ public class Dbref extends Rangetype + jvobj.getSrcAccString()); } } - sequence.addDbRef(dbref); } } -- 1.7.10.2