Skip to content

Commit cf4efc8

Browse files
committed
Add a test of the Genbank Functionality
1 parent d8bf8e1 commit cf4efc8

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
*
3+
*/
4+
package org.biojava3.core.sequence.io;
5+
6+
import java.io.ByteArrayInputStream;
7+
import java.io.ByteArrayOutputStream;
8+
import java.io.File;
9+
import java.util.ArrayList;
10+
import java.util.LinkedHashMap;
11+
12+
import org.biojava3.core.sequence.DNASequence;
13+
import org.junit.After;
14+
import org.junit.AfterClass;
15+
import org.junit.Before;
16+
import org.junit.BeforeClass;
17+
import org.junit.Test;
18+
19+
/**
20+
* @author mckeee1
21+
*
22+
*/
23+
public class GenbankWriterTest {
24+
25+
public GenbankWriterTest() {}
26+
27+
@BeforeClass
28+
public static void setUpClass() throws Exception {}
29+
30+
@AfterClass
31+
public static void tearDownClass() throws Exception {}
32+
33+
@Before
34+
public void setUp() {}
35+
36+
@After
37+
public void tearDown() {}
38+
39+
@Test
40+
public void testProcess() throws Exception {
41+
File dnaFile = new File("src/test/resources/NM_000266.gb");
42+
LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence( dnaFile );
43+
ByteArrayOutputStream fragwriter = new ByteArrayOutputStream();
44+
ArrayList<DNASequence> seqs = new ArrayList<DNASequence>();
45+
for(DNASequence seq : dnaSequences.values()) {
46+
seqs.add(seq);
47+
}
48+
GenbankWriterHelper.writeNucleotideSequence(fragwriter, seqs,
49+
GenbankWriterHelper.LINEAR_DNA);
50+
//System.out.println(fragwriter.toString());
51+
ByteArrayInputStream fragreader = new ByteArrayInputStream(fragwriter.toByteArray());
52+
dnaSequences = GenbankReaderHelper.readGenbankDNASequence( fragreader );
53+
fragwriter.close();
54+
assert(seqs.get(0).getSequenceAsString() == dnaSequences.values().iterator().next().getSequenceAsString());
55+
}
56+
}

0 commit comments

Comments
 (0)