Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:38:20 GMT
  2. Package jalview.gui

File StructureViewerTest.java

 

Code metrics

2
38
2
1
111
65
3
0.08
19
2
1.5

Classes

Class Line # Actions
StructureViewerTest 39 38 3
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.gui;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertFalse;
25    import static org.testng.Assert.assertNull;
26    import static org.testng.Assert.assertSame;
27    import static org.testng.Assert.assertTrue;
28   
29    import jalview.datamodel.PDBEntry;
30    import jalview.datamodel.PDBEntry.Type;
31    import jalview.datamodel.Sequence;
32    import jalview.datamodel.SequenceI;
33   
34    import java.util.Map;
35   
36    import org.testng.annotations.BeforeClass;
37    import org.testng.annotations.Test;
38   
 
39    public class StructureViewerTest
40    {
41   
 
42  1 toggle @BeforeClass(alwaysRun = true)
43    public void setUpJvOptionPane()
44    {
45  1 JvOptionPane.setInteractiveMode(false);
46  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
47    }
48   
 
49  1 toggle @Test(groups = "Functional")
50    public void testGetSequencesForPdbs()
51    {
52  1 StructureViewer sv = new StructureViewer(null);
53   
54  1 assertNull(sv.getSequencesForPdbs(null, null));
55   
56  1 PDBEntry pdbe1 = new PDBEntry("1A70", "A", Type.PDB, "path1");
57  1 PDBEntry pdbe2 = new PDBEntry("3A6S", "A", Type.PDB, "path2");
58  1 PDBEntry pdbe3 = new PDBEntry("1A70", "B", Type.PDB, "path1");
59  1 PDBEntry pdbe4 = new PDBEntry("1GAQ", "A", Type.PDB, null);
60  1 PDBEntry pdbe5 = new PDBEntry("3A6S", "B", Type.PDB, "path2");
61  1 PDBEntry pdbe6 = new PDBEntry("1GAQ", "B", Type.PDB, null);
62  1 PDBEntry pdbe7 = new PDBEntry("1FOO", "Q", Type.PDB, null);
63   
64  1 PDBEntry[] pdbs = new PDBEntry[] { pdbe1, pdbe2, pdbe3, pdbe4, pdbe5,
65    pdbe6, pdbe7 };
66   
67    /*
68    * seq1 ... seq6 associated with pdbe1 ... pdbe6
69    */
70  1 SequenceI[] seqs = new SequenceI[pdbs.length];
71  8 for (int i = 0; i < seqs.length; i++)
72    {
73  7 seqs[i] = new Sequence("Seq" + i, "abc");
74    }
75   
76    /*
77    * pdbe3/5/6 should get removed as having a duplicate file path
78    */
79  1 Map<PDBEntry, SequenceI[]> uniques = sv.getSequencesForPdbs(pdbs, seqs);
80  1 assertTrue(uniques.containsKey(pdbe1));
81  1 assertTrue(uniques.containsKey(pdbe2));
82  1 assertFalse(uniques.containsKey(pdbe3));
83  1 assertTrue(uniques.containsKey(pdbe4));
84  1 assertFalse(uniques.containsKey(pdbe5));
85  1 assertFalse(uniques.containsKey(pdbe6));
86  1 assertTrue(uniques.containsKey(pdbe7));
87   
88    // 1A70 associates with seq1 and seq3
89  1 SequenceI[] ss = uniques.get(pdbe1);
90  1 assertEquals(ss.length, 2);
91  1 assertSame(seqs[0], ss[0]);
92  1 assertSame(seqs[2], ss[1]);
93   
94    // 3A6S has seq2 and seq5
95  1 ss = uniques.get(pdbe2);
96  1 assertEquals(ss.length, 2);
97  1 assertSame(seqs[1], ss[0]);
98  1 assertSame(seqs[4], ss[1]);
99   
100    // 1GAQ has seq4 and seq6
101  1 ss = uniques.get(pdbe4);
102  1 assertEquals(ss.length, 2);
103  1 assertSame(seqs[3], ss[0]);
104  1 assertSame(seqs[5], ss[1]);
105   
106    // 1FOO has seq7
107  1 ss = uniques.get(pdbe7);
108  1 assertEquals(ss.length, 1);
109  1 assertSame(seqs[6], ss[0]);
110    }
111    }