878042dc27da0beb8973a8471a57badd75d89b70
[jalview.git] / src / jalview / datamodel / xdb / embl / EmblFeatureLocations.java
1 package jalview.datamodel.xdb.embl;\r
2 \r
3 import java.util.Iterator;\r
4 import java.util.Vector;\r
5 \r
6 public class EmblFeatureLocations {\r
7     Vector locElements;\r
8     String locationType;\r
9     boolean locationComplement;\r
10     /**\r
11      * @return the locationComplement\r
12      */\r
13     public boolean isLocationComplement() {\r
14         return locationComplement;\r
15     }\r
16     /**\r
17      * @param locationComplement the locationComplement to set\r
18      */\r
19     public void setLocationComplement(boolean locationComplement) {\r
20         this.locationComplement = locationComplement;\r
21     }\r
22     /**\r
23      * @return the locationType\r
24      */\r
25     public String getLocationType() {\r
26         return locationType;\r
27     }\r
28     /**\r
29      * @param locationType the locationType to set\r
30      */\r
31     public void setLocationType(String locationType) {\r
32         this.locationType = locationType;\r
33     }\r
34     /**\r
35      * @return the locElements\r
36      */\r
37     public Vector getLocElements() {\r
38         return locElements;\r
39     }\r
40     /**\r
41      * @param locElements the locElements to set\r
42      */\r
43     public void setLocElements(Vector locElements) {\r
44         this.locElements = locElements;\r
45     }\r
46     /**\r
47      * Return all location elements as start-end pairs on referenced sequence \r
48      * @return int[] { start1, end1, ... }\r
49      */\r
50     public int[] getElementRanges() {\r
51         if (locationType.equalsIgnoreCase("single")) {\r
52             int[] se = new int[locElements.size()*2];            \r
53             int sepos=0;\r
54             for (Iterator le=locElements.iterator();le.hasNext();) {\r
55                 EmblFeatureLocElement loce = (EmblFeatureLocElement) le.next();\r
56                 BasePosition bp[] = loce.getBasePositions();\r
57                 if (bp.length==2) {\r
58                     se[sepos++] = Integer.parseInt(bp[0].getPos());\r
59                     se[sepos++] = Integer.parseInt(bp[1].getPos());\r
60                 }\r
61             }\r
62             return se;\r
63         }\r
64         return null;\r
65     }\r
66 }