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.bin.Cache;
24 import jalview.datamodel.DBRefEntry;
25 import jalview.datamodel.Mapping;
26 import jalview.datamodel.SequenceI;
27 import jalview.io.VamsasAppDatastore;
29 import uk.ac.vamsas.objects.core.DataSet;
30 import uk.ac.vamsas.objects.core.DbRef;
31 import uk.ac.vamsas.objects.core.Map;
32 import uk.ac.vamsas.objects.core.Sequence;
33 import uk.ac.vamsas.objects.utils.SymbolDictionary;
35 public class Dbref extends Rangetype
39 uk.ac.vamsas.objects.core.Sequence sequence = null;
43 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry,
44 SequenceI sq2, uk.ac.vamsas.objects.core.Sequence sequence2,
47 super(datastore, dbentry, DbRef.class);
48 // initialise object specific attributes
57 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq,
60 super(datastore, ref, DBRefEntry.class);
63 ds = (DataSet) vdseq.getV_parent();
67 public void updateToDoc()
69 DbRef dbref = (DbRef) this.vobj;
70 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
71 dbref.setAccessionId(jvobj.getAccessionId());
72 dbref.setSource(jvobj.getSource());
73 dbref.setVersion(jvobj.getVersion());
74 if (jvobj.getMap() != null)
76 // Record mapping to external database coordinate system.
77 Mapping mp = jvobj.getMap();
78 if (mp.getMap() != null)
81 if (dbref.getMapCount() == 0)
84 initMapType(vMap, mp.getMap(), true);
89 // we just update the data anyway.
90 vMap = dbref.getMap(0);
91 initMapType(vMap, mp.getMap(), true);
98 Cache.log.debug("Ignoring mapless DbRef.Map "
99 + jvobj.getSrcAccString());
105 * ugly hack to try to get the embedded sequences within a database reference
106 * to be stored in the document's dataset.
110 private void updateMapTo(Mapping mp)
112 log.info("Performing updateMapTo remove this message when we know what we're doing.");
113 // TODO determine how sequences associated with database mappings are stored
115 if (mp != null && mp.getTo() != null)
117 if (mp.getTo().getDatasetSequence() == null)
119 // TODO: fix this hinky sh!t
120 DatastoreItem dssync = dsReg.getDatastoreItemFor(mp.getTo());
123 // sync the dataset sequence, if it hasn't been done already.
124 // TODO: ensure real dataset sequence corresponding to getTo is
126 dssync = new Datasetsequence(
129 (mp.getMappedWidth() == mp.getWidth()) ? sequence
131 : ((mp.getMappedWidth() == 3) ? SymbolDictionary.STANDARD_NA
132 : SymbolDictionary.STANDARD_AA),
136 // TODO: NOW add a mapping between new dataset sequence and sequence
137 // associated with the database reference
139 // dna mappings only...
140 // new jalview.io.vamsas.Sequencemapping(datastore, mp, sequence, ds);
147 log.debug("Ignoring non-dataset sequence mapping.");
151 public void updateFromDoc()
153 DbRef vobj = (DbRef) this.vobj;
154 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
155 jvobj.setAccessionId(vobj.getAccessionId());
156 jvobj.setSource(vobj.getSource());
157 jvobj.setVersion(vobj.getVersion());
159 if (vobj.getMapCount() > 0)
161 // TODO: Jalview ignores all the other maps
162 if (vobj.getMapCount() > 1)
165 .debug("Ignoring additional mappings on DbRef: "
166 + jvobj.getSource() + ":" + jvobj.getAccessionId());
168 Mapping mp = new Mapping(parsemapType(vobj.getMap(0)));
169 if (jvobj.getMap() == null || !mp.equals(jvobj.getMap()))
176 public void conflict()
178 DbRef vobj = (DbRef) this.vobj;
179 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
180 Cache.log.debug("Conflict in dbentry update for "
181 + vobj.getAccessionId() + vobj.getSource() + " "
182 + vobj.getVorbaId());
183 // TODO Auto-generated method stub
187 public void addFromDocument()
189 DbRef vobj = (DbRef) this.vobj;
190 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
192 sq.addDBRef(jvobj = new DBRefEntry(vobj.getSource()
193 .toString(), vobj.getVersion().toString(), vobj
194 .getAccessionId().toString()));
195 if (vobj.getMapCount() > 0)
197 // TODO: Jalview ignores all the other maps
198 if (vobj.getMapCount() > 1)
201 .debug("Ignoring additional mappings on DbRef: "
202 + jvobj.getSource() + ":" + jvobj.getAccessionId());
204 Mapping mp = new Mapping(
205 parsemapType(vobj.getMap(0)));
208 // TODO: jalview ignores links and properties because it doesn't know what
211 bindjvvobj(jvobj, vobj);
214 public void addToDocument()
216 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
217 DbRef dbref = new DbRef();
218 bindjvvobj(jvobj, dbref);
219 dbref.setAccessionId(jvobj.getAccessionId());
220 dbref.setSource(jvobj.getSource());
221 dbref.setVersion(jvobj.getVersion());
222 sequence.addDbRef(dbref);
223 if (jvobj.getMap() != null)
225 Mapping mp = jvobj.getMap();
226 if (mp.getMap() != null)
228 Map vMap = new Map();
229 initMapType(vMap, mp.getMap(), true);
235 Cache.log.debug("Ignoring mapless DbRef.Map "
236 + jvobj.getSrcAccString());