| 1 |
|
package jalview.io; |
| 2 |
|
|
| 3 |
|
import static org.testng.Assert.assertEquals; |
| 4 |
|
import static org.testng.Assert.assertTrue; |
| 5 |
|
|
| 6 |
|
import jalview.datamodel.SequenceFeature; |
| 7 |
|
import jalview.datamodel.SequenceI; |
| 8 |
|
import jalview.datamodel.features.SequenceFeaturesI; |
| 9 |
|
|
| 10 |
|
import java.io.IOException; |
| 11 |
|
import java.util.List; |
| 12 |
|
|
| 13 |
|
import org.testng.annotations.Test; |
| 14 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.07 |
|
| 15 |
|
public class BSMLFileTest |
| 16 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 17 |
1 |
@Test(groups="Functional")... |
| 18 |
|
public void testParse_BSML() throws IOException |
| 19 |
|
{ |
| 20 |
|
|
| 21 |
1 |
String data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + |
| 22 |
|
"<Bsml>\r\n" + |
| 23 |
|
" <Definitions>\r\n" + |
| 24 |
|
" <Sequences>\r\n" + |
| 25 |
|
" <Sequence\r\n" + |
| 26 |
|
" comment=\"Sequence Data Contained in 'Multiple-alignment' section\"\r\n" + |
| 27 |
|
" id=\"SEQ-ID:181170\" length=\"30\" molecule=\"dna\" title=\"EP1\">\r\n" + |
| 28 |
|
" <Feature-tables>\r\n" + |
| 29 |
|
" <Feature-table title=\"GENE\">\r\n" + |
| 30 |
|
" <Feature class=\"GENE\" title=\"TEST-001\">\r\n" + |
| 31 |
|
" <Interval-loc complement=\"0\" endpos=\"20\" startpos=\"10\"/>\r\n" + |
| 32 |
|
" <Resource id=\"GENE-ID:181171\"/>\r\n" + |
| 33 |
|
" </Feature>\r\n" + |
| 34 |
|
" </Feature-table>\r\n" + |
| 35 |
|
" </Feature-tables>\r\n" + |
| 36 |
|
" </Sequence>\r\n" + |
| 37 |
|
" </Sequences>\r\n" + |
| 38 |
|
" <Tables>\r\n" + |
| 39 |
|
" <Multiple-alignment-table molecule-type=\"nucleotide\">\r\n" + |
| 40 |
|
" <Sequence-alignment sequences=\"1\">\r\n" + |
| 41 |
|
" <Sequence-data seq-name=\"EP1\">--AATTTT-ATTTAGTGTCT-----------</Sequence-data>\r\n" + |
| 42 |
|
" <Alignment-consensus/>\r\n" + |
| 43 |
|
" </Sequence-alignment>\r\n" + |
| 44 |
|
" </Multiple-alignment-table>\r\n" + |
| 45 |
|
" </Tables>\r\n" + |
| 46 |
|
" <Notebook notebook=\"\"/>\r\n" + |
| 47 |
|
" </Definitions>\r\n" + |
| 48 |
|
"</Bsml>\r\n" + |
| 49 |
|
""; |
| 50 |
1 |
BSMLFile cf = new BSMLFile(data, DataSourceType.PASTE); |
| 51 |
|
|
| 52 |
1 |
SequenceI[] seqs = cf.getSeqsAsArray(); |
| 53 |
1 |
assertEquals(seqs.length, 1); |
| 54 |
1 |
SequenceI seq = seqs[0]; |
| 55 |
1 |
assertEquals(seq.getName(), "EP1"); |
| 56 |
1 |
assertEquals(seq.getStart(), 1); |
| 57 |
1 |
assertEquals(seq.getEnd(), 31); |
| 58 |
1 |
assertTrue(seq.getSequenceAsString().equals("--AATTTT-ATTTAGTGTCT-----------")); |
| 59 |
1 |
SequenceFeaturesI features = seq.getFeatures(); |
| 60 |
1 |
List<SequenceFeature> genes = features.getAllFeatures("GENE"); |
| 61 |
1 |
assertEquals(genes.size(), 1); |
| 62 |
1 |
SequenceFeature sf = genes.get(0); |
| 63 |
1 |
assertEquals(sf.getDescription(), "TEST-001"); |
| 64 |
1 |
assertEquals(sf.begin + "," + sf.end, "10,20"); |
| 65 |
|
|
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
} |