JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / structure / StructureMapping.js
1 Clazz.declarePackage ("jalview.structure");\r
2 Clazz.load (null, "jalview.structure.StructureMapping", ["jalview.datamodel.AlignmentAnnotation"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.mappingDetails = null;\r
5 this.sequence = null;\r
6 this.pdbfile = null;\r
7 this.pdbid = null;\r
8 this.pdbchain = null;\r
9 this.mapping = null;\r
10 Clazz.instantialize (this, arguments);\r
11 }, jalview.structure, "StructureMapping");\r
12 Clazz.makeConstructor (c$, \r
13 function (seq, pdbfile, pdbid, chain, mapping, mappingDetails) {\r
14 this.sequence = seq;\r
15 this.pdbfile = pdbfile;\r
16 this.pdbid = pdbid;\r
17 this.pdbchain = chain;\r
18 this.mapping = mapping;\r
19 this.mappingDetails = mappingDetails;\r
20 }, "jalview.datamodel.SequenceI,~S,~S,~S,~A,~S");\r
21 Clazz.defineMethod (c$, "getSequence", \r
22 function () {\r
23 return this.sequence;\r
24 });\r
25 Clazz.defineMethod (c$, "getChain", \r
26 function () {\r
27 return this.pdbchain;\r
28 });\r
29 Clazz.defineMethod (c$, "getPdbId", \r
30 function () {\r
31 return this.pdbid;\r
32 });\r
33 Clazz.defineMethod (c$, "getAtomNum", \r
34 function (seqpos) {\r
35 if (this.mapping.length > seqpos) {\r
36 return this.mapping[seqpos][1];\r
37 } else {\r
38 return 0;\r
39 }}, "~N");\r
40 Clazz.defineMethod (c$, "getPDBResNum", \r
41 function (seqpos) {\r
42 if (this.mapping.length > seqpos) {\r
43 return this.mapping[seqpos][0];\r
44 } else {\r
45 return 0;\r
46 }}, "~N");\r
47 Clazz.defineMethod (c$, "getSeqPos", \r
48 function (pdbResNum) {\r
49 for (var i = 0; i < this.mapping.length; i++) {\r
50 if (this.mapping[i][0] == pdbResNum) {\r
51 return i;\r
52 }}\r
53 return -1;\r
54 }, "~N");\r
55 Clazz.defineMethod (c$, "transfer", \r
56 function (ana) {\r
57 var ala_copy =  new jalview.datamodel.AlignmentAnnotation (ana);\r
58 var ds = this.sequence;\r
59 while (ds.getDatasetSequence () != null) {\r
60 ds = ds.getDatasetSequence ();\r
61 }\r
62 ala_copy.remap (ds, this.mapping, -1, -1, 0);\r
63 ds.addAlignmentAnnotation (ala_copy);\r
64 if (ds !== this.sequence) {\r
65 ala_copy =  new jalview.datamodel.AlignmentAnnotation (ala_copy);\r
66 this.sequence.addAlignmentAnnotation (ala_copy);\r
67 }return ala_copy;\r
68 }, "jalview.datamodel.AlignmentAnnotation");\r
69 });\r