Hi Graeme,

You can make it work like this:

def symop_to_mat(symop):
  return matrix.sqr(sgtbx.rt_mx(
    sgtbx.parse_string(symop), r_den=12, t_den=144).as_double_array()[:9]).transpose().elems

But I suggest using the change_of_basis_op type instead. See the complete script below.

Ralf


from cctbx import sgtbx
from cctbx.array_family import flex
from scitbx import matrix

def symop_to_mat(symop):
  return matrix.sqr(sgtbx.rt_mx(
    sgtbx.parse_string(symop), r_den=12, t_den=144).as_double_array()[:9]).transpose().elems

def run(args):
  assert len(args) == 0
  print symop_to_mat("1/2*z,-y+1/2*z,x")
  cb_op = sgtbx.change_of_basis_op("1/2*z,-y+1/2*z,x").inverse()
  print cb_op.as_hkl()
  miller_indices = flex.miller_index([(2,4,1)])
  print list(cb_op.apply(miller_indices))

if (__name__ == "__main__"):
  import sys
  run(args=sys.argv[1:])


On Tue, Jul 12, 2011 at 7:06 AM, <Graeme.Winter@diamond.ac.uk> wrote:

Dear All,

 

For a little while now I have been using some cctbx jiffy code to convert from symmetry operations to matrices to help with testing reindexing data. This works as

 

def symop_to_mat(symop):

    return matrix.sqr(sgtbx.rt_mx(

        sgtbx.parse_string(symop)).as_double_array()[:9]).transpose().elems

 

Which is plenty simple. However it just exploded when given “1/2*z,-y+1/2*z,x”  - reasonably really as this is not a rotation. It is however a valid reindexing operation to go from C2 to P1.

 

Does anyone have code which will handle this general transformation from a reindexing operation to a matrix, which will cope with the fact that the resulting matrix is not RT? I had a little jiffy I wrote using ccp4f lib (symop2mat – you can probably see it!) but I am trying to do away with things like that and do everything properly…

 

Many thanks in advance,

 

Graeme

 

Dr. Graeme Winter

Senior Software Scientist

Diamond Light Source

 

+44 1235 778091 (work)

+44 7786 662784 (work mobile)

 

 


 

-- 

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@phenix-online.org
http://phenix-online.org/mailman/listinfo/cctbxbb