1 package jalview.structures.models;
3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertFalse;
5 import static org.testng.AssertJUnit.assertTrue;
6 import org.testng.annotations.Test;
7 import org.testng.annotations.BeforeMethod;
8 import java.util.Arrays;
11 import jalview.datamodel.Alignment;
12 import jalview.datamodel.AlignmentI;
13 import jalview.datamodel.PDBEntry;
14 import jalview.datamodel.PDBEntry.Type;
15 import jalview.datamodel.Sequence;
16 import jalview.datamodel.SequenceI;
17 import jalview.io.AppletFormatAdapter;
18 import jalview.structure.AtomSpec;
19 import jalview.structure.StructureSelectionManager;
20 import jalview.structures.models.AAStructureBindingModel.SuperposeData;
23 * Unit tests for non-abstract methods of abstract base class
28 public class AAStructureBindingModelTest
30 private static final String PDB_1 = "HEADER COMPLEX (ANTI-ONCOGENE/ANKYRIN REPEATS) 30-SEP-96 1YCS \n"
31 + "ATOM 2 CA VAL A 97 24.134 4.926 45.821 1.00 47.43 C \n"
32 + "ATOM 9 CA PRO A 98 25.135 8.584 46.217 1.00 41.60 C \n"
33 + "ATOM 16 CA SER A 99 28.243 9.596 44.271 1.00 39.63 C \n"
34 + "ATOM 22 CA GLN A 100 31.488 10.133 46.156 1.00 35.60 C \n"
35 + "ATOM 31 CA LYS A 101 33.323 11.587 43.115 1.00 41.69 C \n";
37 private static final String PDB_2 = "HEADER HYDROLASE 09-SEP-09 3A6S \n"
38 + "ATOM 2 CA MET A 1 15.366 -11.648 24.854 1.00 32.05 C \n"
39 + "ATOM 10 CA LYS A 2 16.846 -9.215 22.340 1.00 25.68 C \n"
40 + "ATOM 19 CA LYS A 3 15.412 -6.335 20.343 1.00 19.42 C \n"
41 + "ATOM 28 CA LEU A 4 15.629 -5.719 16.616 1.00 15.49 C \n"
42 + "ATOM 36 CA GLN A 5 14.412 -2.295 15.567 1.00 12.19 C \n";
44 private static final String PDB_3 = "HEADER STRUCTURAL GENOMICS 04-MAR-03 1OOT \n"
45 + "ATOM 2 CA SER A 1 29.427 3.330 -6.578 1.00 32.50 C \n"
46 + "ATOM 8 CA PRO A 2 29.975 3.340 -2.797 1.00 17.62 C \n"
47 + "ATOM 16 CA ALYS A 3 26.958 3.024 -0.410 0.50 8.78 C \n"
48 + "ATOM 33 CA ALA A 4 26.790 4.320 3.172 1.00 11.98 C \n"
49 + "ATOM 39 CA AVAL A 5 24.424 3.853 6.106 0.50 13.83 C \n";
51 AAStructureBindingModel testee;
56 * Set up test conditions with three aligned sequences,
61 SequenceI seq1 = new Sequence("1YCS", "-VPSQK");
62 SequenceI seq2 = new Sequence("3A6S", "MK-KLQ");
63 SequenceI seq3 = new Sequence("1OOT", "SPK-AV");
64 al = new Alignment(new SequenceI[]
65 { seq1, seq2, seq3 });
68 PDBEntry[] pdbFiles = new PDBEntry[3];
69 pdbFiles[0] = new PDBEntry("1YCS", "A", Type.PDB, "1YCS.pdb");
70 pdbFiles[1] = new PDBEntry("3A6S", "B", Type.PDB, "3A6S.pdb");
71 pdbFiles[2] = new PDBEntry("1OOT", "A", Type.PDB, "1OOT.pdb");
72 String[][] chains = new String[3][];
73 SequenceI[][] seqs = new SequenceI[3][];
74 seqs[0] = new SequenceI[]
76 seqs[1] = new SequenceI[]
78 seqs[2] = new SequenceI[]
80 StructureSelectionManager ssm = new StructureSelectionManager();
82 ssm.setMapping(new SequenceI[]
83 { seq1 }, null, PDB_1, AppletFormatAdapter.PASTE);
84 ssm.setMapping(new SequenceI[]
85 { seq2 }, null, PDB_2, AppletFormatAdapter.PASTE);
86 ssm.setMapping(new SequenceI[]
87 { seq3 }, null, PDB_3, AppletFormatAdapter.PASTE);
89 testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, chains, null)
92 public String[] getPdbFile()
95 * fudge 'filenames' to match those generated when PDBFile parses PASTE
99 { "INLINE1YCS", "INLINE3A6S", "INLINE1OOT" };
102 public void updateColours(Object source)
106 public void releaseReferences(Object svl)
110 public void highlightAtoms(List<AtomSpec> atoms)
117 * Verify that the method determines that columns 2, 5 and 6 of the aligment
118 * are alignable in structure
121 public void testFindSuperposableResidues()
123 SuperposeData[] structs = new SuperposeData[al.getHeight()];
124 for (int i = 0; i < structs.length; i++)
126 structs[i] = testee.new SuperposeData(al.getWidth());
129 * initialise array of 'superposable columns' to true (would be false for
132 boolean[] matched = new boolean[al.getWidth()];
133 Arrays.fill(matched, true);
135 int refStructure = testee
136 .findSuperposableResidues(al, matched, structs);
138 assertEquals(0, refStructure);
141 * only ungapped, structure-mapped columns are superposable
143 assertFalse(matched[0]); // gap in first sequence
144 assertTrue(matched[1]);
145 assertFalse(matched[2]); // gap in second sequence
146 assertFalse(matched[3]); // gap in third sequence
147 assertTrue(matched[4]);
148 assertTrue(matched[5]);
152 public void testFindSuperposableResidues_hiddenColumn()
154 SuperposeData[] structs = new SuperposeData[al.getHeight()];
155 for (int i = 0; i < structs.length; i++)
157 structs[i] = testee.new SuperposeData(al.getWidth());
160 * initialise array of 'superposable columns' to true (would be false for
163 boolean[] matched = new boolean[al.getWidth()];
164 Arrays.fill(matched, true);
165 // treat column 5 of the alignment as hidden
168 int refStructure = testee
169 .findSuperposableResidues(al, matched, structs);
171 assertEquals(0, refStructure);
173 // only ungapped, structure-mapped columns are not superposable
174 assertFalse(matched[0]);
175 assertTrue(matched[1]);
176 assertFalse(matched[2]);
177 assertFalse(matched[3]);
178 assertFalse(matched[4]); // superposable, but hidden, column
179 assertTrue(matched[5]);