2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.io.vamsas;
20 import jalview.datamodel.DBRefEntry;
21 import jalview.datamodel.SequenceI;
22 import uk.ac.vamsas.objects.core.DataSet;
23 import uk.ac.vamsas.objects.core.DbRef;
24 import uk.ac.vamsas.objects.core.Map;
25 import uk.ac.vamsas.objects.core.Sequence;
26 import uk.ac.vamsas.objects.core.SequenceType;
27 import jalview.io.VamsasAppDatastore;
29 public class Dbref extends Rangetype
31 jalview.datamodel.SequenceI sq = null;
33 uk.ac.vamsas.objects.core.Sequence sequence = null;
37 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry,
38 jalview.datamodel.SequenceI sq2,
39 uk.ac.vamsas.objects.core.Sequence sequence2, DataSet dataset)
41 super(datastore, dbentry, DbRef.class);
42 // initialise object specific attributes
51 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq,
54 super(datastore, ref, jalview.datamodel.DBRefEntry.class);
57 ds = (DataSet) vdseq.getV_parent();
61 public void updateToDoc()
63 DbRef dbref = (DbRef) this.vobj;
64 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
65 dbref.setAccessionId(jvobj.getAccessionId());
66 dbref.setSource(jvobj.getSource());
67 dbref.setVersion(jvobj.getVersion());
68 if (jvobj.getMap() != null)
70 // Record mapping to external database coordinate system.
71 jalview.datamodel.Mapping mp = jvobj.getMap();
72 if (mp.getMap() != null)
75 if (dbref.getMapCount() == 0)
78 initMapType(vMap, mp.getMap(), true);
83 // we just update the data anyway.
84 vMap = dbref.getMap(0);
85 initMapType(vMap, mp.getMap(), true);
92 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
93 + jvobj.getSrcAccString());
99 * ugly hack to try to get the embedded sequences within a database reference
100 * to be stored in the document's dataset.
104 private void updateMapTo(jalview.datamodel.Mapping mp)
107 .info("Performing updateMapTo remove this message when we know what we're doing.");
108 // TODO determine how sequences associated with database mappings are stored
110 if (mp != null && mp.getTo() != null)
112 if (mp.getTo().getDatasetSequence() == null)
114 // TODO: fix this hinky sh!t
115 DatastoreItem dssync = dsReg.getDatastoreItemFor(mp.getTo());
118 // sync the dataset sequence, if it hasn't been done already.
119 // TODO: ensure real dataset sequence corresponding to getTo is
121 dssync = new Datasetsequence(
124 (mp.getMappedWidth() == mp.getWidth()) ? sequence
126 : ((mp.getMappedWidth() == 3) ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
127 : uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA),
131 // TODO: NOW add a mapping between new dataset sequence and sequence
132 // associated with the database reference
134 // dna mappings only...
135 // new jalview.io.vamsas.Sequencemapping(datastore, mp, sequence, ds);
142 log.debug("Ignoring non-dataset sequence mapping.");
146 public void updateFromDoc()
148 DbRef vobj = (DbRef) this.vobj;
149 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
150 jvobj.setAccessionId(vobj.getAccessionId());
151 jvobj.setSource(vobj.getSource());
152 jvobj.setVersion(vobj.getVersion());
154 if (vobj.getMapCount() > 0)
156 // TODO: Jalview ignores all the other maps
157 if (vobj.getMapCount() > 1)
159 jalview.bin.Cache.log
160 .debug("Ignoring additional mappings on DbRef: "
161 + jvobj.getSource() + ":" + jvobj.getAccessionId());
163 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
164 parsemapType(vobj.getMap(0)));
165 if (jvobj.getMap() == null || !mp.equals(jvobj.getMap()))
172 public void conflict()
174 DbRef vobj = (DbRef) this.vobj;
175 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
176 jalview.bin.Cache.log.debug("Conflict in dbentry update for "
177 + vobj.getAccessionId() + vobj.getSource() + " "
178 + vobj.getVorbaId());
179 // TODO Auto-generated method stub
183 public void addFromDocument()
185 DbRef vobj = (DbRef) this.vobj;
186 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
188 sq.addDBRef(jvobj = new jalview.datamodel.DBRefEntry(vobj.getSource()
189 .toString(), vobj.getVersion().toString(), vobj
190 .getAccessionId().toString()));
191 if (vobj.getMapCount() > 0)
193 // TODO: Jalview ignores all the other maps
194 if (vobj.getMapCount() > 1)
196 jalview.bin.Cache.log
197 .debug("Ignoring additional mappings on DbRef: "
198 + jvobj.getSource() + ":" + jvobj.getAccessionId());
200 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(
201 parsemapType(vobj.getMap(0)));
204 // TODO: jalview ignores links and properties because it doesn't know what
207 bindjvvobj(jvobj, vobj);
210 public void addToDocument()
212 DBRefEntry jvobj = (DBRefEntry) this.jvobj;
213 DbRef dbref = new DbRef();
214 bindjvvobj(jvobj, dbref);
215 dbref.setAccessionId(jvobj.getAccessionId());
216 dbref.setSource(jvobj.getSource());
217 dbref.setVersion(jvobj.getVersion());
218 sequence.addDbRef(dbref);
219 if (jvobj.getMap() != null)
221 jalview.datamodel.Mapping mp = jvobj.getMap();
222 if (mp.getMap() != null)
224 Map vMap = new Map();
225 initMapType(vMap, mp.getMap(), true);
231 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "
232 + jvobj.getSrcAccString());