1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structure; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertTrue; |
25 |
|
|
26 |
|
import org.testng.Assert; |
27 |
|
import org.testng.AssertJUnit; |
28 |
|
import org.testng.annotations.BeforeClass; |
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
31 |
|
import jalview.datamodel.AlignmentAnnotation; |
32 |
|
import jalview.datamodel.Annotation; |
33 |
|
import jalview.datamodel.Sequence; |
34 |
|
import jalview.datamodel.SequenceI; |
35 |
|
import jalview.gui.AlignFrame; |
36 |
|
import jalview.gui.JvOptionPane; |
37 |
|
import jalview.io.DataSourceType; |
38 |
|
import jalview.io.FileFormat; |
39 |
|
import jalview.io.FileLoader; |
40 |
|
import jalview.io.StructureFile; |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 138 (138) |
Complexity: 18 |
Complexity Density: 0.17 |
|
42 |
|
public class Mapping |
43 |
|
{ |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
45 |
0 |
@BeforeClass(alwaysRun = true)... |
46 |
|
public void setUpJvOptionPane() |
47 |
|
{ |
48 |
0 |
JvOptionPane.setInteractiveMode(false); |
49 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 2 |
Complexity Density: 0.05 |
|
59 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
60 |
|
public void pdbEntryPositionMap() throws Exception |
61 |
|
{ |
62 |
0 |
Assert.fail("This test intentionally left to fail"); |
63 |
0 |
for (int offset = 0; offset < 20; offset += 6) |
64 |
|
{ |
65 |
|
|
66 |
0 |
Sequence uprot = new Sequence("TheProtSeq", |
67 |
|
"DAWEIPRESLKLEKKLGAGQFGEVWMATYNKHTKVAVKTMKPGSMSVEAFLAEANVMKTL"); |
68 |
0 |
uprot.setStart(offset + 258); |
69 |
|
|
70 |
|
|
71 |
0 |
uprot.setEnd(uprot.getStart() + uprot.getLength() - 1); |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
0 |
int coils[] = { 266, 275, 278, 287, 289, 298, 302, 316 }, |
76 |
|
helices[] = new int[] |
77 |
|
{ 303, 315 }, sheets[] = new int[] { 267, 268, 269, 270 }; |
78 |
|
|
79 |
0 |
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager(); |
80 |
0 |
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { uprot }, |
81 |
|
new String[] |
82 |
|
{ "A" }, "test/jalview/ext/jmol/1QCF.pdb", |
83 |
|
DataSourceType.FILE, null, null); |
84 |
0 |
assertTrue(pmap != null); |
85 |
0 |
SequenceI protseq = pmap.getSeqsAsArray()[0]; |
86 |
0 |
AlignmentAnnotation pstra = protseq |
87 |
|
.getAnnotation("Secondary Structure")[0]; |
88 |
0 |
int pinds, pinde; |
89 |
0 |
pstra.restrict((pinds = protseq.findIndex(258) - 1), |
90 |
|
pinde = (protseq.findIndex(317) - 1)); |
91 |
0 |
int op; |
92 |
0 |
System.out.println("PDB Annot"); |
93 |
0 |
for (char c : protseq.getSubSequence(pinds, pinde).getSequence()) |
94 |
|
{ |
95 |
0 |
System.out.print(c + ", "); |
96 |
|
} |
97 |
0 |
System.out.println("\n" + pstra + "\n\nsubsequence\n"); |
98 |
0 |
for (char c : uprot.getSequence()) |
99 |
|
{ |
100 |
0 |
System.out.print(c + ", "); |
101 |
|
} |
102 |
0 |
System.out.println(""); |
103 |
0 |
for (AlignmentAnnotation ss : uprot |
104 |
|
.getAnnotation("Secondary Structure")) |
105 |
|
{ |
106 |
0 |
ss.adjustForAlignment(); |
107 |
0 |
System.out.println("Uniprot Annot\n" + ss); |
108 |
0 |
assertTrue(ss.hasIcons); |
109 |
0 |
char expected = 'H'; |
110 |
0 |
for (int p : helices) |
111 |
|
{ |
112 |
0 |
Annotation a = ss.annotations[op = (uprot.findIndex(offset + p) |
113 |
|
- 1)]; |
114 |
0 |
assertTrue("Expected a helix at position " + p |
115 |
|
+ uprot.getCharAt(op) + " but got coil", a != null); |
116 |
0 |
assertEquals("Expected a helix at position " + p, |
117 |
|
a.secondaryStructure, expected); |
118 |
|
} |
119 |
0 |
expected = 'E'; |
120 |
0 |
for (int p : sheets) |
121 |
|
{ |
122 |
0 |
Annotation a = ss.annotations[uprot.findIndex(offset + p) - 1]; |
123 |
0 |
assertTrue("Expected a strand at position " + p + " but got coil", |
124 |
|
a != null); |
125 |
0 |
assertEquals("Expected a strand at position " + p, |
126 |
|
a.secondaryStructure, expected); |
127 |
|
} |
128 |
0 |
expected = ' '; |
129 |
0 |
for (int p : coils) |
130 |
|
{ |
131 |
0 |
Annotation a = ss.annotations[uprot.findIndex(offset + p) - 1]; |
132 |
0 |
assertTrue("Expected coil at position " + p + " but got " |
133 |
|
+ a.secondaryStructure, a == null); |
134 |
|
} |
135 |
|
} |
136 |
|
} |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 10 |
Complexity Density: 0.26 |
|
139 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
140 |
|
public void testPDBentryMapping() throws Exception |
141 |
|
{ |
142 |
0 |
Assert.fail("This test intentionally left to fail"); |
143 |
0 |
Sequence sq = new Sequence("1GAQ A subseq 126 to 219", |
144 |
|
"EIVKGVCSNFLCDLQPGDNVQITGPVGKEMLMPKDPNATIIMLATGTGIAPFRSFLWKMFFEKHDDYKFNGLGWLFLGVPTSSSLLYKEEFGKM"); |
145 |
0 |
Sequence sq1 = new Sequence(sq); |
146 |
0 |
String inFile; |
147 |
0 |
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager(); |
148 |
|
|
149 |
|
|
150 |
0 |
StructureFile pde = ssm.setMapping(true, new SequenceI[] { sq }, |
151 |
|
new String[] |
152 |
|
{ "A" }, inFile = "examples/1gaq.txt", DataSourceType.FILE, |
153 |
|
null, null); |
154 |
0 |
assertTrue("PDB File couldn't be found", pde != null); |
155 |
0 |
StructureMapping[] mp = ssm.getMapping(inFile); |
156 |
0 |
assertTrue("No mappings made.", mp != null && mp.length > 0); |
157 |
0 |
int nsecStr = 0, nsTemp = 0; |
158 |
|
|
159 |
0 |
for (AlignmentAnnotation alan : sq.getAnnotation()) |
160 |
|
{ |
161 |
0 |
if (alan.hasIcons) |
162 |
|
{ |
163 |
0 |
nsecStr++; |
164 |
|
} |
165 |
0 |
if (alan.graph == alan.LINE_GRAPH) |
166 |
|
{ |
167 |
0 |
nsTemp++; |
168 |
|
} |
169 |
|
} |
170 |
0 |
assertEquals( |
171 |
|
"Only one secondary structure should be transferred to associated sequence.", |
172 |
|
1, nsecStr); |
173 |
0 |
assertEquals( |
174 |
|
"Only two line graphs should be transferred to associated sequence.", |
175 |
|
2, nsTemp); |
176 |
|
|
177 |
0 |
for (StructureMapping origMap : mp) |
178 |
|
{ |
179 |
0 |
if (origMap.getSequence() == sq) |
180 |
|
{ |
181 |
0 |
assertEquals("Mapping was incomplete.", sq.getLength() - 1, |
182 |
|
(origMap.getPDBResNum(sq.getEnd()) |
183 |
|
- origMap.getPDBResNum(sq.getStart()))); |
184 |
|
|
185 |
|
|
186 |
0 |
assertEquals(1, origMap.getSeqPos(126)); |
187 |
0 |
SequenceI firstChain = pde.getSeqs().get(0); |
188 |
|
|
189 |
|
|
190 |
0 |
for (AlignmentAnnotation alan : firstChain.getAnnotation()) |
191 |
|
{ |
192 |
0 |
AlignmentAnnotation transfer = origMap.transfer(alan); |
193 |
0 |
System.out.println("pdb:" + firstChain.getSequenceAsString()); |
194 |
0 |
System.out.println("ann:" + alan.toString()); |
195 |
0 |
System.out.println("pdb:" + sq.getSequenceAsString()); |
196 |
0 |
System.out.println("ann:" + transfer.toString()); |
197 |
|
|
198 |
0 |
for (int p = 0, pSize = firstChain.getLength(); p < pSize; p++) |
199 |
|
{ |
200 |
|
|
201 |
0 |
int rseqpos; |
202 |
0 |
int fpos = origMap |
203 |
|
.getSeqPos(rseqpos = firstChain.findPosition(p)); |
204 |
|
|
205 |
|
|
206 |
0 |
if (fpos < 1) |
207 |
|
{ |
208 |
0 |
continue; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
0 |
int tanpos = sq.findIndex(fpos) - 1; |
215 |
0 |
if (tanpos < 0 || transfer.annotations.length <= tanpos) |
216 |
|
{ |
217 |
|
|
218 |
0 |
break; |
219 |
|
} |
220 |
|
|
221 |
0 |
Annotation a = transfer.annotations[tanpos], |
222 |
|
b = alan.annotations[p]; |
223 |
0 |
assertEquals( |
224 |
|
"Non-equivalent annotation element at " + p + "(" |
225 |
|
+ rseqpos + ")" + " expected at " + fpos |
226 |
|
+ " (alIndex " + tanpos + ")", |
227 |
0 |
a == null ? a : a.toString(), |
228 |
0 |
b == null ? b : b.toString()); |
229 |
0 |
System.out.print("(" + a + "|" + b + ")"); |
230 |
|
} |
231 |
|
|
232 |
|
} |
233 |
|
} |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
242 |
0 |
@Test(groups = { "Functional" })... |
243 |
|
public void mapFer1From3W5V() throws Exception |
244 |
|
{ |
245 |
0 |
AlignFrame seqf = new FileLoader(false).LoadFileWaitTillLoaded( |
246 |
|
">FER1_MAIZE/1-150 Ferredoxin-1, chloroplast precursor\nMATVLGSPRAPAFFFSSSSLRAAPAPTAVALPAAKVGIMGRSASSRRRLRAQATYNVKLITPEGEVELQVPD\nDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKE\nEELTGA", |
247 |
|
DataSourceType.PASTE, FileFormat.Fasta); |
248 |
0 |
SequenceI newseq = seqf.getViewport().getAlignment().getSequenceAt(0); |
249 |
0 |
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager(); |
250 |
0 |
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { newseq }, |
251 |
|
new String[] |
252 |
|
{ null }, "examples/3W5V.pdb", DataSourceType.FILE, null, null); |
253 |
0 |
if (pmap == null) |
254 |
|
{ |
255 |
0 |
AssertJUnit.fail("Couldn't make a mapping for 3W5V to FER1_MAIZE"); |
256 |
|
} |
257 |
|
} |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 3 |
Complexity Density: 0.13 |
|
263 |
0 |
@Test(groups = { "Functional" })... |
264 |
|
public void compareTransferredToRefPDBAnnot() throws Exception |
265 |
|
{ |
266 |
0 |
StructureImportSettings.setProcessSecondaryStructure(true); |
267 |
0 |
StructureImportSettings.setVisibleChainAnnotation(true); |
268 |
0 |
StructureImportSettings.setShowSeqFeatures(true); |
269 |
0 |
AlignFrame ref = new FileLoader(false).LoadFileWaitTillLoaded( |
270 |
|
"test/jalview/ext/jmol/1QCF.pdb", DataSourceType.FILE); |
271 |
0 |
SequenceI refseq = ref.getViewport().getAlignment().getSequenceAt(0); |
272 |
0 |
SequenceI newseq = new Sequence(refseq.getName() + "Copy", |
273 |
|
refseq.getSequenceAsString()); |
274 |
|
|
275 |
0 |
newseq.setStart(refseq.getStart() + 25); |
276 |
0 |
newseq.setEnd(refseq.getLength() + 25 + refseq.getStart()); |
277 |
0 |
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager(); |
278 |
0 |
ssm.setProcessSecondaryStructure(true); |
279 |
0 |
ssm.setAddTempFacAnnot(true); |
280 |
0 |
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { newseq }, |
281 |
|
new String[] |
282 |
|
{ null }, "test/jalview/ext/jmol/1QCF.pdb", DataSourceType.FILE, |
283 |
|
null, null); |
284 |
0 |
assertTrue(pmap != null); |
285 |
0 |
assertEquals("Original and copied sequence of different lengths.", |
286 |
|
refseq.getLength(), newseq.getLength()); |
287 |
0 |
assertTrue(refseq.getAnnotation() != null |
288 |
|
&& refseq.getAnnotation().length > 0); |
289 |
0 |
assertTrue(newseq.getAnnotation() != null |
290 |
|
&& newseq.getAnnotation().length > 0); |
291 |
0 |
for (AlignmentAnnotation oannot : refseq.getAnnotation()) |
292 |
|
{ |
293 |
0 |
for (AlignmentAnnotation tannot : newseq.getAnnotation(oannot.label)) |
294 |
|
{ |
295 |
0 |
for (int p = 0, pSize = refseq.getLength(); p < pSize; p++) |
296 |
|
{ |
297 |
0 |
Annotation orig = oannot.annotations[p], |
298 |
|
tran = tannot.annotations[p]; |
299 |
0 |
assertTrue("Mismatch: coil and non coil site " + p, |
300 |
|
orig == tran || orig != null && tran != null); |
301 |
0 |
if (tran != null) |
302 |
|
{ |
303 |
0 |
assertEquals("Mismatch in secondary structure at site " + p, |
304 |
|
tran.secondaryStructure, orig.secondaryStructure); |
305 |
|
} |
306 |
|
} |
307 |
|
} |
308 |
|
} |
309 |
|
} |
310 |
|
} |