2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 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.DbRef;
24 import uk.ac.vamsas.objects.core.Map;
25 import uk.ac.vamsas.objects.core.Sequence;
26 import jalview.io.VamsasAppDatastore;
28 public class Dbref extends Rangetype
30 jalview.datamodel.SequenceI sq = null;
31 uk.ac.vamsas.objects.core.Sequence sequence = null;
33 DBRefEntry dbentry=null;
34 public Dbref(VamsasAppDatastore datastore, DBRefEntry dbentry, jalview.datamodel.SequenceI sq2, uk.ac.vamsas.objects.core.Sequence sequence2)
37 dbref = (DbRef) getjv2vObj(dbentry);
40 this.dbentry = dbentry;
45 if (dbref.isUpdated())
56 public Dbref(VamsasAppDatastore datastore, DbRef ref, Sequence vdseq, SequenceI dsseq)
62 dbentry = (jalview.datamodel.DBRefEntry) getvObj2jv(dbref);
67 if (dbref.isUpdated())
76 // TODO: verify and update dbrefs in vamsas document
77 // there will be trouble when a dataset sequence is modified to
78 // contain more residues than were originally referenced - we must
79 // then make a number of dataset sequence entries - this info is already stored
80 jalview.bin.Cache.log.debug("TODO verify update of dataset sequence database references.");
83 private void conflict()
85 jalview.bin.Cache.log.debug("Conflict in dbentry update for "+dbref.getAccessionId()+dbref.getSource()+" "+dbref.getVorbaId());
86 // TODO Auto-generated method stub
89 private void addFromDocument()
92 sq.addDBRef(dbentry = new jalview.datamodel.DBRefEntry
94 dbref.getSource().toString(),
95 dbref.getVersion().toString(),
96 dbref.getAccessionId().toString()));
97 if (dbref.getMapCount()>0)
99 // TODO: Jalview ignores all the other maps
100 if (dbref.getMapCount()>1)
102 jalview.bin.Cache.log.debug("Ignoring additional mappings on DbRef: "+dbentry.getSource()+":"+dbentry.getAccessionId());
104 jalview.datamodel.Mapping mp = new jalview.datamodel.Mapping(parsemapType(dbref.getMap(0)));
107 // TODO: jalview ignores links and properties because it doesn't know what to do with them.
109 bindjvvobj(dbentry, dbref);
113 DbRef dbref = new DbRef();
114 bindjvvobj(dbentry, dbref);
115 dbref.setAccessionId(dbentry.getAccessionId());
116 dbref.setSource(dbentry.getSource());
117 dbref.setVersion(dbentry.getVersion());
118 if (dbentry.getMap()!=null)
120 jalview.datamodel.Mapping mp = dbentry.getMap();
121 if (mp.getMap()!=null)
123 Map vMap = new Map();
124 initMapType(vMap, mp.getMap(), true);
127 jalview.bin.Cache.log.debug("Ignoring mapless DbRef.Map "+dbentry.getSrcAccString());
130 sequence.addDbRef(dbref);