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
40 public DBRefEntry(String source, String version, String accessionId)
42 this(source, version, accessionId, null);
48 * canonical source (uppercase only)
50 * (source dependent version string)
52 * (source dependent accession number string)
54 * (mapping from local sequence numbering to source accession
57 public DBRefEntry(String source, String version, String accessionId,
60 this.source = source.toUpperCase();
61 this.version = version;
62 this.accessionId = accessionId;
66 public DBRefEntry(DBRefEntry entry)
69 (entry.source == null ? "" : new String(entry.source)),
70 (entry.version == null ? "" : new String(entry.version)),
71 (entry.accessionId == null ? "" : new String(entry.accessionId)),
72 (entry.map == null ? null : new Mapping(entry.map)));
76 public boolean equals(Object o)
78 // TODO should also override hashCode to ensure equal objects have equal
80 if (o == null || !(o instanceof DBRefEntry))
84 DBRefEntry entry = (DBRefEntry) o;
90 && ((map == null && entry.map == null) || (map != null
91 && entry.map != null && map.equals(entry.map))))
99 * test for similar DBRef attributes, except for the map object.
102 * @return true if source, accession and version are equal with those of entry
105 public boolean equalRef(DBRefEntryI entry)
116 && (source != null && entry.getSource() != null && source
117 .equalsIgnoreCase(entry.getSource()))
118 && (accessionId != null && entry.getAccessionId() != null && accessionId
119 .equalsIgnoreCase(entry.getAccessionId()))
120 && (version != null && entry.getVersion() != null && version
121 .equalsIgnoreCase(entry.getVersion())))
129 public String getSource()
135 public String getVersion()
141 public String getAccessionId()
148 * the accessionId to set
151 public void setAccessionId(String accessionId)
153 this.accessionId = accessionId;
161 public void setSource(String source)
163 this.source = source;
171 public void setVersion(String version)
173 this.version = version;
179 public Mapping getMap()
188 public void setMap(Mapping map)
193 public boolean hasMap()
200 * @return source+":"+accessionId
202 public String getSrcAccString()
204 return ((source != null) ? source : "") + ":"
205 + ((accessionId != null) ? accessionId : "");
209 public String toString()
211 return getSrcAccString();
214 public int getStartRes()
219 public void setStartRes(int startRes)
221 this.startRes = startRes;
224 public int getEndRes()
229 public void setEndRes(int endRes)
231 this.endRes = endRes;