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.assertFalse;
25 import static org.testng.Assert.assertNull;
26 import static org.testng.Assert.assertSame;
27 import static org.testng.Assert.assertTrue;
29 import jalview.datamodel.PDBEntry;
30 import jalview.datamodel.PDBEntry.Type;
31 import jalview.datamodel.Sequence;
32 import jalview.datamodel.SequenceI;
36 import org.testng.annotations.BeforeClass;
37 import org.testng.annotations.Test;
39 public class StructureViewerTest
42 @BeforeClass(alwaysRun = true)
43 public void setUpJvOptionPane()
45 JvOptionPane.setInteractiveMode(false);
46 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
49 @Test(groups = "Functional")
50 public void testGetSequencesForPdbs()
52 StructureViewer sv = new StructureViewer(null);
54 assertNull(sv.getSequencesForPdbs(null, null));
56 PDBEntry pdbe1 = new PDBEntry("1A70", "A", Type.PDB, "path1");
57 PDBEntry pdbe2 = new PDBEntry("3A6S", "A", Type.PDB, "path2");
58 PDBEntry pdbe3 = new PDBEntry("1A70", "B", Type.PDB, "path1");
59 PDBEntry pdbe4 = new PDBEntry("1GAQ", "A", Type.PDB, null);
60 PDBEntry pdbe5 = new PDBEntry("3A6S", "B", Type.PDB, "path2");
61 PDBEntry pdbe6 = new PDBEntry("1GAQ", "B", Type.PDB, null);
62 PDBEntry pdbe7 = new PDBEntry("1FOO", "Q", Type.PDB, null);
64 PDBEntry[] pdbs = new PDBEntry[] { pdbe1, pdbe2, pdbe3, pdbe4, pdbe5,
68 * seq1 ... seq6 associated with pdbe1 ... pdbe6
70 SequenceI[] seqs = new SequenceI[pdbs.length];
71 for (int i = 0; i < seqs.length; i++)
73 seqs[i] = new Sequence("Seq" + i, "abc");
77 * pdbe3/5/6 should get removed as having a duplicate file path
79 Map<PDBEntry, SequenceI[]> uniques = sv.getSequencesForPdbs(pdbs, seqs);
80 assertTrue(uniques.containsKey(pdbe1));
81 assertTrue(uniques.containsKey(pdbe2));
82 assertFalse(uniques.containsKey(pdbe3));
83 assertTrue(uniques.containsKey(pdbe4));
84 assertFalse(uniques.containsKey(pdbe5));
85 assertFalse(uniques.containsKey(pdbe6));
86 assertTrue(uniques.containsKey(pdbe7));
88 // 1A70 associates with seq1 and seq3
89 SequenceI[] ss = uniques.get(pdbe1);
90 assertEquals(ss.length, 2);
91 assertSame(seqs[0], ss[0]);
92 assertSame(seqs[2], ss[1]);
94 // 3A6S has seq2 and seq5
95 ss = uniques.get(pdbe2);
96 assertEquals(ss.length, 2);
97 assertSame(seqs[1], ss[0]);
98 assertSame(seqs[4], ss[1]);
100 // 1GAQ has seq4 and seq6
101 ss = uniques.get(pdbe4);
102 assertEquals(ss.length, 2);
103 assertSame(seqs[3], ss[0]);
104 assertSame(seqs[5], ss[1]);
107 ss = uniques.get(pdbe7);
108 assertEquals(ss.length, 1);
109 assertSame(seqs[6], ss[0]);