Skip to content

Commit 2d6b9f4

Browse files
committed
Updated the some protocols which used eval calls get residue atoms to be compatible with latest MDAnalysis version=1.1.1 and instead use the residue.atoms.select_atoms pattern.
1 parent 1f3f02c commit 2d6b9f4

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

pybilt/bilayer_analyzer/analysis_protocols.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,12 +3548,14 @@ def run_analysis(self, ba_settings, ba_reps, ba_mda_data):
35483548
residues = self.selection.residues
35493549
cos_run = RunningStats()
35503550
for residue in residues:
3551-
atom_1 = eval("residue.{}".format(self.settings['ref_atom_1']))
3552-
atom_2 = eval("residue.{}".format(self.settings['ref_atom_2']))
3551+
#atom_1 = eval("residue.{}".format(self.settings['ref_atom_1']))
3552+
#atom_2 = eval("residue.{}".format(self.settings['ref_atom_2']))
3553+
atom_1 = residue.atoms.select_atoms('name {}'.format(self.settings['ref_atom_1']))
3554+
atom_2 = residue.atoms.select_atoms('name {}'.format(self.settings['ref_atom_2']))
35533555
#atom_1 = ast.literal_eval("residue.{}".format(self.settings['ref_atom_1']))
35543556
#atom_2 = ast.literal_eval("residue.{}".format(self.settings['ref_atom_2']))
3555-
atom_1_i = atom_1.index
3556-
atom_2_i = atom_2.index
3557+
atom_1_i = atom_1.indices[0]
3558+
atom_2_i = atom_2.indices[0]
35573559
atom_1_coord = ba_reps['current_mda_frame'].positions[atom_1_i]
35583560
atom_2_coord = ba_reps['current_mda_frame'].positions[atom_2_i]
35593561
diff = atom_2_coord - atom_1_coord
@@ -3687,10 +3689,10 @@ def run_analysis(self, ba_settings, ba_reps, ba_mda_data):
36873689
residues = self.selection.residues
36883690
cos_run = RunningStats()
36893691
for residue in residues:
3690-
atom_1 = eval("residue."+self.settings['ref_atom_1'])
3691-
atom_2 = eval("residue."+self.settings['ref_atom_2'])
3692-
atom_1_i = atom_1.index
3693-
atom_2_i = atom_2.index
3692+
atom_1 = residue.atoms.select_atoms('name {}'.format(self.settings['ref_atom_1']))
3693+
atom_2 = residue.atoms.select_atoms('name {}'.format(self.settings['ref_atom_2']))
3694+
atom_1_i = atom_1.indices[0]
3695+
atom_2_i = atom_2.indices[0]
36943696
atom_1_coord = ba_reps['current_mda_frame'].positions[atom_1_i]
36953697
atom_2_coord = ba_reps['current_mda_frame'].positions[atom_2_i]
36963698
diff = atom_2_coord - atom_1_coord

0 commit comments

Comments
 (0)