JAL-1988 JAL-3130 New jlinked JRE in jalview_java2 with modules. Still needs jaxws...
[jalview.git] / test / jalview / io / ClustalFileTest.java
1 package jalview.io;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5
6 import jalview.datamodel.SequenceI;
7
8 import java.io.IOException;
9
10 import org.testng.annotations.Test;
11
12 public class ClustalFileTest
13 {
14   @Test(groups="Functional")
15   public void testParse_withNumbering() throws IOException
16   {
17     //@formatter:off
18     String data = "CLUSTAL\n\n"
19             + "FER_CAPAA/1-8      -----------------------------------------------------------A\t1\n"
20             + "FER_CAPAN/1-55     MA------SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALFGLKS-A--NGGKVTCMA 48\n"
21             + "FER1_SOLLC/1-55    MA------SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA 48\n"
22             + "Q93XJ9_SOLTU/1-55  MA------SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA 48\n"
23             + "FER1_PEA/1-60      MATT---PALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFLGLKT-SLKRGDLAVAMA 53\n\n"
24             + "FER_CAPAA/1-8      SYKVKLI 8\n"
25             + "FER_CAPAN/1-55     SYKVKLI 55\n"
26             + "FER1_SOLLC/1-55    SYKVKLI 55\n"
27             + "Q93XJ9_SOLTU/1-55  SYKVKLI 55\n"
28             + "FER1_PEA/1-60      SYKVKLV 60\n"
29             + "                   .*     .:....*******..** ..........**  ********...*:::*  ...\n"
30             + "\t\t.:.::.  *\n";
31     //@formatter:on
32     ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
33     cf.parse();
34     SequenceI[] seqs = cf.getSeqsAsArray();
35     assertEquals(seqs.length, 5);
36     assertEquals(seqs[0].getName(), "FER_CAPAA");
37     assertEquals(seqs[0].getStart(), 1);
38     assertEquals(seqs[0].getEnd(), 8);
39     assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));
40   }
41
42   @Test(groups="Functional")
43   public void testParse_noNumbering() throws IOException
44   {
45     //@formatter:off
46     String data = "CLUSTAL\n\n"
47             + "FER_CAPAA/1-8      -----------------------------------------------------------A\n"
48             + "FER_CAPAN/1-55     MA------SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALFGLKS-A--NGGKVTCMA\n"
49             + "FER1_SOLLC/1-55    MA------SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA\n"
50             + "Q93XJ9_SOLTU/1-55  MA------SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA\n"
51             + "FER1_PEA/1-60      MATT---PALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFLGLKT-SLKRGDLAVAMA\n\n"
52             + "FER_CAPAA/1-8      SYKVKLI\n"
53             + "FER_CAPAN/1-55     SYKVKLI\n"
54             + "FER1_SOLLC/1-55    SYKVKLI\n"
55             + "Q93XJ9_SOLTU/1-55  SYKVKLI\n"
56             + "FER1_PEA/1-60      SYKVKLV\n";
57     //@formatter:on
58     ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
59     cf.parse();
60     SequenceI[] seqs = cf.getSeqsAsArray();
61     assertEquals(seqs.length, 5);
62     assertEquals(seqs[0].getName(), "FER_CAPAA");
63     assertEquals(seqs[0].getStart(), 1);
64     assertEquals(seqs[0].getEnd(), 8);
65     assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));
66   }
67 }