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