Re: [cctbxbb] unexpected behaviour of unit_cell.fractionalize

Am Mittwoch 13 Februar 2013 17:01:37 you wrote:
Hi Jan,
can this method work for you: sites_mod_positive ? I don't remember what exactly it does but I think it either what you need or at least very close.
Hi Pavel, hm, it goes in the right direction, but is not exactly what I'm looking for, as it is bound to scatterers and not to sites in general. And adding a scatterer for each site I want to convert to the structure first, then converting, and than extracting the converted sites from the scatterers afterwards seems quite inefficient to me. Also I think it would be clearer to add the functionality for this to the "fractionalize" function as people trying to convert from direct space coordinates to fractional coordinates will most likely find this functionality first. Cheers, Jan
On 2/13/13 7:17 AM, Jan Marten Simons wrote:
Hi,
When I try to convert a list of direct space coordinates into fractional coordinates like this:
from cctbx import xray from cctbx import crystal from cctbx.array_family import flex
structure = xray.structure(
special_position_settings=crystal.special_position_settings(
crystal_symmetry=crystal.symmetry(
unit_cell=(3.14098, 4.08327, 5.33966, 83, 109, 129), space_group_symbol="P1")))
sites = flex.vec3_double( ((0.0, 0.1, 0.2), (1.3, 3.0, 2.3), (5.3, 0.1, 7.3)) ) sites_frac = structure.unit_cell().fractionalize(sites) print(list(sites_frac))
Now this returns a list of coordinates where x,y,z may be outside ot the interval [0,1[. ... quite unexpected.
It would be very nice to have at least an option like "restrict_to_asu" in unit_cell.fractionalize which would enforce (x,y,z) to be inside the asymmetric unit and/or "restrict_to_cell" which would enforce (x,y,z) to be inside the unit cell.
Could any of you more into the inner workings of the cctbx add this functionality, please?
Thanks in advance,
Jan

Hi Jan, I see, yes, that's right. Just to make sure I correctly understand.. So having *only* sites_cart and unit_cell, you want to convert these sites_cart into fractional basis such that resulting sites_frac are all between 0 and 1, correct? Pavel On 2/13/13 8:43 AM, Jan Marten Simons wrote:
Am Mittwoch 13 Februar 2013 17:01:37 you wrote:
Hi Jan,
can this method work for you: sites_mod_positive ? I don't remember what exactly it does but I think it either what you need or at least very close. Hi Pavel,
hm, it goes in the right direction, but is not exactly what I'm looking for, as it is bound to scatterers and not to sites in general. And adding a scatterer for each site I want to convert to the structure first, then converting, and than extracting the converted sites from the scatterers afterwards seems quite inefficient to me.
Also I think it would be clearer to add the functionality for this to the "fractionalize" function as people trying to convert from direct space coordinates to fractional coordinates will most likely find this functionality first.
Cheers, Jan
On 2/13/13 7:17 AM, Jan Marten Simons wrote:
Hi,
When I try to convert a list of direct space coordinates into fractional coordinates like this:
from cctbx import xray from cctbx import crystal from cctbx.array_family import flex
structure = xray.structure(
special_position_settings=crystal.special_position_settings(
crystal_symmetry=crystal.symmetry(
unit_cell=(3.14098, 4.08327, 5.33966, 83, 109, 129), space_group_symbol="P1")))
sites = flex.vec3_double( ((0.0, 0.1, 0.2), (1.3, 3.0, 2.3), (5.3, 0.1, 7.3)) ) sites_frac = structure.unit_cell().fractionalize(sites) print(list(sites_frac))
Now this returns a list of coordinates where x,y,z may be outside ot the interval [0,1[. ... quite unexpected.
It would be very nice to have at least an option like "restrict_to_asu" in unit_cell.fractionalize which would enforce (x,y,z) to be inside the asymmetric unit and/or "restrict_to_cell" which would enforce (x,y,z) to be inside the unit cell.
Could any of you more into the inner workings of the cctbx add this functionality, please?
Thanks in advance,
Jan
cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb

Am Mittwoch 13 Februar 2013 18:19:15 schrieb Pavel Afonine:
Hi Jan,
I see, yes, that's right.
Just to make sure I correctly understand.. So having *only* sites_cart and unit_cell, you want to convert these sites_cart into fractional basis such that resulting sites_frac are all between 0 and 1, correct?
Yes you got that right. It would be even better to have the option to restrict all sites_frac to be inside the asymmetric unit of the (empty) cell as well, as all other sites can be generated from symmetry operations later on, if one needs to have all of those. Cheers, Jan

Hi Jan,
This message from the cctbxbb archive demonstrates how you can map sites to
the asymmetric unit cell in Python. I think you should probably be able to
write the equivalent code in C++ if you need the speed, but I would have to
look into it more closely to be sure:
http://phenix-online.org/pipermail/cctbxbb/2010-February/000142.html
Regarding the sites_frac between 0 and 1, there is a standalone C++
function mod_positive() and a related function mod_short() in
cctbx/coordinates.h which act just on a site coordinate rather than on a
scatterer. If you have need to access this in Python you would need to
write a wrapper function that will act on a flex.vec3_double() from Python
and loop over this in C++. If this is what you want we can point you in the
write direction for how to accomplish this.
Cheers,
Richard
On 13 February 2013 10:20, Jan Marten Simons
Am Mittwoch 13 Februar 2013 18:19:15 schrieb Pavel Afonine:
Hi Jan,
I see, yes, that's right.
Just to make sure I correctly understand.. So having *only* sites_cart and unit_cell, you want to convert these sites_cart into fractional basis such that resulting sites_frac are all between 0 and 1, correct?
Yes you got that right.
It would be even better to have the option to restrict all sites_frac to be inside the asymmetric unit of the (empty) cell as well, as all other sites can be generated from symmetry operations later on, if one needs to have all of those.
Cheers, Jan _______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb

On 13 Februar 2013 20:15:32 Richard Gildea wrote:
Hi Jan,
This message from the cctbxbb archive demonstrates how you can map sites to the asymmetric unit cell in Python. I think you should probably be able to write the equivalent code in C++ if you need the speed, but I would have to look into it more closely to be sure: http://phenix-online.org/pipermail/cctbxbb/2010-February/000142.html
I think it would be nice to get the same result in a more straight forward way, but for now restricting the sites via this method should work for me.
Regarding the sites_frac between 0 and 1, there is a standalone C++ function mod_positive() and a related function mod_short() in cctbx/coordinates.h which act just on a site coordinate rather than on a scatterer. If you have need to access this in Python you would need to write a wrapper function that will act on a flex.vec3_double() from Python and loop over this in C++. If this is what you want we can point you in the write direction for how to accomplish this.
That would be quite helpful. Also, I think I must be blind, but so far I have not found a method that returns the basis *vectors* of a unit cell via python. Do you know any? Thanks in advance, Jan
participants (3)
-
Jan Marten Simons
-
Pavel Afonine
-
Richard Gildea