Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 16:21:17 GMT
  2. Package jalview.io

File ClustalFileTest.java

 

Code metrics

0
18
2
1
87
57
2
0.11
9
2
1

Classes

Class Line # Actions
ClustalFileTest 32 18 2
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

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 jalview.datamodel.SequenceI;
27   
28    import java.io.IOException;
29   
30    import org.testng.annotations.Test;
31   
 
32    public class ClustalFileTest
33    {
 
34  1 toggle @Test(groups = "Functional")
35    public void testParse_withNumbering() throws IOException
36    {
37    //@formatter:off
38  1 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"
50    + "\t\t.:.::. *\n";
51    //@formatter:on
52  1 ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
53  1 cf.parse();
54  1 SequenceI[] seqs = cf.getSeqsAsArray();
55  1 assertEquals(seqs.length, 5);
56  1 assertEquals(seqs[0].getName(), "FER_CAPAA");
57  1 assertEquals(seqs[0].getStart(), 1);
58  1 assertEquals(seqs[0].getEnd(), 8);
59  1 assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));
60    }
61   
 
62  1 toggle @Test(groups = "Functional")
63    public void testParse_noNumbering() throws IOException
64    {
65    //@formatter:off
66  1 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";
77    //@formatter:on
78  1 ClustalFile cf = new ClustalFile(data, DataSourceType.PASTE);
79  1 cf.parse();
80  1 SequenceI[] seqs = cf.getSeqsAsArray();
81  1 assertEquals(seqs.length, 5);
82  1 assertEquals(seqs[0].getName(), "FER_CAPAA");
83  1 assertEquals(seqs[0].getStart(), 1);
84  1 assertEquals(seqs[0].getEnd(), 8);
85  1 assertTrue(seqs[0].getSequenceAsString().endsWith("ASYKVKLI"));
86    }
87    }