Conversion from symmetry operation to matrix
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
Dear All, Answered my own question: Sgtbx.change_of_basis_op(op).c().as_double_array() Etc. in case anyone is interested. Best wishes, Graeme From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: 12 July 2011 15:06 To: [email protected] Subject: [cctbxbb] Conversion from symmetry operation to matrix 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 -- 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
However... Having said this, I am struggling to write the inverse namely the general conversion from a symmetry / reindexing operation as a matrix to a string. In principle if I have an rt_mx I can call apon:
r
t = sgtbx.change_of_basis_op(r) t.as_xyz() '1/2*z,-y+1/2*z,x'
which works a treat. However unless I get the rt_mx from a reindexing operation I cannot assign a non-rotation to R:
r = matrix.sqr(s.c().as_double_array()[:9]) rt = sgtbx.rt_mx(r, (0,0,0)) Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: cctbx InternalError: /home/gw56/xtal/cctbx/cctbx_sources/cctbx/sgtbx/rt_mx.cpp(290): Unsuitable value for rational rotation matrix.
which is something of a pain. Is there some kind of constructor hidden about the place which will allow me to make an rt_mx in the way I can get from a change_of_basis_op but from 9 numbers instead? Where |r| != 1.0? Thanks again in advance, Graeme ________________________________ From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]] Sent: 12 July 2011 15:17 To: [email protected] Subject: Re: [cctbxbb] Conversion from symmetry operation to matrix Dear All, Answered my own question: Sgtbx.change_of_basis_op(op).c().as_double_array() Etc. in case anyone is interested. Best wishes, Graeme From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: 12 July 2011 15:06 To: [email protected] Subject: [cctbxbb] Conversion from symmetry operation to matrix 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 -- 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 -- 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
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,
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 [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
Hi Ralf,
as a big fan of phenix, I still wonder if there is a way to improve the
output of xtriage. Even after looking at it for a number of years now, I
manage to confuse myself. I for one would prefer clear statements over
probability scores. I never know whether a high number is good or bad (or
what the scale is!) because sometimes a score reflects the probability
whether something is true or whether an assumption is wrong. Would it not be
possible to print likelihood of a space group scaled to 100% ? I realize
that it involves a bit of judgment and you have to evaluate absent
violations and weak violations with different number of occurrences etc.But
still...
Also what surprises me is that when I run phenix.xtriage or phenix and then
"reflection tools" xtriage, I get different results.
For instance in one test case I get in phenix.xtriage logfile.log:
Analyses of the absences table indicates a number of likely space group
candidates, which are listed below. For each space group, the number of
absent violations are listed under the '+++' column. The number of present
violations (weak reflections) are listed under '---'. The last column is a
likelihood based score for the particular space group. Note that
enantiomorphic spacegroups will have equal scores. Also, if absences were
removed while processing the data, they will be regarded as missing
information, rather then as enforcing that absence in the space group choices.
------------------------------------------------------------------------------------
| space group | n absent | <Z>_absent |
On Tue, Jul 12, 2011 at 12:51 PM,
Also what surprises me is that when I run phenix.xtriage or phenix and then "reflection tools" xtriage, I get different results.
Yeah, this is a bug - getting Xtriage output to display nicely in the GUI was non-trivial, and in a few cases I misinterpreted which data arrays were relevant. It'll be fixed in the next nightly build.
as a big fan of phenix, I still wonder if there is a way to improve the output of xtriage. Even after looking at it for a number of years now, I manage to confuse myself. I for one would prefer clear statements over probability scores. I never know whether a high number is good or bad (or what the scale is!) because sometimes a score reflects the probability whether something is true or whether an assumption is wrong. Would it not be possible to print likelihood of a space group scaled to 100%?
We agree that it needs to be made much more intuitive - I have tried to clarify some issues in the GUI but I'm limited to those parts I actually understand. Peter and I probably need to spend a couple of weeks revising and cleaning up the output, but as usual this has to compete with about a dozen other projects... -Nat
Hi Ralf,
The t_den and r_den additions made the difference (also needed with the change_of_basis_op using rt_mx as starting point) - may be worth adding as an additional comment in the __init__ methods what these actually mean as it was not clear!
Many thanks,
Graeme
From: [email protected] [mailto:[email protected]] On Behalf Of Ralf Grosse-Kunstleve
Sent: 12 July 2011 20:18
To: cctbx mailing list
Subject: Re: [cctbxbb] Conversion from symmetry operation to matrix
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,
participants (4)
-
Graeme.Winter@Diamond.ac.uk
-
lesser@helix.nih.gov
-
Nat Echols
-
Ralf Grosse-Kunstleve