Closed pguillem closed 1 year ago
Hi Pedro. I don't think there is anything built-in that can help you there. Selections represent atoms, but centroids are not.
What you can do is:
For the rest of your algorithm, you manipulate only Vector3 objects so distanceTo() is available. If you are only comparing distances, a minor optimization is to use the squared distances instead (avoids a root square operation). There might be some other optimizations in the comparisons (e.g. not doing an all against distance which is O(n2) in time complexity, ~but use the centroid of all centroids (which you can compute in O(n) time just by adding Vector3 objects) and compare the distance to this centroid; I am not certain it will give you the same result though, need to check that~) Scratch that... What you are trying to do is clustering residues by distance. There are methods to do clustering in linear time but this is not straightforward.
Most appreciated! I will try the suggestions and report the code if I get it working :)
I'm trying to build a function that:
1) Receives a selection of arbitrary residues (say.. 20 residues) 2) Calculate the centroid of each sidechain (maybe an xyz position in space, or simply a C near the centroid). 3) Measure the distance from all to all centroids. 4) Create groups of residues separated by less than the average distance from all to all.
My questions:
Thanks in advance... I know perhaps this is a very specific thing to do. Pedro