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.
21 package jalview.io.vamsas;
23 import jalview.datamodel.DBRefEntry;
24 import jalview.datamodel.SequenceI;
25 import jalview.io.VamsasAppDatastore;
27 import uk.ac.vamsas.objects.core.DataSet;
28 import uk.ac.vamsas.objects.core.DbRef;
29 import uk.ac.vamsas.objects.core.Map;
30 import uk.ac.vamsas.objects.core.Sequence;
32 public class Dbref extends Rangetype
34 jalview.datamodel.SequenceI sq = null;
36 uk.ac.vamsas.objects.core.Sequence sequence = null;
40 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry,
41 jalview.datamodel.SequenceI sq2,
42 uk.ac.vamsas.objects.core.Sequence sequence2, DataSet dataset)
44 super(datastore, dbentry, DbRef.class);
45 // initialise object specific attributes
54 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq,
57 super(datastore, ref, jalview.datamodel.DBRefEntry.class);
60 ds = (DataSet) vdseq.getV_parent();
64 public void updateToDoc()
66 DbRef dbref = (DbRef) this.vobj;
67 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
68 dbref.setAccessionId(jvobj.getAccessionId());
69 dbref.setSource(jvobj.getSource());
70 dbref.setVersion(jvobj.getVersion());
71 if (jvobj.getMap() != null)
73 // Record mapping to external database coordinate system.
74 jalview.datamodel.Mapping mp = jvobj.getMap();
75 if (mp.getMap() != null)
78 if (dbref.getMapCount() == 0)
81 initMapType(vMap, mp.getMap(), true);
86 // we just update the data anyway.
87 vMap = dbref.getMap(0);
88 initMapType(vMap, mp.getMap(), true);
95 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
96 + jvobj.getSrcAccString());
102 * ugly hack to try to get the embedded sequences within a database reference
103 * to be stored in the document's dataset.
107 private void updateMapTo(jalview.datamodel.Mapping mp)
109 log.info("Performing updateMapTo remove this message when we know what we're doing.");
110 // TODO determine how sequences associated with database mappings are stored
112 if (mp != null && mp.getTo() != null)
114 if (mp.getTo().getDatasetSequence() == null)
116 // TODO: fix this hinky sh!t
117 DatastoreItem dssync = dsReg.getDatastoreItemFor(mp.getTo());
120 // sync the dataset sequence, if it hasn't been done already.
121 // TODO: ensure real dataset sequence corresponding to getTo is
123 dssync = new Datasetsequence(
126 (mp.getMappedWidth() == mp.getWidth()) ? sequence
128 : ((mp.getMappedWidth() == 3) ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
129 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA),
133 // TODO: NOW add a mapping between new dataset sequence and sequence
134 // associated with the database reference
136 // dna mappings only...
137 // new jalview.io.vamsas.Sequencemapping(datastore, mp, sequence, ds);
144 log.debug("Ignoring non-dataset sequence mapping.");
148 public void updateFromDoc()
150 DbRef vobj = (DbRef) this.vobj;
151 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
152 jvobj.setAccessionId(vobj.getAccessionId());
153 jvobj.setSource(vobj.getSource());
154 jvobj.setVersion(vobj.getVersion());
156 if (vobj.getMapCount() > 0)
158 // TODO: Jalview ignores all the other maps
159 if (vobj.getMapCount() > 1)
161 jalview.bin.Cache.log
162 .debug("Ignoring additional mappings on DbRef: "
163 + jvobj.getSource() + ":" + jvobj.getAccessionId());
165 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
166 parsemapType(vobj.getMap(0)));
167 if (jvobj.getMap() == null || !mp.equals(jvobj.getMap()))
174 public void conflict()
176 DbRef vobj = (DbRef) this.vobj;
177 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
178 jalview.bin.Cache.log.debug("Conflict in dbentry update for "
179 + vobj.getAccessionId() + vobj.getSource() + " "
180 + vobj.getVorbaId());
181 // TODO Auto-generated method stub
185 public void addFromDocument()
187 DbRef vobj = (DbRef) this.vobj;
188 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
190 sq.addDBRef(jvobj = new jalview.datamodel.DBRefEntry(vobj.getSource()
191 .toString(), vobj.getVersion().toString(), vobj
192 .getAccessionId().toString()));
193 if (vobj.getMapCount() > 0)
195 // TODO: Jalview ignores all the other maps
196 if (vobj.getMapCount() > 1)
198 jalview.bin.Cache.log
199 .debug("Ignoring additional mappings on DbRef: "
200 + jvobj.getSource() + ":" + jvobj.getAccessionId());
202 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
203 parsemapType(vobj.getMap(0)));
206 // TODO: jalview ignores links and properties because it doesn't know what
209 bindjvvobj(jvobj, vobj);
212 public void addToDocument()
214 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
215 DbRef dbref = new DbRef();
216 bindjvvobj(jvobj, dbref);
217 dbref.setAccessionId(jvobj.getAccessionId());
218 dbref.setSource(jvobj.getSource());
219 dbref.setVersion(jvobj.getVersion());
220 sequence.addDbRef(dbref);
221 if (jvobj.getMap() != null)
223 jalview.datamodel.Mapping mp = jvobj.getMap();
224 if (mp.getMap() != null)
226 Map vMap = new Map();
227 initMapType(vMap, mp.getMap(), true);
233 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
234 + jvobj.getSrcAccString());