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 public class DBRefEntry
25 String source = "", version = "", accessionId = "";
28 * maps from associated sequence to the database sequence's coordinate system
37 public DBRefEntry(String source, String version, String accessionId)
39 this(source, version, accessionId, null);
45 * canonical source (uppercase only)
47 * (source dependent version string)
49 * (source dependent accession number string)
51 * (mapping from local sequence numbering to source accession
54 public DBRefEntry(String source, String version, String accessionId,
57 this.source = source.toUpperCase();
58 this.version = version;
59 this.accessionId = accessionId;
63 public DBRefEntry(DBRefEntry entry)
66 (entry.source == null ? "" : new String(entry.source)),
67 (entry.version == null ? "" : new String(entry.version)),
68 (entry.accessionId == null ? "" : new String(entry.accessionId)),
69 (entry.map == null ? null : new Mapping(entry.map)));
73 public boolean equals(Object o)
75 // TODO should also override hashCode to ensure equal objects have equal
77 if (o == null || !(o instanceof DBRefEntry))
81 DBRefEntry entry = (DBRefEntry) o;
87 && ((map == null && entry.map == null) || (map != null
88 && entry.map != null && map.equals(entry.map))))
96 * test for similar DBRef attributes, except for the map object.
99 * @return true if source, accession and version are equal with those of entry
101 public boolean equalRef(DBRefEntry entry)
111 if ((source != null && entry.source != null && source
112 .equalsIgnoreCase(entry.source))
113 && (accessionId != null && entry.accessionId != null && accessionId
114 .equalsIgnoreCase(entry.accessionId))
115 && (version != null && entry.version != null && version
116 .equalsIgnoreCase(entry.version)))
123 public String getSource()
128 public String getVersion()
133 public String getAccessionId()
140 * the accessionId to set
142 public void setAccessionId(String accessionId)
144 this.accessionId = accessionId;
151 public void setSource(String source)
153 this.source = source;
160 public void setVersion(String version)
162 this.version = version;
168 public Mapping getMap()
177 public void setMap(Mapping map)
182 public boolean hasMap()
189 * @return source+":"+accessionId
191 public String getSrcAccString()
193 return ((source != null) ? source : "") + ":"
194 + ((accessionId != null) ? accessionId : "");
197 public String toString()
199 return getSrcAccString();