debugged mappings and translated sequence recovery
[jalview.git] / src / jalview / datamodel / DBRefEntry.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
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.
9  *
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.
14  *
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
18  */
19 package jalview.datamodel;
20
21 public class DBRefEntry
22 {
23   String source="", version="", accessionId="";
24   /**
25    * maps from associated sequence to the database sequence's coordinate system
26    */
27   Mapping map=null;
28   public DBRefEntry() {
29       
30   }
31   public DBRefEntry(String source, String version, String accessionId)
32   {
33     this(source, version, accessionId, null);
34   }
35   public DBRefEntry(String source, String version, String accessionId, Mapping map) {
36     this.source = source;
37     this.version = version;
38     this.accessionId = accessionId;
39     this.map = map;
40   }
41   public DBRefEntry(DBRefEntry entry)
42   {
43     this(new String(entry.source), new String(entry.version), new String(entry.accessionId), new Mapping(entry.map));
44   }
45   public boolean equals(DBRefEntry entry) {
46       if (entry==this)
47           return true;
48       if (entry==null)
49           return false;
50       if ((source!=null && entry.source!=null && source.equals(entry.source))
51           &&
52           (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId))
53           &&
54           (version!=null && entry.version!=null && version.equals(entry.version))
55           &&
56           ((map==null && entry.map==null) || (map!=null && entry.map!=null && map.equals(entry.map)))) {
57               return true;
58           }
59       return false;
60   }
61   public String getSource()
62   {
63     return source;
64   }
65
66   public String getVersion()
67   {
68     return version;
69   }
70
71   public String getAccessionId()
72   {
73     return accessionId;
74   }
75 /**
76  * @param accessionId the accessionId to set
77  */
78 public void setAccessionId(String accessionId) {
79     this.accessionId = accessionId;
80 }
81 /**
82  * @param source the source to set
83  */
84 public void setSource(String source) {
85     this.source = source;
86 }
87 /**
88  * @param version the version to set
89  */
90 public void setVersion(String version) {
91     this.version = version;
92 }
93 /**
94  * @return the map
95  */
96 public Mapping getMap() {
97     return map;
98 }
99 /**
100  * @param map the map to set
101  */
102 public void setMap(Mapping map) {
103     this.map = map;
104 }
105 public boolean hasMap()
106 {
107   // TODO Auto-generated method stub
108   return map!=null;
109 }
110 /**
111  * 
112  * @return source+":"+accessionId
113  */
114 public String getSrcAccString()
115 {
116   return ((source!=null) ? source : "")
117     + ":" + ((accessionId!=null) ? accessionId : "");
118 }
119 }