|
35 | 35 | import org.slf4j.LoggerFactory; |
36 | 36 |
|
37 | 37 | import java.io.InputStream; |
| 38 | +import java.util.ArrayList; |
38 | 39 | import java.util.LinkedHashMap; |
| 40 | +import org.biojava.nbio.core.sequence.features.FeatureInterface; |
| 41 | +import org.biojava.nbio.core.sequence.template.AbstractSequence; |
39 | 42 |
|
40 | 43 | import static org.junit.Assert.assertNotNull; |
41 | 44 |
|
42 | 45 | /** |
43 | 46 | * |
44 | 47 | * @author Scooter Willis <willishf at gmail dot com> |
| 48 | + * @author Jacek Grzebyta |
45 | 49 | */ |
46 | 50 | public class GenbankReaderTest { |
47 | 51 |
|
48 | | - private final static Logger logger = LoggerFactory.getLogger(GenbankReaderTest.class); |
49 | | - |
50 | | - public GenbankReaderTest() { |
51 | | - } |
52 | | - |
53 | | - @BeforeClass |
54 | | - public static void setUpClass() throws Exception { |
55 | | - } |
56 | | - |
57 | | - @AfterClass |
58 | | - public static void tearDownClass() throws Exception { |
59 | | - } |
60 | | - |
61 | | - @Before |
62 | | - public void setUp() { |
63 | | - } |
64 | | - |
65 | | - @After |
66 | | - public void tearDown() { |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * Test of process method, of class GenbankReader. |
71 | | - */ |
72 | | - @Test |
73 | | - public void testProcess() throws Exception { |
74 | | - |
75 | | - logger.info("process protein"); |
76 | | - InputStream inStream = this.getClass().getResourceAsStream("/BondFeature.gb"); |
77 | | - assertNotNull(inStream); |
78 | | - |
79 | | - GenbankReader<ProteinSequence,AminoAcidCompound> GenbankProtein = |
80 | | - new GenbankReader<ProteinSequence,AminoAcidCompound>( |
81 | | - inStream, |
82 | | - new GenericGenbankHeaderParser<ProteinSequence,AminoAcidCompound>(), |
83 | | - new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) |
84 | | - ); |
85 | | - @SuppressWarnings("unused") |
86 | | - LinkedHashMap<String,ProteinSequence> proteinSequences = GenbankProtein.process(); |
87 | | - inStream.close(); |
88 | | - |
89 | | - logger.info("process DNA"); |
90 | | - inStream = this.getClass().getResourceAsStream("/NM_000266.gb"); |
91 | | - assertNotNull(inStream); |
92 | | - |
93 | | - GenbankReader<DNASequence,NucleotideCompound> GenbankDNA = |
94 | | - new GenbankReader<DNASequence,NucleotideCompound>( |
95 | | - inStream, |
96 | | - new GenericGenbankHeaderParser<DNASequence,NucleotideCompound>(), |
97 | | - new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) |
98 | | - ); |
99 | | - @SuppressWarnings("unused") |
100 | | - LinkedHashMap<String,DNASequence> dnaSequences = GenbankDNA.process(); |
101 | | - inStream.close(); |
102 | | - } |
103 | | - |
| 52 | + private final static Logger logger = LoggerFactory.getLogger(GenbankReaderTest.class); |
| 53 | + |
| 54 | + public GenbankReaderTest() { |
| 55 | + } |
| 56 | + |
| 57 | + @BeforeClass |
| 58 | + public static void setUpClass() throws Exception { |
| 59 | + } |
| 60 | + |
| 61 | + @AfterClass |
| 62 | + public static void tearDownClass() throws Exception { |
| 63 | + } |
| 64 | + |
| 65 | + @Before |
| 66 | + public void setUp() { |
| 67 | + } |
| 68 | + |
| 69 | + @After |
| 70 | + public void tearDown() { |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Test of process method, of class GenbankReader. |
| 75 | + */ |
| 76 | + @Test |
| 77 | + public void testProcess() throws Exception { |
| 78 | + |
| 79 | + logger.info("process protein"); |
| 80 | + InputStream inStream = this.getClass().getResourceAsStream("/BondFeature.gb"); |
| 81 | + assertNotNull(inStream); |
| 82 | + |
| 83 | + GenbankReader<ProteinSequence, AminoAcidCompound> GenbankProtein |
| 84 | + = new GenbankReader<ProteinSequence, AminoAcidCompound>( |
| 85 | + inStream, |
| 86 | + new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(), |
| 87 | + new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) |
| 88 | + ); |
| 89 | + @SuppressWarnings("unused") |
| 90 | + LinkedHashMap<String, ProteinSequence> proteinSequences = GenbankProtein.process(); |
| 91 | + inStream.close(); |
| 92 | + |
| 93 | + logger.info("process DNA"); |
| 94 | + inStream = this.getClass().getResourceAsStream("/NM_000266.gb"); |
| 95 | + assertNotNull(inStream); |
| 96 | + |
| 97 | + GenbankReader<DNASequence, NucleotideCompound> GenbankDNA |
| 98 | + = new GenbankReader<DNASequence, NucleotideCompound>( |
| 99 | + inStream, |
| 100 | + new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(), |
| 101 | + new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) |
| 102 | + ); |
| 103 | + @SuppressWarnings("unused") |
| 104 | + LinkedHashMap<String, DNASequence> dnaSequences = GenbankDNA.process(); |
| 105 | + inStream.close(); |
| 106 | + } |
| 107 | + |
| 108 | + @Test |
| 109 | + public void CDStest() throws Exception { |
| 110 | + logger.info("CDS test"); |
| 111 | + |
| 112 | + InputStream inStream = this.getClass().getResourceAsStream("/BondFeature.gb"); |
| 113 | + assertNotNull(inStream); |
| 114 | + |
| 115 | + GenbankReader<ProteinSequence, AminoAcidCompound> GenbankProtein |
| 116 | + = new GenbankReader<ProteinSequence, AminoAcidCompound>( |
| 117 | + inStream, |
| 118 | + new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(), |
| 119 | + new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) |
| 120 | + ); |
| 121 | + @SuppressWarnings("unused") |
| 122 | + LinkedHashMap<String, ProteinSequence> proteinSequences = GenbankProtein.process(); |
| 123 | + inStream.close(); |
| 124 | + |
| 125 | + Assert.assertTrue(proteinSequences.size() == 1); |
| 126 | + logger.info("protein sequences: {}", proteinSequences); |
| 127 | + |
| 128 | + ProteinSequence protein = new ArrayList<ProteinSequence>(proteinSequences.values()).get(0); |
| 129 | + |
| 130 | + FeatureInterface<AbstractSequence<AminoAcidCompound>, AminoAcidCompound> cdsFeature = protein.getFeaturesByType("CDS").get(0); |
| 131 | + String codedBy = cdsFeature.getQualifiers().get("coded_by").getValue(); |
| 132 | + Assert.assertNotNull(codedBy); |
| 133 | + Assert.assertTrue(!codedBy.isEmpty()); |
| 134 | + } |
| 135 | + |
104 | 136 | } |
0 commit comments