I'm new to the Python API, so please don't assume any knowledge!

I'd like to measure a distance between two molecules.  The molecules are roughly planar, so I have defined the planes of each molecule, and I want to find the perpendicular distnace between the planes.  I can find the angle between the planes (which is usually 0, and if it's not 0 I realise that I can't measure the distance anyway).  How can I get the distance?  Below, the code is all working fine, except for the last line.

Thanks,

Louise

 

substructure_search.add_plane('P1',

    sub1, 0,

    sub1, 1,

    sub1, 2,

    sub1, 3,

    sub1, 4,

    sub1, 5,

    sub1, 6,

    sub1, 7,

    sub1, 8)

substructure_search.add_plane('P2',

    sub2, 0,

    sub2, 1,

    sub2, 2,

    sub2, 3,

    sub2, 4,

    sub2, 5,

    sub2, 6,

    sub2, 7,

    sub2, 8)

substructure_search.add_plane_angle_measurement('ang3', 'P1', 'P2')

substructure_search.add_distance_measurement('sep1', 'P1', 'P2')

Hi Louise,

the API does not support a plane-plane distance measurement since the planes are deemed to be infinite in extent.  You can measure a point-plane distance, so for example you could define a centroid from the first substructure's atoms and measure the distance to the second substructure's plane:

substructure_search.add_centroid('CENT1', (sub1, 0), (sub1, 1), (sub1, 2), (sub1, 3), (sub1, 4), (sub1, 5), (sub1, 6), (sub1, 7), (sub1, 8))
substructure_search.add_point_plane_distance('CENT1_P2', 'CENT1', 'P2')

Similarly you could define a second centroid, and measure the distance between the two centroids and the distance between the second centroid and the first plane.


I hope this is helpful.
Best wishes
Richard

 

Hi Richard,

Thanks for this.  As Mercury now allows measurement of the distance between two planes I was hoping that it would also be in the API.

Anyway, I tried your suggestion, and got the error:

AttributeError: 'SubstructureSearch' object has no attribute 'add_point_plane_distance'

Any ideas on what I might be doing wrong?

Thanks,

Louise

Sorry, Louise, I meant to say 'add_point_plane_distance_measurement'.  However, I now realise that this feature is scheduled for the next release of the API which will be available sometime in the next month.  In the meantime, you can measure the distances after the search using:

hits = substructure_search.search()

for h in hits:
     h.measurements['PP1'] = h.geometric_objects['P1'].plane_distance(h.geometric_objects['P2'])

This will usually give a value of 0.0, as does mercury, since non-parallel planes will intersect.

You can, though, add a distance measurement between the centroids in the search:

substructure_search.add_distance_measurement('DIST2', 'CENT1', 'CENT2')

and extract centroid-plane distances using:

h.geometric_objects['P1'].point_distance(h.geometric_objects['CENT1'])

Sorry about the earlier misinformation.

Best wishes
Richard

Hi Richard,

That's amazing - thank you.  I'm currently only interested in perfectly parallel planes, so the h.measurements bit is perfect for what I want (and working brilliantly!).  When (if?) I extend to nearly parallel planes I will look at the centroid-plane distances.

Thanks so much for your help,

Louise

Any time, Louise.  Please don't hesitate to ask again if anything is unclear.

Best wishes

Richard

You must be signed in to post in this forum.