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.
21 package jalview.structures.models;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertTrue;
27 import jalview.datamodel.Alignment;
28 import jalview.datamodel.AlignmentI;
29 import jalview.datamodel.PDBEntry;
30 import jalview.datamodel.PDBEntry.Type;
31 import jalview.datamodel.Sequence;
32 import jalview.datamodel.SequenceI;
33 import jalview.io.AppletFormatAdapter;
34 import jalview.structure.AtomSpec;
35 import jalview.structure.StructureSelectionManager;
36 import jalview.structures.models.AAStructureBindingModel.SuperposeData;
38 import java.util.Arrays;
39 import java.util.List;
41 import org.testng.annotations.BeforeMethod;
42 import org.testng.annotations.Test;
45 * Unit tests for non-abstract methods of abstract base class
50 public class AAStructureBindingModelTest
53 * Scenario: Jalview has 4 sequences, corresponding to 1YCS (chains A and B), 3A6S|B, 1OOT|A
55 private static final String PDB_1 = "HEADER COMPLEX (ANTI-ONCOGENE/ANKYRIN REPEATS) 30-SEP-96 1YCS \n"
56 + "ATOM 2 CA VAL A 97 24.134 4.926 45.821 1.00 47.43 C \n"
57 + "ATOM 9 CA PRO A 98 25.135 8.584 46.217 1.00 41.60 C \n"
58 + "ATOM 16 CA SER A 99 28.243 9.596 44.271 1.00 39.63 C \n"
59 + "ATOM 22 CA GLN A 100 31.488 10.133 46.156 1.00 35.60 C \n"
60 // artificial jump in residue numbering to prove it is correctly
62 + "ATOM 31 CA LYS A 102 33.323 11.587 43.115 1.00 41.69 C \n"
63 + "ATOM 1857 CA GLU B 374 9.193 -16.005 95.870 1.00 54.22 C \n"
64 + "ATOM 1866 CA ILE B 375 7.101 -14.921 92.847 1.00 46.82 C \n"
65 + "ATOM 1874 CA VAL B 376 10.251 -13.625 91.155 1.00 47.80 C \n"
66 + "ATOM 1881 CA LYS B 377 11.767 -17.068 91.763 1.00 50.21 C \n"
67 + "ATOM 1890 CA PHE B 378 8.665 -18.948 90.632 1.00 44.85 C \n";
69 private static final String PDB_2 = "HEADER HYDROLASE 09-SEP-09 3A6S \n"
70 + "ATOM 2 CA MET B 1 15.366 -11.648 24.854 1.00 32.05 C \n"
71 + "ATOM 10 CA LYS B 2 16.846 -9.215 22.340 1.00 25.68 C \n"
72 + "ATOM 19 CA LYS B 3 15.412 -6.335 20.343 1.00 19.42 C \n"
73 + "ATOM 28 CA LEU B 4 15.629 -5.719 16.616 1.00 15.49 C \n"
74 + "ATOM 36 CA GLN B 5 14.412 -2.295 15.567 1.00 12.19 C \n";
76 private static final String PDB_3 = "HEADER STRUCTURAL GENOMICS 04-MAR-03 1OOT \n"
77 + "ATOM 2 CA SER A 7 29.427 3.330 -6.578 1.00 32.50 C \n"
78 + "ATOM 8 CA PRO A 8 29.975 3.340 -2.797 1.00 17.62 C \n"
79 + "ATOM 16 CA ALYS A 9 26.958 3.024 -0.410 0.50 8.78 C \n"
80 + "ATOM 33 CA ALA A 10 26.790 4.320 3.172 1.00 11.98 C \n"
81 + "ATOM 39 CA AVAL A 12 24.424 3.853 6.106 0.50 13.83 C \n";
83 AAStructureBindingModel testee;
88 * Set up test conditions with three aligned sequences,
90 @BeforeMethod(alwaysRun = true)
93 SequenceI seq1a = new Sequence("1YCS|A", "-VPSQK");
94 SequenceI seq1b = new Sequence("1YCS|B", "EIVKF-");
95 SequenceI seq2 = new Sequence("3A6S", "MK-KLQ");
96 SequenceI seq3 = new Sequence("1OOT", "SPK-AV");
97 al = new Alignment(new SequenceI[] { seq1a, seq1b, seq2, seq3 });
101 * give pdb files the name generated by Jalview for PASTE source
103 PDBEntry[] pdbFiles = new PDBEntry[3];
104 pdbFiles[0] = new PDBEntry("1YCS", "A", Type.PDB, "INLINE1YCS");
105 pdbFiles[1] = new PDBEntry("3A6S", "B", Type.PDB, "INLINE3A6S");
106 pdbFiles[2] = new PDBEntry("1OOT", "A", Type.PDB, "INLINE1OOT");
107 String[][] chains = new String[3][];
108 SequenceI[][] seqs = new SequenceI[3][];
109 seqs[0] = new SequenceI[] { seq1a, seq1b };
110 seqs[1] = new SequenceI[] { seq2 };
111 seqs[2] = new SequenceI[] { seq3 };
112 StructureSelectionManager ssm = new StructureSelectionManager();
114 ssm.setMapping(new SequenceI[] { seq1a, seq1b }, null, PDB_1,
115 AppletFormatAdapter.PASTE);
116 ssm.setMapping(new SequenceI[] { seq2 }, null, PDB_2,
117 AppletFormatAdapter.PASTE);
118 ssm.setMapping(new SequenceI[] { seq3 }, null, PDB_3,
119 AppletFormatAdapter.PASTE);
121 testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, chains, null)
124 public String[] getPdbFile()
126 return new String[] { "INLINE1YCS", "INLINE3A6S", "INLINE1OOT" };
130 public void updateColours(Object source)
135 public void releaseReferences(Object svl)
140 public void highlightAtoms(List<AtomSpec> atoms)
147 * Verify that the method determines that columns 2, 5 and 6 of the alignment
148 * are alignable in structure
150 @Test(groups = { "Functional" })
151 public void testFindSuperposableResidues()
154 * create a data bean to hold data per structure file
156 SuperposeData[] structs = new SuperposeData[testee.getPdbFile().length];
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);
168 int refStructure = testee
169 .findSuperposableResidues(al, matched, structs);
171 assertEquals(0, refStructure);
174 * only ungapped, structure-mapped columns are superposable
176 assertFalse(matched[0]); // gap in first sequence
177 assertTrue(matched[1]);
178 assertFalse(matched[2]); // gap in third sequence
179 assertFalse(matched[3]); // gap in fourth sequence
180 assertTrue(matched[4]);
181 assertTrue(matched[5]); // gap in second sequence
183 assertEquals("1YCS", structs[0].pdbId);
184 assertEquals("3A6S", structs[1].pdbId);
185 assertEquals("1OOT", structs[2].pdbId);
186 assertEquals("A", structs[0].chain); // ? struct has chains A _and_ B
187 assertEquals("B", structs[1].chain);
188 assertEquals("A", structs[2].chain);
189 // the 0's for unsuperposable positions propagate down the columns:
190 assertEquals("[0, 97, 98, 99, 100, 102]",
191 Arrays.toString(structs[0].pdbResNo));
192 assertEquals("[0, 2, 0, 3, 4, 5]", Arrays.toString(structs[1].pdbResNo));
193 assertEquals("[0, 8, 0, 0, 10, 12]",
194 Arrays.toString(structs[2].pdbResNo));
197 @Test(groups = { "Functional" })
198 public void testFindSuperposableResidues_hiddenColumn()
200 SuperposeData[] structs = new SuperposeData[al.getHeight()];
201 for (int i = 0; i < structs.length; i++)
203 structs[i] = testee.new SuperposeData(al.getWidth());
206 * initialise array of 'superposable columns' to true (would be false for
209 boolean[] matched = new boolean[al.getWidth()];
210 Arrays.fill(matched, true);
211 // treat column 5 of the alignment as hidden
214 int refStructure = testee
215 .findSuperposableResidues(al, matched, structs);
217 assertEquals(0, refStructure);
219 // only ungapped, structure-mapped columns are not superposable
220 assertFalse(matched[0]);
221 assertTrue(matched[1]);
222 assertFalse(matched[2]);
223 assertFalse(matched[3]);
224 assertFalse(matched[4]); // superposable, but hidden, column
225 assertTrue(matched[5]);