Skip to content

Commit e49b69b

Browse files
committed
Implementation of exceptional complex location in case of location spanning the end point. Location contract wants sublocations
1 parent d724aec commit e49b69b

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class GenbankSequenceParser<S extends AbstractSequence<C>, C extends Comp
6868
private String header;
6969
private String accession;
7070
private boolean isCircularSequence;
71-
private long sequenceLength;
71+
private int sequenceLength;
7272
public LinkedHashMap<String, ArrayList<DBReferenceInfo>> mapDB;
7373
/**
7474
* this data structure collects list of features extracted from the
@@ -162,7 +162,7 @@ private String parse(BufferedReader bufferedReader) {
162162
if (m.matches()) {
163163
headerParser.setName(m.group(1));
164164
headerParser.setAccession(m.group(1)); // default if no accession found
165-
sequenceLength = Long.valueOf(m.group(2));
165+
sequenceLength = Integer.valueOf(m.group(2));
166166
String lengthUnits = m.group(3);
167167
String type = m.group(6);
168168

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
public class InsdcParser <S extends AbstractSequence<C>, C extends Compound>{
5252

5353
private boolean isSequenceCircular;
54-
private long sequenceLength;
54+
private int sequenceLength;
5555

5656
private final DataSource dataSource;
5757

@@ -133,7 +133,7 @@ public void setSequenceCircular(boolean sequenceCircular) {
133133
isSequenceCircular = sequenceCircular;
134134
}
135135

136-
public void setSequenceLength(long sequenceLength) {
136+
public void setSequenceLength(int sequenceLength) {
137137
this.sequenceLength = sequenceLength;
138138
}
139139

@@ -249,11 +249,34 @@ private List<Location> parseLocationString(String string, int versus) throws Par
249249
featureGlobalEnd = end;
250250
}
251251

252-
AbstractLocation l = new SimpleLocation(
253-
new SimplePoint(start),
254-
new SimplePoint(end),
255-
s
256-
);
252+
AbstractLocation l;
253+
if (start < end) {
254+
l = new SimpleLocation(
255+
new SimplePoint(start),
256+
new SimplePoint(end),
257+
s
258+
);
259+
} else {
260+
// in case of location spanning the end point, Location contract wants sublocations
261+
AbstractLocation l5prime = new SimpleLocation(
262+
new SimplePoint(1),
263+
new SimplePoint(end),
264+
Strand.POSITIVE
265+
);
266+
AbstractLocation l3prime = new SimpleLocation(
267+
new SimplePoint(start),
268+
new SimplePoint(sequenceLength),
269+
Strand.POSITIVE
270+
);
271+
272+
l = new SimpleLocation(
273+
new SimplePoint(start),
274+
new SimplePoint(end), // seq length
275+
s,
276+
isSequenceCircular,
277+
Arrays.asList(l5prime, l3prime)
278+
);
279+
}
257280

258281
if(m.group(4) != null && m.group(4).equals("^")) l.setBetweenCompounds(true);
259282

0 commit comments

Comments
 (0)