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 uk.ac.vamsas.objects.core.DataSet;
26 import uk.ac.vamsas.objects.core.DbRef;
27 import uk.ac.vamsas.objects.core.Map;
28 import uk.ac.vamsas.objects.core.Sequence;
29 import jalview.io.VamsasAppDatastore;
31 public class Dbref extends Rangetype
33 jalview.datamodel.SequenceI sq = null;
35 uk.ac.vamsas.objects.core.Sequence sequence = null;
39 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry,
40 jalview.datamodel.SequenceI sq2,
41 uk.ac.vamsas.objects.core.Sequence sequence2, DataSet dataset)
43 super(datastore, dbentry, DbRef.class);
44 // initialise object specific attributes
53 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq,
56 super(datastore, ref, jalview.datamodel.DBRefEntry.class);
59 ds = (DataSet) vdseq.getV_parent();
63 public void updateToDoc()
65 DbRef dbref = (DbRef) this.vobj;
66 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
67 dbref.setAccessionId(jvobj.getAccessionId());
68 dbref.setSource(jvobj.getSource());
69 dbref.setVersion(jvobj.getVersion());
70 if (jvobj.getMap() != null)
72 // Record mapping to external database coordinate system.
73 jalview.datamodel.Mapping mp = jvobj.getMap();
74 if (mp.getMap() != null)
77 if (dbref.getMapCount() == 0)
80 initMapType(vMap, mp.getMap(), true);
85 // we just update the data anyway.
86 vMap = dbref.getMap(0);
87 initMapType(vMap, mp.getMap(), true);
94 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
95 + jvobj.getSrcAccString());
101 * ugly hack to try to get the embedded sequences within a database reference
102 * to be stored in the document's dataset.
106 private void updateMapTo(jalview.datamodel.Mapping mp)
108 log.info("Performing updateMapTo remove this message when we know what we're doing.");
109 // TODO determine how sequences associated with database mappings are stored
111 if (mp != null && mp.getTo() != null)
113 if (mp.getTo().getDatasetSequence() == null)
115 // TODO: fix this hinky sh!t
116 DatastoreItem dssync = dsReg.getDatastoreItemFor(mp.getTo());
119 // sync the dataset sequence, if it hasn't been done already.
120 // TODO: ensure real dataset sequence corresponding to getTo is
122 dssync = new Datasetsequence(
125 (mp.getMappedWidth() == mp.getWidth()) ? sequence
127 : ((mp.getMappedWidth() == 3) ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
128 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA),
132 // TODO: NOW add a mapping between new dataset sequence and sequence
133 // associated with the database reference
135 // dna mappings only...
136 // new jalview.io.vamsas.Sequencemapping(datastore, mp, sequence, ds);
143 log.debug("Ignoring non-dataset sequence mapping.");
147 public void updateFromDoc()
149 DbRef vobj = (DbRef) this.vobj;
150 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
151 jvobj.setAccessionId(vobj.getAccessionId());
152 jvobj.setSource(vobj.getSource());
153 jvobj.setVersion(vobj.getVersion());
155 if (vobj.getMapCount() > 0)
157 // TODO: Jalview ignores all the other maps
158 if (vobj.getMapCount() > 1)
160 jalview.bin.Cache.log
161 .debug("Ignoring additional mappings on DbRef: "
162 + jvobj.getSource() + ":" + jvobj.getAccessionId());
164 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
165 parsemapType(vobj.getMap(0)));
166 if (jvobj.getMap() == null || !mp.equals(jvobj.getMap()))
173 public void conflict()
175 DbRef vobj = (DbRef) this.vobj;
176 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
177 jalview.bin.Cache.log.debug("Conflict in dbentry update for "
178 + vobj.getAccessionId() + vobj.getSource() + " "
179 + vobj.getVorbaId());
180 // TODO Auto-generated method stub
184 public void addFromDocument()
186 DbRef vobj = (DbRef) this.vobj;
187 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
189 sq.addDBRef(jvobj = new jalview.datamodel.DBRefEntry(vobj.getSource()
190 .toString(), vobj.getVersion().toString(), vobj
191 .getAccessionId().toString()));
192 if (vobj.getMapCount() > 0)
194 // TODO: Jalview ignores all the other maps
195 if (vobj.getMapCount() > 1)
197 jalview.bin.Cache.log
198 .debug("Ignoring additional mappings on DbRef: "
199 + jvobj.getSource() + ":" + jvobj.getAccessionId());
201 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
202 parsemapType(vobj.getMap(0)));
205 // TODO: jalview ignores links and properties because it doesn't know what
208 bindjvvobj(jvobj, vobj);
211 public void addToDocument()
213 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
214 DbRef dbref = new DbRef();
215 bindjvvobj(jvobj, dbref);
216 dbref.setAccessionId(jvobj.getAccessionId());
217 dbref.setSource(jvobj.getSource());
218 dbref.setVersion(jvobj.getVersion());
219 sequence.addDbRef(dbref);
220 if (jvobj.getMap() != null)
222 jalview.datamodel.Mapping mp = jvobj.getMap();
223 if (mp.getMap() != null)
225 Map vMap = new Map();
226 initMapType(vMap, mp.getMap(), true);
232 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
233 + jvobj.getSrcAccString());