|
30 | 30 | import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet; |
31 | 31 | import org.biojava.nbio.core.sequence.compound.DNACompoundSet; |
32 | 32 | import org.biojava.nbio.core.sequence.compound.NucleotideCompound; |
| 33 | +import org.biojava.nbio.core.sequence.io.util.ClasspathResource; |
33 | 34 | import org.biojava.nbio.core.sequence.loader.GenbankProxySequenceReader; |
34 | 35 | import org.junit.*; |
35 | 36 | import org.slf4j.Logger; |
@@ -90,40 +91,42 @@ public void testProcess() throws Throwable { |
90 | 91 | * Method 2: With the GenbankReaderHelper |
91 | 92 | */ |
92 | 93 | //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"); |
95 | 98 |
|
96 | | - LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaFile); |
| 99 | + LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaResource.getInputStream()); |
97 | 100 | for (DNASequence sequence : dnaSequences.values()) { |
98 | 101 | logger.info("DNA Sequence: {}", sequence.getSequenceAsString()); |
99 | 102 | } |
100 | 103 |
|
101 | | - LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper.readGenbankProteinSequence(protFile); |
| 104 | + LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper.readGenbankProteinSequence(protResource.getInputStream()); |
102 | 105 | for (ProteinSequence sequence : protSequences.values()) { |
103 | 106 | logger.info("Protein Sequence: {}", sequence.getSequenceAsString()); |
104 | 107 | } |
105 | 108 | /* |
106 | 109 | * Method 3: With the GenbankReader Object |
107 | 110 | */ |
108 | 111 | //Try reading with the GanbankReader |
109 | | - FileInputStream is = new FileInputStream(dnaFile); |
| 112 | + |
110 | 113 | GenbankReader<DNASequence, NucleotideCompound> dnaReader = new GenbankReader<DNASequence, NucleotideCompound>( |
111 | | - is, |
| 114 | + dnaResource.getInputStream(), |
112 | 115 | new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(), |
113 | 116 | new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) |
114 | 117 | ); |
115 | 118 | dnaSequences = dnaReader.process(); |
116 | | - is.close(); |
| 119 | + |
117 | 120 | logger.info("DNA Sequence: {}", dnaSequences); |
118 | 121 |
|
119 | | - is = new FileInputStream(protFile); |
| 122 | + |
120 | 123 | GenbankReader<ProteinSequence, AminoAcidCompound> protReader = new GenbankReader<ProteinSequence, AminoAcidCompound>( |
121 | | - is, |
| 124 | + protResource.getInputStream(), |
122 | 125 | new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(), |
123 | 126 | new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) |
124 | 127 | ); |
125 | 128 | protSequences = protReader.process(); |
126 | | - is.close(); |
| 129 | + |
127 | 130 | logger.info("Protein Sequence: {}", protSequences); |
128 | 131 |
|
129 | 132 | } |
|
0 commit comments