-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The algorithm used by PolyConf to generate conformations requires that the J-K atom pairs used in rotate() and dist() (and hence shuffler() and dihedral_solver() ) be chosen such that if the polymer is split by breaking the bond J-K, the resulting molecule will have exactly two completely disconnected groups of atoms (see polyconf manuscript figures S1 and S2.
This is not an error or a bug, it's a fundamental requirement of the approach; the geometric processes cannot be defined if this is not true.
Identifying the two disconnected groups of atoms is implemented in split_pol().
If a user chooses a bond such that the there will not be two disconnected groups of atoms (eg, one of the C-C bonds in an aromatic ring), split_pol() will fail with an unclear error message.
Example:
(polyconstruct-env) emilycameron@aibn-3k1tw14:~/polyconstruct$ python3 P5Tx_PolyConf.py
50%|█████████████████████▌ | 25/50 [00:00<00:00, 84.34it/s]
Traceback (most recent call last):
File "/home/emilycameron/polyconstruct/P5Tx_PolyConf.py", line 92, in <module>
P5Tx.shuffler(NC_dihedrals)
~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/home/emilycameron/polyconstruct/polyconf/polyconf/Polymer.py", line 475, in shuffler
self.shuffle(J=dh['J'],J_resid=dh['J_resid'],K=dh['K'],K_resid=dh['K_resid'],mult=dh['mult'],dummies=dummies,clashcheck=clashcheck,cutoff=cutoff)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/emilycameron/polyconstruct/polyconf/polyconf/Polymer.py", line 383, in shuffle
self.rotate(J,J_resid,K,K_resid,mult,step)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/emilycameron/polyconstruct/polyconf/polyconf/Polymer.py", line 300, in rotate
fore,_=self._split_pol(J,J_resid,K,K_resid)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/home/emilycameron/polyconstruct/polyconf/polyconf/Polymer.py", line 270, in _split_pol
bond = self.polymer.atoms.bonds.atomgroup_intersection(pair,strict=True)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/home/emilycameron/miniconda3/envs/polyconstruct-env/lib/python3.13/site-packages/MDAnalysis/core/topologyobjects.py", line 823, in __getitem__
return outclass(self._bix[item],
~~~~~~~~~^^^^^^
IndexError: index 0 is out of bounds for axis 0 with size 0
To do: I need to either build in some kind of checking to validate the chosen bond, and/or build in a more graceful error message to explain that the chosen bond was not sensible.