3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertFalse;
5 import static org.testng.Assert.assertNull;
6 import static org.testng.Assert.assertSame;
7 import static org.testng.Assert.assertTrue;
9 import jalview.datamodel.PDBEntry;
10 import jalview.datamodel.PDBEntry.Type;
11 import jalview.datamodel.Sequence;
12 import jalview.datamodel.SequenceI;
16 import org.testng.annotations.BeforeClass;
17 import org.testng.annotations.Test;
19 public class StructureViewerTest
22 @BeforeClass(alwaysRun = true)
23 public void setUpJvOptionPane()
25 JvOptionPane.setInteractiveMode(false);
26 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
29 @Test(groups = "Functional")
30 public void testGetSequencesForPdbs()
32 StructureViewer sv = new StructureViewer(null);
34 assertNull(sv.getSequencesForPdbs(null, null));
36 PDBEntry pdbe1 = new PDBEntry("1A70", "A", Type.PDB, "path1");
37 PDBEntry pdbe2 = new PDBEntry("3A6S", "A", Type.PDB, "path2");
38 PDBEntry pdbe3 = new PDBEntry("1A70", "B", Type.PDB, "path1");
39 PDBEntry pdbe4 = new PDBEntry("1GAQ", "A", Type.PDB, null);
40 PDBEntry pdbe5 = new PDBEntry("3A6S", "B", Type.PDB, "path2");
41 PDBEntry pdbe6 = new PDBEntry("1GAQ", "B", Type.PDB, null);
42 PDBEntry pdbe7 = new PDBEntry("1FOO", "Q", Type.PDB, null);
44 PDBEntry[] pdbs = new PDBEntry[] { pdbe1, pdbe2, pdbe3, pdbe4, pdbe5,
48 * seq1 ... seq6 associated with pdbe1 ... pdbe6
50 SequenceI[] seqs = new SequenceI[pdbs.length];
51 for (int i = 0; i < seqs.length; i++)
53 seqs[i] = new Sequence("Seq" + i, "abc");
57 * pdbe3/5/6 should get removed as having a duplicate file path
59 Map<PDBEntry, SequenceI[]> uniques = sv.getSequencesForPdbs(pdbs, seqs);
60 assertTrue(uniques.containsKey(pdbe1));
61 assertTrue(uniques.containsKey(pdbe2));
62 assertFalse(uniques.containsKey(pdbe3));
63 assertTrue(uniques.containsKey(pdbe4));
64 assertFalse(uniques.containsKey(pdbe5));
65 assertFalse(uniques.containsKey(pdbe6));
66 assertTrue(uniques.containsKey(pdbe7));
68 // 1A70 associates with seq1 and seq3
69 SequenceI[] ss = uniques.get(pdbe1);
70 assertEquals(ss.length, 2);
71 assertSame(seqs[0], ss[0]);
72 assertSame(seqs[2], ss[1]);
74 // 3A6S has seq2 and seq5
75 ss = uniques.get(pdbe2);
76 assertEquals(ss.length, 2);
77 assertSame(seqs[1], ss[0]);
78 assertSame(seqs[4], ss[1]);
80 // 1GAQ has seq4 and seq6
81 ss = uniques.get(pdbe4);
82 assertEquals(ss.length, 2);
83 assertSame(seqs[3], ss[0]);
84 assertSame(seqs[5], ss[1]);
87 ss = uniques.get(pdbe7);
88 assertEquals(ss.length, 1);
89 assertSame(seqs[6], ss[0]);