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