salilab / pmi

Python Modeling Interface
https://integrativemodeling.org/nightly/doc/ref/namespaceIMP_1_1pmi.html
11 stars 11 forks source link

PMI shuffle_configuration does not work with a single rigid body #254

Closed Stochastic13 closed 3 years ago

Stochastic13 commented 3 years ago

Platform: Windows, Linux Version: 2.14 and the latest IMP-develop branch

Description: The pmi.tools.shuffle_configuration does not shuffle (randomize the coordinates of) a single rigid body when the topology has all other domains/molecules setup as beads (with the gaussians setup, i.e. em_residues_per_gaussian non-zero). This is because all the gaussian-setup beads are added to the collision_excluded_idxs (to avoid considering them for collisions) initially. The script calculates the set of beads other_idxs = members of rigid body - collisions_excluded_idxs, and if this set is empty, skips over the subsequent randomizing step. The script works properly if more than one rigid bodies are present (or gaussians are not setup).

Reproduce the issue: Use the topology file below with appropriate pdb/fastas -> build the system (BuildSystem macro in pmi) -> call pmi.tools.shuffle_configuration on the root_hierarchy -> compare the coordinates of the rigid body before and after the randomization step. Repeat the same procedure with an added copy (pkp1a.1) and the script runs properly.

Topology file:

|topology_dictionary|
|molecule_name | color | fasta_fn | fasta_id | pdb_fn | chain | residue_range | pdb_offset | bead_size | em_residues_per_gaussian | rigid_body | super_rigid_body | chain_of_super_rigid_bodies |
|pkp1a.0 |gray  |pkp1a_uniprot.fasta|pkp1a|BEADS   |A|1,243   |0|10|10|0|1||
|pkp1a.0 |gray  |pkp1a_uniprot.fasta|pkp1a|1xm9.pdb|A|244,700 |0|10|10|1|1||
|pkp1a.0 |gray  |pkp1a_uniprot.fasta|pkp1a|BEADS   |A|701,END |0|10|10|0|1||

Output:

shuffling 1 rigid bodies
shuffling 32 flexible beads
OLD: (4.90679, 23.8089, 17.5942) NEW: (4.90679, 23.8089, 17.5942)

One possible expected Output:

shuffling 1 rigid bodies
shuffling 32 flexible beads
OLD: (4.90679, 23.8089, 17.5942) NEW: (44.8215, 51.4716, 67.944)

All the files necessary to reproduce the bug are attached. files.zip

I am opening a PR for an attempted fix, though I am not certain why the continue statement was kept in the original code. Currently assuming it was to prevent the execution of the second block of collision-avoidance code when other_idxs is empty.

benmwebb commented 3 years ago

Resolved by d8db793