2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel.xdb.embl;
23 import java.util.Enumeration;
24 import java.util.Vector;
26 public class EmblFeatureLocations
32 boolean locationComplement;
35 * @return the locationComplement
37 public boolean isLocationComplement()
39 return locationComplement;
43 * @param locationComplement
44 * the locationComplement to set
46 public void setLocationComplement(boolean locationComplement)
48 this.locationComplement = locationComplement;
52 * @return the locationType
54 public String getLocationType()
61 * the locationType to set
63 public void setLocationType(String locationType)
65 this.locationType = locationType;
69 * @return the locElements
71 public Vector getLocElements()
78 * the locElements to set
80 public void setLocElements(Vector locElements)
82 this.locElements = locElements;
86 * Return all location elements as start-end pairs (without accessions) TODO:
87 * pass back complement and 'less than or more than' range information Note:
88 * do not use this since it throws away any accessionIds associated with each
91 * @return int[] { start1, end1, ... }
93 public int[] getElementRanges()
95 return getElementRanges(null);
99 * Return all location elements concerning given accession as start-end pairs
100 * TODO: pass back complement and 'less than or more than' range information
101 * TODO: deal with multiple accessions
104 * the accession string for which locations are requested, or null
106 * @return null or int[] { start1, end1, ... }
109 public int[] getElementRanges(String accession)
112 int[] se = new int[locElements.size() * 2];
113 if (locationType.equalsIgnoreCase("single"))
115 for (Enumeration le = locElements.elements(); le.hasMoreElements();)
117 EmblFeatureLocElement loce = (EmblFeatureLocElement) le
119 if (accession == null || loce.accession != null
120 && accession.equals(loce.accession))
122 BasePosition bp[] = loce.getBasePositions();
125 se[sepos++] = Integer.parseInt(bp[0].getPos());
126 se[sepos++] = Integer.parseInt(bp[1].getPos());
131 else if (locationType.equalsIgnoreCase("join"))
133 for (Enumeration le = locElements.elements(); le.hasMoreElements();)
135 EmblFeatureLocElement loce = (EmblFeatureLocElement) le
137 if (accession == null || loce.accession != null
138 && accession.equals(loce.accession))
140 BasePosition bp[] = loce.getBasePositions();
143 se[sepos++] = Integer.parseInt(bp[0].getPos());
144 se[sepos++] = Integer.parseInt(bp[1].getPos());
150 else if (locationType != null)
152 if (jalview.bin.Cache.log != null)
153 jalview.bin.Cache.log
154 .error("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"
155 + locationType + "'");
158 .println("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"
159 + locationType + "'");
161 // trim range if necessary.
162 if (se != null && sepos != se.length)
164 int[] trimmed = new int[sepos];
165 System.arraycopy(se, 0, trimmed, 0, sepos);