Merge branch 'develop' into features/JAL-4219_extended_fasta_rna_ss
[jalview.git] / test / jalview / io / FastaFileTest.java
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 jalview.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.SequenceI;
28
29 import java.io.IOException;
30
31 import org.testng.annotations.Test;
32
33 public class FastaFileTest
34 {
35   @Test(groups = "Functional")
36   public void testParse_rnaFasta() throws IOException
37   {
38     String rnaseq = "gGGGGCCACAGCAGAAGCGUUCACGUCGCAGCCCCUGUCAGCCAUUGCACUCCGGCUGCGAAUUCUGCU",
39             rnastruct = "[[[[[[...((((((((((.......))).]]]]]]..(((((..........)))))....)))))))";
40     //@formatter:off
41     String rna_fasta = ">strand_B\n"
42             + rnaseq+"\n"
43             + rnastruct+"\n";
44     //@formatter:on
45     FastaFile cf = new FastaFile(rna_fasta, DataSourceType.PASTE);
46     SequenceI[] seqs = cf.getSeqsAsArray();
47     AlignmentAnnotation[] aa = cf.annotations.toArray(new AlignmentAnnotation[1]);
48     assertEquals(seqs.length, 1);
49     assertEquals(seqs[0].getName(), "strand_B");
50     assertEquals(seqs[0].getStart(), 1);
51     assertEquals(seqs[0].getEnd(), 69);
52     assertTrue(seqs[0].getSequenceAsString().endsWith("UUCUGCU"));
53     assertTrue(seqs[0].getAnnotation()!=null);
54     assertEquals(seqs[0].getAnnotation().length,1);
55     assertEquals(seqs[0].getAnnotation()[0].getRNAStruc(),rnastruct);
56   }
57 }