FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Propagate down this bit of information · biojava/biojava@a74c015 · GitHub

Commit a74c015

Browse files
committed
Propagate down this bit of information
1 parent 0a86883 commit a74c015

2 files changed

Lines changed: 26 additions & 20 deletions

File tree

‎biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private String parse(BufferedReader bufferedReader) {
283283
// new feature!
284284
gbFeature = new TextFeature(key, val, key, key);
285285
Location l =
286-
locationParser.parse(val);
286+
locationParser.parse(val, isCircularSequence);
287287
gbFeature.setLocation((AbstractLocation)l);
288288

289289
if (!featureCollection.containsKey(key)) {

‎biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/InsdcParser.java‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,40 +135,45 @@ public DataSource getDataSource() {
135135
* @return The parsed location
136136
* @throws ParserException thrown in the event of any error during parsing
137137
*/
138-
public Location parse(String locationString) throws ParserException {
138+
public Location parse(String locationString, boolean isSequenceCircular) throws ParserException {
139139
featureGlobalStart = Integer.MAX_VALUE;
140140
featureGlobalEnd = 1;
141141

142142
Location l;
143-
List<Location> ll = parseLocationString(locationString, 1);
143+
List<Location> ll = parseLocationString(locationString, 1, isSequenceCircular);
144144

145145
if (ll.size() == 1) {
146146
l = ll.get(0);
147147
} else {
148148
l = new SimpleLocation(
149-
featureGlobalStart,
150-
featureGlobalEnd,
149+
new SimplePoint(featureGlobalStart),
150+
new SimplePoint(featureGlobalEnd),
151151
Strand.UNDEFINED,
152+
isSequenceCircular,
152153
ll);
153154
}
154155
return l;
155156
}
156157

157-
/**
158-
* Reader based version of the parse methods.
159-
*
160-
* @param reader The source of the data; assumes that end of the reader
161-
* stream is the end of the location string to parse
162-
* @return The parsed location
163-
* @throws IOException Thrown with any reader error
164-
* @throws ParserException Thrown with any error with parsing locations
165-
*/
158+
public Location parse(String locationString) throws ParserException {
159+
return parse(locationString, false);
160+
}
161+
162+
/**
163+
* Reader based version of the parse methods.
164+
*
165+
* @param reader The source of the data; assumes that end of the reader
166+
* stream is the end of the location string to parse
167+
* @return The parsed location
168+
* @throws IOException Thrown with any reader error
169+
* @throws ParserException Thrown with any error with parsing locations
170+
*/
166171
public List<AbstractLocation> parse(Reader reader) throws IOException, ParserException {
167172
// use parse(String s) instead!
168173
return null;
169174
}
170175

171-
private List<Location> parseLocationString(String string, int versus) throws ParserException {
176+
private List<Location> parseLocationString(String string, int versus, boolean isSequenceCircular) throws ParserException {
172177
Matcher m;
173178
List<Location> boundedLocationsCollection = new ArrayList<Location>();
174179

@@ -186,7 +191,8 @@ private List<Location> parseLocationString(String string, int versus) throws Par
186191
if (!splitQualifier.isEmpty()) {
187192
//recursive case
188193
int localVersus = splitQualifier.equalsIgnoreCase("complement") ? -1 : 1;
189-
List<Location> subLocations = parseLocationString(splitString, versus * localVersus);
194+
List<Location> subLocations = parseLocationString(
195+
splitString, versus * localVersus, isSequenceCircular);
190196

191197
switch (complexFeaturesAppendMode) {
192198
case FLATTEN:
@@ -228,8 +234,8 @@ private List<Location> parseLocationString(String string, int versus) throws Par
228234

229235
String accession = m.group(1);
230236
Strand s = versus == 1 ? Strand.POSITIVE : Strand.NEGATIVE;
231-
int start = Integer.parseInt(m.group(3));
232-
int end = m.group(6) == null ? start : new Integer(m.group(6));
237+
int start = Integer.valueOf(m.group(3));
238+
int end = m.group(6) == null ? start : Integer.valueOf(m.group(6));
233239

234240
if (featureGlobalStart > start) {
235241
featureGlobalStart = start;
@@ -239,8 +245,8 @@ private List<Location> parseLocationString(String string, int versus) throws Par
239245
}
240246

241247
AbstractLocation l = new SimpleLocation(
242-
start,
243-
end,
248+
new SimplePoint(start),
249+
new SimplePoint(end),
244250
s
245251
);
246252

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL