[cctbxbb] Fwd: [git/cctbx] master: Making cif behavior exactly the same as pdb (throwing away SCALE records if crystal_symmetry is supplied to obtain xray_structure). With test. (bdf35cf1c)

Graeme.Winter at diamond.ac.uk Graeme.Winter at diamond.ac.uk
Fri Jun 16 01:06:28 PDT 2017


Folks,

Decided with prejudice to resolve this as

https://github.com/cctbx/cctbx_project/commit/8268c807a9063ecd59c052ddbe0cff3c2ac38262

Hope this is OK

Cheers Graeme

-----Original Message-----
From: cctbxbb-bounces at phenix-online.org [mailto:cctbxbb-bounces at phenix-online.org] On Behalf Of Graeme.Winter at diamond.ac.uk
Sent: 16 June 2017 08:56
To: cctbxbb at phenix-online.org
Subject: [cctbxbb] Fwd: [git/cctbx] master: Making cif behavior exactly the same as pdb (throwing away SCALE records if crystal_symmetry is supplied to obtain xray_structure). With test. (bdf35cf1c)

Please could people refrain from making cctbx tests dependent on phenix tools?

E.g. not

easy_run.call("phenix.cif_as_pdb %s.cif > junk.out"%prefix)

Obliged in anticipation

Cheers Graeme

Begin forwarded message:

From: CCTBX Commit via DLS Jenkins <graeme.winter at GMAIL.COM<mailto:graeme.winter at GMAIL.COM>>
Subject: [git/cctbx] master: Making cif behavior exactly the same as pdb (throwing away SCALE records if crystal_symmetry is supplied to obtain xray_structure). With test. (bdf35cf1c)
Date: 15 June 2017 at 19:43:57 BST
To: <CCTBX-COMMIT at JISCMAIL.AC.UK<mailto:CCTBX-COMMIT at JISCMAIL.AC.UK>>
Reply-To: <cctbxbb at PHENIX-ONLINE.ORG<mailto:cctbxbb at PHENIX-ONLINE.ORG>>

Repository : ssh://g18-sc-serv-04.diamond.ac.uk/cctbx
On branch  : master

________________________________


commit bdf35cf1c69d235d2578d915836aad2a739c1c15
Author: Oleg Sobolev <osobolev at lbl.gov<mailto:osobolev at lbl.gov>>
Date:   Thu Jun 15 11:43:52 2017 -0700

    Making cif behavior exactly the same as pdb (throwing away SCALE records if crystal_symmetry is supplied to obtain xray_structure). With test.


________________________________


bdf35cf1c69d235d2578d915836aad2a739c1c15
iotbx/pdb/mmcif.py                 | 24 +++++-----
iotbx/regression/tst_xray_scale.py | 93 ++++++++++++++++++++++++++++++++++++++
iotbx/run_tests.py                 |  1 +
3 files changed, 107 insertions(+), 11 deletions(-)

diff --git a/iotbx/pdb/mmcif.py b/iotbx/pdb/mmcif.py index 6a5221a6a..2b79df99a 100644
--- a/iotbx/pdb/mmcif.py
+++ b/iotbx/pdb/mmcif.py
@@ -508,17 +508,19 @@ class cif_input(iotbx.pdb.pdb_input_mixin):
     return extract_tls_from_cif_block(self.cif_block, hierarchy)

   def scale_matrix(self):
-    fractionalization_matrix = [
-      self.cif_block.get('_atom_sites.fract_transf_matrix[%s][%s]' %(i, j))
-      for i,j in ('11', '12', '13', '21', '22', '23', '31','32', '33')]
-    if fractionalization_matrix.count(None) == 9:
-      return None
-    assert fractionalization_matrix.count(None) == 0
-    fractionalization_vector = [
-      self.cif_block.get('_atom_sites.fract_transf_vector[%s]' %i) for i in '123']
-    assert fractionalization_matrix.count(None) == 0
-    return [[float(i) for i in fractionalization_matrix],
-            [float(i) for i in fractionalization_vector]]
+    if (not hasattr(self, "_scale_matrix")):
+      fractionalization_matrix = [
+        self.cif_block.get('_atom_sites.fract_transf_matrix[%s][%s]' %(i, j))
+        for i,j in ('11', '12', '13', '21', '22', '23', '31','32', '33')]
+      if fractionalization_matrix.count(None) == 9:
+        return None
+      assert fractionalization_matrix.count(None) == 0
+      fractionalization_vector = [
+        self.cif_block.get('_atom_sites.fract_transf_vector[%s]' %i) for i in '123']
+      assert fractionalization_matrix.count(None) == 0
+      self._scale_matrix = [[float(i) for i in fractionalization_matrix],
+                            [float(i) for i in fractionalization_vector]]
+    return self._scale_matrix

   def model_ids(self):
     return flex.std_string([model.id for model in self.hierarchy.models()]) diff --git a/iotbx/regression/tst_xray_scale.py b/iotbx/regression/tst_xray_scale.py
new file mode 100644
index 000000000..e1a4ec9f3
--- /dev/null
+++ b/iotbx/regression/tst_xray_scale.py
@@ -0,0 +1,93 @@
+from __future__ import division
+from libtbx import easy_run
+import iotbx.pdb
+from cctbx import crystal
+from libtbx.test_utils import approx_equal
+
+cif_str="""
+data_5JUP
+#
+_atom_sites.entry_id                    5JUP
+_atom_sites.fract_transf_matrix[1][1]   1.000000
+_atom_sites.fract_transf_matrix[1][2]   0.000000
+_atom_sites.fract_transf_matrix[1][3]   0.000000
+_atom_sites.fract_transf_matrix[2][1]   0.000000
+_atom_sites.fract_transf_matrix[2][2]   1.000000
+_atom_sites.fract_transf_matrix[2][3]   0.000000
+_atom_sites.fract_transf_matrix[3][1]   0.000000
+_atom_sites.fract_transf_matrix[3][2]   0.000000
+_atom_sites.fract_transf_matrix[3][3]   1.000000
+_atom_sites.fract_transf_vector[1]      0.00000
+_atom_sites.fract_transf_vector[2]      0.00000
+_atom_sites.fract_transf_vector[3]      0.00000
+#
+loop_
+_atom_type.symbol
+C
+MG
+N
+O
+P
+S
+#
+loop_
+_atom_site.group_PDB
+_atom_site.id
+_atom_site.type_symbol
+_atom_site.label_atom_id
+_atom_site.label_alt_id
+_atom_site.label_comp_id
+_atom_site.label_asym_id
+_atom_site.label_entity_id
+_atom_site.label_seq_id
+_atom_site.pdbx_PDB_ins_code
+_atom_site.Cartn_x
+_atom_site.Cartn_y
+_atom_site.Cartn_z
+_atom_site.occupancy
+_atom_site.B_iso_or_equiv
+_atom_site.auth_seq_id
+_atom_site.auth_comp_id
+_atom_site.auth_asym_id
+_atom_site.auth_atom_id
+_atom_site.pdbx_PDB_model_num
+ATOM   9      C  "C3'" . U   A  1  1    ? 175.229 258.091 229.127 1.00 113.67 1    U   A  "C3'" 1
+ATOM   7      C  "C4'" . U   A  1  1    ? 175.388 257.913 227.616 1.00 113.21 1    U   A  "C4'" 1
+ATOM   6      C  "C5'" . U   A  1  1    ? 174.124 257.916 226.769 1.00 114.11 1    U   A  "C5'" 1
+ATOM   10     O  "O3'" . U   A  1  1    ? 176.253 257.344 229.761 1.00 112.89 1    U   A  "O3'" 1
+ATOM   8      O  "O4'" . U   A  1  1    ? 176.291 258.974 227.185 1.00 112.70 1    U   A  "O4'" 1
+ATOM   5      O  "O5'" . U   A  1  1    ? 173.735 259.270 226.430 1.00 115.09 1    U   A  "O5'" 1
+ATOM   3      O  OP1   . U   A  1  1    ? 174.056 259.302 223.918 1.00 117.16 1    U   A  OP1   1
+ATOM   4      O  OP2   . U   A  1  1    ? 172.661 261.090 225.058 1.00 104.87 1    U   A  OP2   1
+ATOM   1      O  OP3   . U   A  1  1    ? 171.796 258.709 224.899 1.00 116.23 1    U   A  OP3   1
+ATOM   2      P  P     . U   A  1  1    ? 173.022 259.610 224.994 1.00 116.34 1    U   A  P     1
+#
+"""
+
+def run(prefix="iotbx_tst_xray_scale"):
+  """
+  Exercise obtaining exactly the same xray structure from pdb and cif.
+  Caveate is SCALE records (fract_transf_matrix). In pdb they 
+explicitly
+  suppressed when crystal_symmetry is supplied, see
+  iotbx/pdb/__init__.py:939 (def xray_structure_simple):
+  if(crystal_symmetry is not None): self._scale_matrix = None
+  """
+  fo = open("%s.cif" % prefix,"w")
+  print >> fo, cif_str
+  fo.close()
+  # crystal symmetry from map
+  cs = crystal.symmetry((419., 419., 419., 90.0, 90.0, 90.0), 1)
+  # xrs from mmCIF
+  cif_inp = iotbx.pdb.input(file_name="%s.cif" % prefix)
+  # print "======== doing xrs from cif =============="
+  xrs_cif = cif_inp.xray_structure_simple(crystal_symmetry = cs)
+  # xrs from PDB
+  easy_run.call("phenix.cif_as_pdb %s.cif > junk.out"%prefix)
+  pdb_inp = iotbx.pdb.input(file_name="%s.pdb" % prefix)
+  # print "======== doing xrs from pdb =============="
+  xrs_pdb = pdb_inp.xray_structure_simple(crystal_symmetry = cs)
+  #
+  assert approx_equal(xrs_cif.sites_cart()[0], xrs_pdb.sites_cart()[0])
+
+if (__name__ == "__main__"):
+  run()
diff --git a/iotbx/run_tests.py b/iotbx/run_tests.py index 52eb3d2e4..9f3e50a98 100644
--- a/iotbx/run_tests.py
+++ b/iotbx/run_tests.py
@@ -93,6 +93,7 @@ tst_list = (
   "$D/regression/tst_show_systematic_absences.py",
   "$D/regression/tst_miller_sort_asu.py",
   "$D/regression/tst_reflection_file_reader.py",
+  "$D/regression/tst_xray_scale.py",
   )

def run():


--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom


_______________________________________________
cctbxbb mailing list
cctbxbb at phenix-online.org
http://phenix-online.org/mailman/listinfo/cctbxbb



More information about the cctbxbb mailing list