5d0db6cb0e314c0fa191265ca57c5541f21459f9
[jalview.git] / src / jalview / io / xdb / genbank / GenBankLocation.java
1 package jalview.io.xdb.genbank;
2
3 /**
4  * The location contains at least one sequence location descriptor and may
5  * contain one or more operators with one or more sequence location descriptors.
6  * Base numbers refer to the numbering in the entry. This numbering designates
7  * the first base (5' end) of the presented sequence as base 1.
8  * Base locations beyond the range of the presented sequence may not be used in
9  * location descriptors, the only exception being location in a remote entry (see
10  * 3.5.2.1, e).
11  *
12  * Location operators and descriptors are discussed in more detail below.
13  *
14  *  3.5.2.1 Location descriptors
15  * The location descriptor can be one of the following:
16  * (a) a single base number
17  * (b) a site between two indicated adjoining bases
18  * (c) a single base chosen from within a specified range of bases (not allowed for new
19  *     entries)
20  * (d) the base numbers delimiting a sequence span
21  * (e) a remote entry identifier followed by a local location descriptor
22  *     (i.e., a-d)
23  *
24  * A site between two adjoining nucleotides, such as endonucleolytic cleavage
25  * site, is indicated by listing the two points separated by a carat (^). The
26  * permitted formats for this descriptor are n^n+1 (for example 55^56), or, for
27  * circular molecules, n^1, where "n" is the full length of the molecule, ie
28  * 1000^1 for circular molecule with length 1000.
29  *
30  * A single base chosen from a range of bases is indicated by the first base
31  * number and the last base number of the range separated by a single period
32  * (e.g., '12.21' indicates a single base taken from between the indicated
33  * points). From October 2006 the usage of this descriptor is restricted :
34  * it is illegal to use "a single base from a range" (c) either on its own or
35  * in combination with the "sequence span" (d) descriptor for newly created entries.
36  * The existing entries where such descriptors exist are going to be retrofitted.
37  *
38  * Sequence spans are indicated by the starting base number and the ending base
39  * number separated by two periods (e.g., '34..456'). The '<' and '>' symbols may
40  * be used with the starting and ending base numbers to indicate that an end
41  * point is beyond the specified base number. The starting and ending base
42  * positions can be represented as distinct base numbers ('34..456') or a site
43  * between two indicated adjoining bases.
44  *
45  * A location in a remote entry (not the entry to which the feature table
46  * belongs) can be specified by giving  the accession-number and sequence version
47  * of the remote entry, followed by a colon ":", followed by a location
48  * descriptor which applies to that entry's sequence (i.e. J12345.1:1..15, see
49  * also examples below)
50  *
51  * 3.5.2.2 Operators
52  *
53  * The location operator is a prefix that specifies what must be done to the
54  * indicated sequence to find or construct the location corresponding to the
55  * feature. A list of operators is given below with their definitions and most
56  * common format.
57  *
58  * complement(location)
59  * Find the complement of the presented sequence in the span specified by "
60  * location" (i.e., read the complement of the presented strand in its 5'-to-3'
61  * direction)
62  *
63  * join(location,location, ... location)
64  * The indicated elements should be joined (placed end-to-end) to form one
65  * contiguous sequence
66  *
67  * order(location,location, ... location)
68  * The elements can be found in the
69  * specified order (5' to 3' direction), but nothing is implied about the
70  * reasonableness about joining them
71  *
72  * Note : location operator "complement" can be used in combination with either "
73  * join" or "order" within the same location; combinations of "join" and "order"
74  * within the same location (nested operators) are illegal.
75  *
76  * 3.5.3 Location examples
77  *
78  * The following is a list of common location descriptors with their meanings:
79  * Location                  Description
80  * 467                       Points to a single base in the presented sequence
81  * 340..565                  Points to a continuous range of bases bounded by and
82  *                           including the starting and ending bases
83  * <345..500                 Indicates that the exact lower boundary point of a feature
84  *                           is unknown.  The location begins at some  base previous to
85  *                           the first base specified (which need not be contained in
86  *                           the presented sequence) and continues to and includes the
87  *                           ending base
88  * <1..888                   The feature starts before the first sequenced base and
89  *                           continues to and includes base 888
90  * 1..>888                   The feature starts at the first sequenced base and
91  *                           continues beyond base 888
92  * 102.110                   Indicates that the exact location is unknown but that it is
93  *                           one of the bases between bases 102 and 110, inclusive
94  * 123^124                   Points to a site between bases 123 and 124
95  * join(12..78,134..202)     Regions 12 to 78 and 134 to 202 should be joined to form
96  *                           one contiguous sequence
97  * complement(34..126)       Start at the base complementary to 126 and finish at the
98  *                           base complementary to base 34 (the feature is on the strand
99  *                           complementary to the presented strand)
100  * complement(join(2691..4571,4918..5163))
101  *                           Joins regions 2691 to 4571 and 4918 to 5163, then
102  *                           complements the joined segments (the feature is on the
103  *                           strand complementary to the presented strand)
104  * join(complement(4918..5163),complement(2691..4571))
105  *                           Complements regions 4918 to 5163 and 2691 to 4571, then
106  *                           joins the complemented segments (the feature is on the
107  *                           strand complementary to the presented strand)
108  * J00194.1:100..202         Points to bases 100 to 202, inclusive, in the entry (in
109  *                           this database) with primary accession number 'J00194'
110  * join(1..100,J00194.1:100..202)
111  *                           Joins region 1..100 of the existing entry with the region
112  *                           100..202 of remote entry J00194
113  * 
114  *
115  */
116 public abstract class GenBankLocation {
117     // the location is complement strand?
118     private boolean complement = false;
119
120     public GenBankLocation() {
121     }
122
123     /**
124      * The minor location in genome sequence
125      *
126      * @return position
127      */
128     public abstract int getMinor();
129
130     /**
131      * The major location in genome sequence
132      *
133      * @return position
134      */
135     public abstract int getMajor();
136
137     /**
138      * @return the complement
139      */
140     public boolean isComplement() {
141         return complement;
142     }
143
144     /**
145      * @param complement the complement to set
146      */
147     public void setComplement(boolean complement) {
148         this.complement = complement;
149     }
150 }