Skip to content

Commit 9e2dc2c

Browse files
committed
fixing classpath problem
1 parent 441ddce commit 9e2dc2c

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet;
3131
import org.biojava.nbio.core.sequence.compound.DNACompoundSet;
3232
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
33+
import org.biojava.nbio.core.sequence.io.util.ClasspathResource;
3334
import org.biojava.nbio.core.sequence.loader.GenbankProxySequenceReader;
3435
import org.junit.*;
3536
import org.slf4j.Logger;
@@ -90,40 +91,42 @@ public void testProcess() throws Throwable {
9091
* Method 2: With the GenbankReaderHelper
9192
*/
9293
//Try with the GenbankReaderHelper
93-
File dnaFile = new File("src/test/resources/NM_000266.gb");
94-
File protFile = new File("src/test/resources/BondFeature.gb");
94+
ClasspathResource dnaResource = new ClasspathResource("NM_000266.gb", true);
95+
//File dnaFile = new File("src/test/resources/NM_000266.gb");
96+
//File protFile = new File("src/test/resources/BondFeature.gb");
97+
ClasspathResource protResource = new ClasspathResource("BondFeature.gb");
9598

96-
LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaFile);
99+
LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaResource.getInputStream());
97100
for (DNASequence sequence : dnaSequences.values()) {
98101
logger.info("DNA Sequence: {}", sequence.getSequenceAsString());
99102
}
100103

101-
LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper.readGenbankProteinSequence(protFile);
104+
LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper.readGenbankProteinSequence(protResource.getInputStream());
102105
for (ProteinSequence sequence : protSequences.values()) {
103106
logger.info("Protein Sequence: {}", sequence.getSequenceAsString());
104107
}
105108
/*
106109
* Method 3: With the GenbankReader Object
107110
*/
108111
//Try reading with the GanbankReader
109-
FileInputStream is = new FileInputStream(dnaFile);
112+
110113
GenbankReader<DNASequence, NucleotideCompound> dnaReader = new GenbankReader<DNASequence, NucleotideCompound>(
111-
is,
114+
dnaResource.getInputStream(),
112115
new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(),
113116
new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())
114117
);
115118
dnaSequences = dnaReader.process();
116-
is.close();
119+
117120
logger.info("DNA Sequence: {}", dnaSequences);
118121

119-
is = new FileInputStream(protFile);
122+
120123
GenbankReader<ProteinSequence, AminoAcidCompound> protReader = new GenbankReader<ProteinSequence, AminoAcidCompound>(
121-
is,
124+
protResource.getInputStream(),
122125
new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
123126
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())
124127
);
125128
protSequences = protReader.process();
126-
is.close();
129+
127130
logger.info("Protein Sequence: {}", protSequences);
128131

129132
}

0 commit comments

Comments
 (0)