# [Chimera-users] Chimera scripting question

Eric Pettersen pett at cgl.ucsf.edu
Mon Sep 25 18:16:17 PDT 2017

```I guess I’m going to provide “hints” again rather than full-blown code segments…

> On Sep 25, 2017, at 12:18 PM, Oliver Clarke <olibclarke at gmail.com> wrote:
>
> Hi,
>
> I’d like to do the following (presumably with a python script):
>
> For each pair of Calphas in two identical structures A and B:
> 	Get list of other Calphas within distance cutoff of Calpha(0) for each conformation (say 10 Å);
> 	For each Calpha in list:
> 		Calc distance difference diff_dist between Calpha(0—>A), Calpha(0—>B)
> 	average(diff_dist) over list and assign to attribute
>
> So more or less, I think I need to
>
> (1) iterate through all Calphas of the first structure (this part I get);
>
> (2) check if there is an equivalent Calpha in the second structure (same residue number and chain I guess?);

If your input files are basically identical except for coordinate positions, then the list of atoms in each structure will be in the same order.  Therefore, if a1 is an atom in structure mol1, you can get it’s position in the atom list with:

index = mol1.atoms.index(a1)

and get the equivalent atom from another structure with:

a2 = mol2.atoms[index]

>
> (3) get a list of nearby Calphas, merged between structures (not exactly sure about this but I think I found something in an example I can adapt)

Well, the simplest way is to brute force the distance check, but that might be too slow — depending on how many C-alphas we’re talking about.  In my code I typically use AdaptiveTree to form a 3D-space-partiioning search tree that can used repeatedly and cuts down the search tremendously.  Assuming you had all your C-alpha atom in a list called calphas, you would set up the tree with:

coordData = [[c.x, c.y, c.z] for c in [a.xformCoord() for a in calphas]]

then you would search for C-alphas within 10.0 of calpha0 with:

crd = calpha0.xformCoord()
nearby = tree.searchTree([crd.x, crd.y, crd.z], 10.0)

nearby will be a list of atoms that might be within 10 angstroms — some will be slightly beyond 10 so you will have to filter this much smaller list yourself.

> (4) calculate distances, then difference-distances between the paired structures, from each target Calpha;

FYI, the distance between two atoms is a1.xformCoord().distance(a2.xformCoord())

>
> (5) assign the averaged difference distance to an attribute (I think I can figure out this bit)

I think you can too. :-)

—Eric

>
> Any suggestions much appreciated (or if anyone can point me towards similar scripts I can adapt the would also be most welcome!)
>
> The intent of this is to generate an attribute representing local structural flexibility (independent of displacement) - to capture changes in the local arrangements of atoms, decoupled from rigid displacements of domains. The idea is this may be useful for highlighting hinge regions and regions that have undergone plastic deformation, without pre-aligning structures.
>
> Cheers
> Oli
>
>
>
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20170925/4e8b5eae/attachment.html>
```