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.datamodel;
23 import jalview.api.DBRefEntryI;
25 public class DBRefEntry implements DBRefEntryI
27 String source = "", version = "", accessionId = "";
29 private int startRes, endRes;
31 * maps from associated sequence to the database sequence's coordinate system
41 public DBRefEntry(String source, String version, String accessionId)
43 this(source, version, accessionId, null);
49 * canonical source (uppercase only)
51 * (source dependent version string)
53 * (source dependent accession number string)
55 * (mapping from local sequence numbering to source accession
58 public DBRefEntry(String source, String version, String accessionId,
61 this.source = source.toUpperCase();
62 this.version = version;
63 this.accessionId = accessionId;
67 public DBRefEntry(DBRefEntryI entry)
69 this((entry.getSource() == null ? "" : new String(entry.getSource())),
70 (entry.getVersion() == null ? "" : new String(
72 (entry.getAccessionId() == null ? "" : new String(
73 entry.getAccessionId())),
74 (entry.getMap() == null ? null : new Mapping(entry.getMap())));
78 public boolean equals(Object o)
80 // TODO should also override hashCode to ensure equal objects have equal
82 if (o == null || !(o instanceof DBRefEntry))
86 DBRefEntry entry = (DBRefEntry) o;
92 && ((map == null && entry.map == null) || (map != null
93 && entry.map != null && map.equals(entry.map))))
101 * test for similar DBRef attributes, except for the map object.
104 * @return true if source, accession and version are equal with those of entry
107 public boolean equalRef(DBRefEntryI entry)
118 && (source != null && entry.getSource() != null && source
119 .equalsIgnoreCase(entry.getSource()))
120 && (accessionId != null && entry.getAccessionId() != null && accessionId
121 .equalsIgnoreCase(entry.getAccessionId()))
122 && (version != null && entry.getVersion() != null && version
123 .equalsIgnoreCase(entry.getVersion())))
131 public String getSource()
137 public String getVersion()
143 public String getAccessionId()
150 public void setAccessionId(String accessionId)
152 this.accessionId = accessionId;
157 public void setSource(String source)
159 this.source = source;
164 public void setVersion(String version)
166 this.version = version;
171 public Mapping getMap()
180 public void setMap(Mapping map)
185 public boolean hasMap()
192 * @return source+":"+accessionId
194 public String getSrcAccString()
196 return ((source != null) ? source : "") + ":"
197 + ((accessionId != null) ? accessionId : "");
201 public String toString()
203 return getSrcAccString();
207 public int getStartRes()
213 public void setStartRes(int startRes)
215 this.startRes = startRes;
219 public int getEndRes()
225 public void setEndRes(int endRes)
227 this.endRes = endRes;