2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.bin.Cache;
25 import java.util.Vector;
28 * Data model for a <loctaion> child element of a <feature> read
29 * from an EMBL query reply
31 * @see embl_mapping.xml
33 public class EmblFeatureLocations
35 Vector<EmblFeatureLocElement> locElements;
39 boolean locationComplement;
42 * @return the locationComplement
44 public boolean isLocationComplement()
46 return locationComplement;
50 * @param locationComplement
51 * the locationComplement to set
53 public void setLocationComplement(boolean locationComplement)
55 this.locationComplement = locationComplement;
59 * @return the locationType
61 public String getLocationType()
68 * the locationType to set
70 public void setLocationType(String locationType)
72 this.locationType = locationType;
76 * @return the locElements
78 public Vector<EmblFeatureLocElement> getLocElements()
85 * the locElements to set
87 public void setLocElements(Vector<EmblFeatureLocElement> locElements)
89 this.locElements = locElements;
93 * Return all location elements as start-end pairs (without accessions) TODO:
94 * pass back complement and 'less than or more than' range information Note:
95 * do not use this since it throws away any accessionIds associated with each
98 * @return int[] { start1, end1, ... }
100 public int[] getElementRanges()
102 return getElementRanges(null);
106 * Return all location elements concerning given accession as start-end pairs
107 * TODO: pass back complement and 'less than or more than' range information
108 * TODO: deal with multiple accessions
111 * the accession string for which locations are requested, or null
113 * @return null or int[] { start1, end1, ... }
116 public int[] getElementRanges(String accession)
119 int[] se = new int[locElements.size() * 2];
120 if (locationType.equalsIgnoreCase("single")) // TODO: or "simple" ?
122 for (EmblFeatureLocElement loce : locElements)
124 if (accession == null || loce.accession != null
125 && accession.equals(loce.accession))
127 BasePosition bp[] = loce.getBasePositions();
130 se[sepos++] = Integer.parseInt(bp[0].getPos());
131 se[sepos++] = Integer.parseInt(bp[1].getPos());
136 else if (locationType.equalsIgnoreCase("join"))
138 for (EmblFeatureLocElement loce : locElements)
140 if (accession == null || loce.accession != null
141 && accession.equals(loce.accession))
143 BasePosition bp[] = loce.getBasePositions();
146 se[sepos++] = Integer.parseInt(bp[0].getPos());
147 se[sepos++] = Integer.parseInt(bp[1].getPos());
153 else if (locationType != null)
155 if (Cache.log != null)
158 .error("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"
159 + locationType + "'");
164 .println("EmbleFeatureLocations.getElementRanges cannot deal with locationType=='"
165 + locationType + "'");
168 // trim range if necessary.
169 if (se != null && sepos != se.length)
171 int[] trimmed = new int[sepos];
172 System.arraycopy(se, 0, trimmed, 0, sepos);