Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GenbankReader#process(int max) closes the underlying InputStream #663

Copy link
Copy link

Description

@psoares
Issue body actions

I tried to use the GenbankReader to read a Genbank file. I wanted to do this through repeated calls to the version of the process method that takes a number of records as the only parameter.
After the first call, the underlying inputstream is closed and the second call fails.

Here is an example :

import org.biojava.nbio.core.sequence.DNASequence;
import org.biojava.nbio.core.sequence.compound.DNACompoundSet;
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
import org.biojava.nbio.core.sequence.io.FileProxyDNASequenceCreator;
import org.biojava.nbio.core.sequence.io.GenbankReader;
import org.biojava.nbio.core.sequence.io.GenbankSequenceParser;
import org.biojava.nbio.core.sequence.io.GenericGenbankHeaderParser;
import org.biojava.nbio.core.sequence.template.AbstractSequence;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.LinkedHashMap;

class TestGBReading {

    public static void main(String[] args) {
        File file = new File("/tmp/gbpat100.seq");

        LinkedHashMap<String, DNASequence> sequences = null;
        GenbankReader<DNASequence, NucleotideCompound> gbReader = null;
        try {
            gbReader =
                    new GenbankReader<DNASequence, NucleotideCompound>(
                            file,
                            new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(),
                            new FileProxyDNASequenceCreator(
                                    file,
                                    DNACompoundSet.getDNACompoundSet(),
                                    new GenbankSequenceParser<AbstractSequence<NucleotideCompound>,
                                            NucleotideCompound>()
                            )
                    );
            sequences = gbReader.process(10);
            System.out.println("Reading first 10");
            for (DNASequence seq : sequences.values()) {
                System.out.println(" - " + seq.getAccession());
            }

            sequences = gbReader.process(10);
            System.out.println("Reading next 10");
            for (DNASequence seq : sequences.values()) {
                System.out.println(" - " + seq.getAccession());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}```
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBugs and bugfixesBugs and bugfixes

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.