Clover icon

Coverage Report

  1. Project Clover database Thu Jun 4 2026 15:31:54 BST
  2. Package jalview.io

File LayeredDBNParserTest.java

 

Code metrics

0
25
1
1
105
61
1
0.04
25
1
1

Classes

Class Line # Actions
LayeredDBNParserTest 33 25 1
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.io;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertTrue;
25   
26    import java.io.IOException;
27   
28    import org.testng.annotations.Test;
29   
30    import jalview.datamodel.AlignmentI;
31    import jalview.io.LayeredDBNParser.Record;
32   
 
33    public class LayeredDBNParserTest
34    {
 
35  1 toggle @Test(groups = "Functional")
36    public void testParse() throws IOException
37    {
38   
39    // Example text fitting the specification
40  1 String sampleText = ">RNA complex: chains A[1_555](1-59), B[1_555](1-59) ('&' separates chains)\n"
41   
42    + "seq : AAGUACCCUCCAAGCCCUACAGGUUGGAAGAGGGGGCUAUCAGUCCUGUAGGCAGACUC&AAGUACCCUCCAAGCCCUACAGGUUGGAAGAGGGGGCUAUCAGUCCUGUAGGCAGACUC\n"
43   
44    + "L1 cWW : .(((.([[[[[..{.{{{{.{{{...)..].]]]])))......}}}.}}}}}......&.(((.([[[[[..{.{{{{{{{{...)..].]]]])))......}}}}}}}}}......\n"
45   
46    + "L10 tWW : .......................(......)............................&...........................................................\n"
47   
48    + "L11 tWH : ........................(...)..............................&........................(...)..............................\n"
49   
50    + "L12 tWS : ....(....................)..(.............)................&....(....................)..(.............)................\n"
51   
52    + "L13 tHW : ....(....................................).................&....(....................................).................\n"
53   
54    + "L18 tSS : ...........................................................&............(......................................)....... \n"
55    ;
56   
57    // Init Jalview FileParse in PASTE mode, which means reading directly from a
58    // String block in memory
59   
60  1 LayeredDBNParser parser = new LayeredDBNParser(sampleText,
61    DataSourceType.PASTE);
62  1 Record parsedRecord = parser.getRecord();
63  1 String seq1 = "AAGUACCCUCCAAGCCCUACAGGUUGGAAGAGGGGGCUAUCAGUCCUGUAGGCAGACUC", seq2="AAGUACCCUCCAAGCCCUACAGGUUGGAAGAGGGGGCUAUCAGUCCUGUAGGCAGACUC";
64   
65  1 assertEquals(parsedRecord.sequences.get(0), seq1);
66  1 assertEquals(parsedRecord.sequences.get(1), seq2);
67  1 assertEquals(parsedRecord.basePairs.get("L1 cWW").get(0).getWuss(),
68    ".(((.([[[[[..{.{{{{.{{{...)..].]]]])))......}}}.}}}}}......");
69  1 assertEquals(parsedRecord.basePairs.get("L1 cWW").get(1).getWuss(),
70    ".(((.([[[[[..{.{{{{{{{{...)..].]]]])))......}}}}}}}}}......");
71  1 assertEquals(parsedRecord.basePairs.get("L10 tWW").get(0).getWuss(),
72    ".......................(......)............................");
73  1 assertEquals(parsedRecord.basePairs.get("L10 tWW").get(1).getWuss(),
74    "...........................................................");
75  1 assertEquals(parsedRecord.basePairs.get("L11 tWH").get(0).getWuss(),
76    "........................(...)..............................");
77  1 assertEquals(parsedRecord.basePairs.get("L11 tWH").get(1).getWuss(),
78    "........................(...)..............................");
79  1 assertEquals(parsedRecord.basePairs.get("L12 tWS").get(0).getWuss(),
80    "....(....................)..(.............)................");
81  1 assertEquals(parsedRecord.basePairs.get("L12 tWS").get(1).getWuss(),
82    "....(....................)..(.............)................");
83  1 assertEquals(parsedRecord.basePairs.get("L13 tHW").get(0).getWuss(),
84    "....(....................................).................");
85  1 assertEquals(parsedRecord.basePairs.get("L13 tHW").get(1).getWuss(),
86    "....(....................................).................");
87  1 assertEquals(parsedRecord.basePairs.get("L18 tSS").get(0).getWuss(),
88    "...........................................................");
89  1 assertEquals(parsedRecord.basePairs.get("L18 tSS").get(1).getWuss(),
90    "............(......................................).......");
91   
92    // identifyfile
93   
94  1 FileFormatI afr = new IdentifyFile().identify(sampleText, DataSourceType.PASTE);
95  1 assertEquals(afr, FileFormat.LayeredBN);
96    // now check sequence
97  1 AlignmentI al = new AppletFormatAdapter().readFile(sampleText,
98    DataSourceType.PASTE, FileFormat.LayeredBN);
99   
100  1 assertEquals(al.getHeight(), 2);
101  1 assertEquals(al.getSequenceAt(0).getAnnotation()[0].isRNA(), true);
102  1 assertTrue(al.getSequenceAt(0).getSequenceAsString().equals(seq1));
103  1 assertTrue(al.getSequenceAt(1).getSequenceAsString().equals(seq2));
104    }
105    }