JAL-2106 DBRefEntry.isPrimary() minimal test & implementation
[jalview.git] / src / jalview / api / DBRefEntryI.java
1 package jalview.api;
2
3 import jalview.datamodel.Mapping;
4
5 //JBPComment: this is a datamodel API - so it should be in datamodel (it's a peer of SequenceI)
6
7 public interface DBRefEntryI
8 {
9   public boolean equalRef(DBRefEntryI entry);
10
11   /**
12    * 
13    * @return Source DB name for this entry
14    */
15   public String getSource();
16
17   /**
18    * 
19    * @return Accession Id for this entry
20    */
21   public String getAccessionId();
22
23   /**
24    * 
25    * @param accessionId
26    *          Accession Id for this entry
27    */
28   public void setAccessionId(String accessionId);
29
30   /**
31    * 
32    * @param source
33    *          Source DB name for this entry
34    */
35   public void setSource(String source);
36
37   /**
38    * 
39    * @return Source DB version for this entry
40    */
41   public String getVersion();
42
43   /**
44    * 
45    * @param version
46    *          Source DB version for this entry
47    */
48   public void setVersion(String version);
49
50   /**
51    * access a mapping, if present that can be used to map positions from the
52    * associated dataset sequence to the DBRef's sequence frame.
53    * 
54    * @return null or a valid mapping.
55    */
56   public Mapping getMap();
57
58   /**
59    * Answers true if this object is either equivalent to, or can be 'improved'
60    * by, the given entry. Specifically, answers true if
61    * <ul>
62    * <li>source and accession are identical</li>
63    * <li>version is identical, or this version is of the format "someSource:0",
64    * in which case the version for the other entry replaces it</li>
65    * <li>mappings are not compared but if this entry has no mapping, replace
66    * with that for the other entry</li>
67    * </ul>
68    * 
69    * @param otherEntry
70    * @return
71    */
72   public boolean updateFrom(DBRefEntryI otherEntry);
73
74   /**
75    * Method to distinguish between direct and indirect database references
76    * 
77    * primary references indicate the local sequence data directly corresponds
78    * with the database record. All other references are secondary. direct
79    * references indicate that part or all of the local sequence data can be
80    * mapped with another sequence, enabling annotation transfer.
81    * cross-references indicate the local sequence data can be corresponded to
82    * some other linear coordinate system via a transformation.
83    * 
84    * This method is also sufficient to distinguish direct DBRefEntry mappings
85    * from other relationships - e.g. coding relationships (imply a 1:3/3:1
86    * mapping), but not transcript relationships, which imply a (possibly
87    * non-contiguous) 1:1 mapping
88    * 
89    * The only way a dbref's mappings can be fully verified is via the local
90    * sequence frame, so rather than use isPrimary directly, please use
91    * SequenceI.getPrimaryDbRefs()
92    *
93    * @return true if this reference provides a primary accession for the
94    *         associated sequence object
95    */
96   public boolean isPrimary();
97 }