2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertTrue;
26 import jalview.datamodel.SequenceI;
28 import java.io.IOException;
30 import org.testng.annotations.Test;
32 public class ClustalFileTest
34 @Test(groups = "Functional")
35 public void testParse_withNumbering() throws IOException
38 String data = "CLUSTAL\n\n"
39 + "FER_CAPAA/1-8 -----------------------------------------------------------A\t1\n"
40 + "FER_CAPAN/1-55 MA------SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALFGLKS-A--NGGKVTCMA 48\n"
41 + "FER1_SOLLC/1-55 MA------SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA 48\n"
42 + "Q93XJ9_SOLTU/1-55 MA------SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA 48\n"
43 + "FER1_PEA/1-60 MATT---PALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFLGLKT-SLKRGDLAVAMA 53\n\n"
44 + "FER_CAPAA/1-8 SYKVKLI 8\n"
45 + "FER_CAPAN/1-55 SYKVKLI 55\n"
46 + "FER1_SOLLC/1-55 SYKVKLI 55\n"
47 + "Q93XJ9_SOLTU/1-55 SYKVKLI 55\n"
48 + "FER1_PEA/1-60 SYKVKLV 60\n"
49 + " .* .:....*******..** ..........** ********...*:::* ...\n"
52 ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
54 SequenceI[] seqs = cf.getSeqsAsArray();
55 assertEquals(seqs.length, 5);
56 assertEquals(seqs[0].getName(), "FER_CAPAA");
57 assertEquals(seqs[0].getStart(), 1);
58 assertEquals(seqs[0].getEnd(), 8);
59 assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));
62 @Test(groups = "Functional")
63 public void testParse_noNumbering() throws IOException
66 String data = "CLUSTAL\n\n"
67 + "FER_CAPAA/1-8 -----------------------------------------------------------A\n"
68 + "FER_CAPAN/1-55 MA------SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALFGLKS-A--NGGKVTCMA\n"
69 + "FER1_SOLLC/1-55 MA------SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA\n"
70 + "Q93XJ9_SOLTU/1-55 MA------SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMA\n"
71 + "FER1_PEA/1-60 MATT---PALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFLGLKT-SLKRGDLAVAMA\n\n"
72 + "FER_CAPAA/1-8 SYKVKLI\n"
73 + "FER_CAPAN/1-55 SYKVKLI\n"
74 + "FER1_SOLLC/1-55 SYKVKLI\n"
75 + "Q93XJ9_SOLTU/1-55 SYKVKLI\n"
76 + "FER1_PEA/1-60 SYKVKLV\n";
78 ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
80 SequenceI[] seqs = cf.getSeqsAsArray();
81 assertEquals(seqs.length, 5);
82 assertEquals(seqs[0].getName(), "FER_CAPAA");
83 assertEquals(seqs[0].getStart(), 1);
84 assertEquals(seqs[0].getEnd(), 8);
85 assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));