672d6b4650e3f0794932a194d029ae8b316f5163
[jalview.git] / src / jalview / api / DBRefEntryI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.api;
22
23 import jalview.datamodel.Mapping;
24
25 //JBPComment: this is a datamodel API - so it should be in datamodel (it's a peer of SequenceI)
26
27 public interface DBRefEntryI
28 {
29   public boolean equalRef(DBRefEntryI entry);
30
31   /**
32    * 
33    * @return Source DB name for this entry
34    */
35   public String getSource();
36
37   /**
38    * 
39    * @return Accession Id for this entry
40    */
41   public String getAccessionId();
42
43   /**
44    * 
45    * @param accessionId
46    *          Accession Id for this entry
47    */
48   public void setAccessionId(String accessionId);
49
50   /**
51    * 
52    * @param source
53    *          Source DB name for this entry
54    */
55   public void setSource(String source);
56
57   /**
58    * 
59    * @return Source DB version for this entry
60    */
61   public String getVersion();
62
63   /**
64    * 
65    * @param version
66    *          Source DB version for this entry
67    */
68   public void setVersion(String version);
69
70   /**
71    * access a mapping, if present that can be used to map positions from the
72    * associated dataset sequence to the DBRef's sequence frame.
73    * 
74    * @return null or a valid mapping.
75    */
76   public Mapping getMap();
77
78   /**
79    * Answers true if this object is either equivalent to, or can be 'improved'
80    * by, the given entry. Specifically, answers true if
81    * <ul>
82    * <li>source and accession are identical</li>
83    * <li>version is identical, or this version is of the format "someSource:0",
84    * in which case the version for the other entry replaces it</li>
85    * <li>mappings are not compared but if this entry has no mapping, replace
86    * with that for the other entry</li>
87    * </ul>
88    * 
89    * @param otherEntry
90    * @return
91    */
92   public boolean updateFrom(DBRefEntryI otherEntry);
93
94   /**
95    * Answers true if the ref looks like a primary (direct) database reference.
96    * <br>
97    * The only way a dbref's mappings can be fully verified is via the local
98    * sequence frame, so rather than use isPrimaryCandidate directly, please use
99    * SequenceI.getPrimaryDbRefs(). <br>
100    * Primary references indicate the local sequence data directly corresponds
101    * with the database record. All other references are secondary. Direct
102    * references indicate that part or all of the local sequence data can be
103    * mapped with another sequence, enabling annotation transfer.
104    * Cross-references indicate the local sequence data can be corresponded to
105    * some other linear coordinate system via a transformation. <br>
106    * This method is also sufficient to distinguish direct DBRefEntry mappings
107    * from other relationships - e.g. coding relationships (imply a 1:3/3:1
108    * mapping), but not transcript relationships, which imply a (possibly
109    * non-contiguous) 1:1 mapping.
110    *
111    * @return true if this reference provides a primary accession for the
112    *         associated sequence object
113    */
114   public boolean isPrimaryCandidate();
115 }