Skip to content

Commit

Permalink
Merge pull request #416 from ReactionMechanismGenerator/none_mol
Browse files Browse the repository at this point in the history
BugFix: Don't attempt to get SMILES if the mol object is None
  • Loading branch information
alongd committed Aug 6, 2020
2 parents 9d53181 + aae4c66 commit 1f8a964
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions arc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1878,8 +1878,10 @@ def determine_most_stable_conformer(self, label):
break
if is_isomorphic or are_coords_compliant_with_graph(xyz=xyz, mol=self.species_dict[label].mol):
if i == 0:
b_mol_smiles = b_mol.copy(deep=True).to_smiles() \
if b_mol is not None else '<no 2D structure available>'
logger.info(f'Most stable conformer for species {label} was found to be isomorphic '
f'with the 2D graph representation {b_mol.copy(deep=True).to_smiles()}\n')
f'with the 2D graph representation {b_mol_smiles}\n')
conformer_xyz = xyz
if 'passed isomorphism check' not in self.output[label]['conformers']:
self.output[label]['conformers'] += f'most stable conformer ({i}) passed ' \
Expand All @@ -1890,12 +1892,14 @@ def determine_most_stable_conformer(self, label):
mol = molecules_from_xyz(xyzs[0],
multiplicity=self.species_dict[label].multiplicity,
charge=self.species_dict[label].charge)[1]
smiles_1 = self.species_dict[label].mol.copy(deep=True).to_smiles() \
if self.species_dict[label].mol is not None else '<no 2D structure available>'
smiles_2 = mol.copy(deep=True).to_smiles() \
if mol is not None else '<no 2D structure available>'
logger.info(f'A conformer for species {label} was found to be isomorphic with the '
f'2D graph representation '
f'{self.species_dict[label].mol.copy(deep=True).to_smiles()}. '
f'2D graph representation {smiles_1}.\n'
f'This conformer is {energies[i] - energies[0]:.2f} kJ/mol above the '
f'most stable one which corresponds to '
f'{mol.copy(deep=True).to_smiles()} (and is not isomorphic). '
f'most stable one corresponding to {smiles_2} (and is not isomorphic). '
f'Using the isomorphic conformer for further geometry optimization.')
self.output[label]['conformers'] += f'Conformer {i} was found to be the lowest ' \
f'energy isomorphic conformer; '
Expand All @@ -1909,10 +1913,13 @@ def determine_most_stable_conformer(self, label):
self.output[label]['conformers'] += f'most stable conformer ({i}) did not ' \
f'pass isomorphism check; '
self.species_dict[label].conf_is_isomorphic = False
smiles_1 = b_mol.copy(deep=True).to_smiles() \
if b_mol is not None else '<no 2D structure available>'
smiles_2 = self.species_dict[label].mol.copy(deep=True).to_smiles() \
if self.species_dict[label].mol is not None else '<no 2D structure available>'
logger.warning(f'Most stable conformer for species {label} with structure '
f'{b_mol.copy(deep=True).to_smiles()} was found to be NON-isomorphic '
f'with the 2D graph representation '
f'{self.species_dict[label].mol.copy(deep=True).to_smiles()}. '
f'{smiles_1} was found to be NON-isomorphic '
f'with the 2D graph representation {smiles_2}. '
f'Searching for a different conformer that is isomorphic...')
else:
# all conformers for the species failed isomorphism test
Expand Down

0 comments on commit 1f8a964

Please sign in to comment.