Skip to content

Commit 9f6ed03

Browse files
arojnuckarinjosemduarte
authored andcommitted
Revert to old behavior where process(int) return null on end-of-file.
1 parent 1bd4606 commit 9f6ed03

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public LinkedHashMap<String,S> process() throws IOException {
122122
* <ul>
123123
* <li>This method can't be called after calling its NO-ARGUMENT twin.</li>
124124
* <li>remember to close the underlying resource when you are done.</li>
125-
* <li>This method always return non-null hash map. When end-of-file is reached,
126-
* the number of sequences returned will be smaller than the number requested.</li>
127125
* </ul>
128126
* @see #process()
129127
* @author Amr AL-Hossary
@@ -219,7 +217,7 @@ public LinkedHashMap<String,S> process(int max) throws IOException {
219217
this.line = line;
220218
this.header= header;
221219

222-
return sequences;
220+
return max > -1 && sequences.isEmpty() ? null : sequences;
223221
}
224222

225223
public void close() throws IOException {

biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ private void testProcess1(String path) throws Exception {
7272
assertThat(out1.containsKey("P02768"),is(true));
7373
assertThat(out1.get("P02768").getLength(),is(609));
7474
LinkedHashMap<String,ProteinSequence> out2 = fastaReader.process(1);
75-
assertThat(out2,is(notNullValue()));
76-
assertThat(out2.size(),is(0));
75+
assertThat(out2,is(nullValue()));
7776
} finally {
7877
if(fastaReader != null) fastaReader.close();
7978
}
@@ -120,8 +119,7 @@ private void testProcess2(String path) throws Exception {
120119
assertThat(out2.containsKey("P00698"),is(true));
121120
assertThat(out2.get("P00698").getLength(),is(147));
122121
LinkedHashMap<String,ProteinSequence> out3 = fastaReader.process(1);
123-
assertThat(out3,is(notNullValue()));
124-
assertThat(out3.size(),is(0));
122+
assertThat(out3,is(nullValue()));
125123
} finally {
126124
if(fastaReader != null) fastaReader.close();
127125
}

0 commit comments

Comments
 (0)