1 package jalview.datamodel.xdb.embl;
3 import java.util.Enumeration;
4 import java.util.Iterator;
5 import java.util.Vector;
7 public class EmblFeatureLocations {
10 boolean locationComplement;
12 * @return the locationComplement
14 public boolean isLocationComplement() {
15 return locationComplement;
18 * @param locationComplement the locationComplement to set
20 public void setLocationComplement(boolean locationComplement) {
21 this.locationComplement = locationComplement;
24 * @return the locationType
26 public String getLocationType() {
30 * @param locationType the locationType to set
32 public void setLocationType(String locationType) {
33 this.locationType = locationType;
36 * @return the locElements
38 public Vector getLocElements() {
42 * @param locElements the locElements to set
44 public void setLocElements(Vector locElements) {
45 this.locElements = locElements;
48 * Return all location elements as start-end pairs (without accessions)
49 * TODO: pass back complement and 'less than or more than' range information
50 * Note: do not use this since it throws away any accessionIds associated with
52 * @return int[] { start1, end1, ... }
54 public int[] getElementRanges() {
55 return getElementRanges(null);
58 * Return all location elements concerning given accession as start-end pairs
59 * TODO: pass back complement and 'less than or more than' range information
60 * TODO: deal with multiple accessions
61 * @param accession the accession string for which locations are requested, or null for all locations
62 * @return null or int[] { start1, end1, ... }
65 public int[] getElementRanges(String accession)
68 int[] se = new int[locElements.size()*2];
69 if (locationType.equalsIgnoreCase("single")) {
70 for (Enumeration le=locElements.elements();le.hasMoreElements();) {
71 EmblFeatureLocElement loce = (EmblFeatureLocElement) le.nextElement();
72 if (accession==null || loce.accession!=null && accession.equals(loce.accession))
74 BasePosition bp[] = loce.getBasePositions();
76 se[sepos++] = Integer.parseInt(bp[0].getPos());
77 se[sepos++] = Integer.parseInt(bp[1].getPos());
82 if (locationType.equalsIgnoreCase("join")) {
83 for (Enumeration le=locElements.elements();le.hasMoreElements();) {
84 EmblFeatureLocElement loce = (EmblFeatureLocElement) le.nextElement();
85 if (accession==null || loce.accession!=null && accession.equals(loce.accession))
87 BasePosition bp[] = loce.getBasePositions();
89 se[sepos++] = Integer.parseInt(bp[0].getPos());
90 se[sepos++] = Integer.parseInt(bp[1].getPos());
96 if (locationType!=null)
98 if (jalview.bin.Cache.log!=null)
99 jalview.bin.Cache.log.error("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"+locationType+"'");
101 System.err.println("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"+locationType+"'");
103 // trim range if necessary.
104 if (se!=null && sepos!=se.length)
106 int[] trimmed = new int[sepos];
107 System.arraycopy(se,0,trimmed, 0, sepos);