2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.io.vamsas;
21 import jalview.datamodel.DBRefEntry;
22 import jalview.datamodel.SequenceI;
23 import uk.ac.vamsas.objects.core.DataSet;
24 import uk.ac.vamsas.objects.core.DbRef;
25 import uk.ac.vamsas.objects.core.Map;
26 import uk.ac.vamsas.objects.core.Sequence;
27 import uk.ac.vamsas.objects.core.SequenceType;
28 import jalview.io.VamsasAppDatastore;
30 public class Dbref extends Rangetype
32 jalview.datamodel.SequenceI sq = null;
34 uk.ac.vamsas.objects.core.Sequence sequence = null;
38 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry,
39 jalview.datamodel.SequenceI sq2,
40 uk.ac.vamsas.objects.core.Sequence sequence2, DataSet dataset)
42 super(datastore, dbentry, DbRef.class);
43 // initialise object specific attributes
52 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq,
55 super(datastore, ref, jalview.datamodel.DBRefEntry.class);
58 ds = (DataSet) vdseq.getV_parent();
62 public void updateToDoc()
64 DbRef dbref = (DbRef) this.vobj;
65 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
66 dbref.setAccessionId(jvobj.getAccessionId());
67 dbref.setSource(jvobj.getSource());
68 dbref.setVersion(jvobj.getVersion());
69 if (jvobj.getMap() != null)
71 // Record mapping to external database coordinate system.
72 jalview.datamodel.Mapping mp = jvobj.getMap();
73 if (mp.getMap() != null)
76 if (dbref.getMapCount() == 0)
79 initMapType(vMap, mp.getMap(), true);
84 // we just update the data anyway.
85 vMap = dbref.getMap(0);
86 initMapType(vMap, mp.getMap(), true);
93 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
94 + jvobj.getSrcAccString());
100 * ugly hack to try to get the embedded sequences within a database reference
101 * to be stored in the document's dataset.
105 private void updateMapTo(jalview.datamodel.Mapping mp)
108 .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());