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