JAL-2738 use GeneLocus extends DBRefEntry to hold chromosomal mappings
[jalview.git] / src / jalview / datamodel / GeneLocus.java
1 package jalview.datamodel;
2
3 import jalview.util.MapList;
4
5 /**
6  * A specialisation of DBRefEntry used to hold the chromosomal coordinates for a
7  * (typically gene) sequence
8  * <ul>
9  * <li>field <code>source</code> is used to hold a species id e.g. human</li>
10  * <li>field <code>version</code> is used to hold assembly id e.g GRCh38</li>
11  * <li>field <code>accession</code> is used to hold the chromosome id</li>
12  * <li>field <code>map</code> is used to hold the mapping from sequence to
13  * chromosome coordinates</li>
14  * </ul>
15  * 
16  * @author gmcarstairs
17  *
18  */
19 public class GeneLocus extends DBRefEntry implements GeneLociI
20 {
21   /**
22    * Constructor adapts species, assembly, chromosome to DBRefEntry source,
23    * version, accession, respectively, and saves the mapping of sequence to
24    * chromosomal coordinates
25    * 
26    * @param speciesId
27    * @param assemblyId
28    * @param chromosomeId
29    * @param mapping
30    */
31   public GeneLocus(String speciesId, String assemblyId, String chromosomeId,
32           Mapping mapping)
33   {
34     super(speciesId, assemblyId, chromosomeId, mapping);
35   }
36
37   /**
38    * Constructor
39    * 
40    * @param speciesId
41    * @param assemblyId
42    * @param chromosomeId
43    */
44   public GeneLocus(String speciesId, String assemblyId, String chromosomeId)
45   {
46     this(speciesId, assemblyId, chromosomeId, null);
47   }
48
49   @Override
50   public boolean equals(Object o)
51   {
52     return o instanceof GeneLocus && super.equals(o);
53   }
54
55   @Override
56   public MapList getMapping()
57   {
58     return map == null ? null : map.getMap();
59   }
60
61   /**
62    * Answers the species identifier e.g. "human", stored as field <code>source</code> of
63    * DBRefEntry
64    */
65   @Override
66   public String getSpeciesId()
67   {
68     return getSource();
69   }
70
71   /**
72    * Answers the genome assembly id e.g. "GRCh38", stored as field
73    * <code>version</code> of DBRefEntry
74    */
75   @Override
76   public String getAssemblyId()
77   {
78     return getVersion();
79   }
80
81   /**
82    * Answers the chromosome identifier e.g. "X", stored as field
83    * <code>accession</code> of DBRefEntry
84    */
85   @Override
86   public String getChromosomeId()
87   {
88     return getAccessionId();
89   }
90
91 }