JAL-4366 build a mapping to a PDBChain with an arbitrary SequenceMapping
authorJames Procter <j.procter@dundee.ac.uk>
Fri, 15 Dec 2023 13:56:57 +0000 (13:56 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Fri, 15 Dec 2023 13:56:57 +0000 (13:56 +0000)
src/mc_view/PDBChain.java

index 2970ccf..7e220bb 100755 (executable)
@@ -187,6 +187,39 @@ public class PDBChain
   }
 
   /**
+   * like makeExactMapping but using a sequence mapping object
+   * @param sqmpping
+   * @param seq
+   */
+  public void mapChainWith(Mapping sqmpping, SequenceI seq)
+  {
+    for (Atom atom : atoms)
+    {
+      atom.alignmentMapping = -1;
+    }
+    // and now map sqmapping to the atom set.
+    int[] range = sqmpping.locateRange(seq.getStart(),seq.getEnd());
+    int r=0,from,to;
+    while (r<range.length)
+    {
+      from=range[r++];
+      to=range[r++];
+      for (int pdbpos=from;pdbpos<=to;pdbpos++)
+      {
+        if (pdbpos >= residues.size())
+        {
+          continue;
+        }
+        Residue res = residues.elementAt(pdbpos);
+        for (Atom atom : res.atoms)
+        {
+          atom.alignmentMapping = sqmpping.getPosition(pdbpos);
+        }
+      }
+    }    
+  }
+
+  /**
    * Annotate the residues with their corresponding positions in s1 using the
    * alignment in as NOTE: This clears all atom.alignmentMapping values on the
    * structure.