-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
molecule branch: list index out of range in Molecule.isLinear #81
Comments
I ran it in ipython with --pdb and had a look around: ipdb> bonds
[]
ipdb> atom
<Atom 'C'>
ipdb> self
Molecule(SMILES="[C].C[O].[O].[O].[H]")
ipdb> u
> /Users/rwest/Code/rmgpy/RMG-Py/rmgpy/rmg/model.py(87)generateThermoData()
86 else:
---> 87 linear = self.molecule[0].isLinear()
88 nRotors = self.molecule[0].countInternalRotors()
ipdb> self.label
'C1(OC)OO1' that means that it was meant to be C1(OC)OO1 but by the time it got to line 1048 of isLinear(), it had no bonds! (apart from one C-O bond) But when I play around with that molecule in isolation, both isCyclic() and isLinear() work fine. ipdb> aaa=Molecule(SMILES=('C1(OC)OO1'))
ipdb> aaa
Molecule(SMILES="C1(OC)OO1")
ipdb> aaa.isCyclic()
True
ipdb> aaa
Molecule(SMILES="C1(OC)OO1")
ipdb> aaa.isLinear()
False
ipdb> aaa
Molecule(SMILES="C1(OC)OO1") I have put some extra lines in that print the SMILES string at various points. The molecule is having its bonds destroyed during the call to The first handful of (noncyclic) species get through fine, then somewhere between calling generateThermoData (line 68) and isLinear (line 87) the SMILES changes to one with missing bonds:
|
The trouble is occurring in estimateThermoViaGroupAdditivity (data/thermo.py line 624) ipdb> mmm=Molecule(SMILES="C1(OC)OO1")
ipdb> database.thermo.estimateThermoViaGroupAdditivity(mmm)
ThermoData(Tdata=([300,400,500,600,800,1000,1500],"K"), Cpdata=([91.7551,109.453,123.302,135.227,156.398,171.628,183.385],"K"), H298=(-273341,"K"), S298=(184.514,"K"), comment="""group(Cs-OsOsOsH) + gauche(Cs(RRRR)) + other(R) + group(Cs-OsHHH) + gauche(Cs(RRRR)) + other(R) + group(Os-CsCs) + gauche(Os(CsCs)) + other(R) + group(Os-OsCs) + gauche(Os(CsR)) + other(R) + group(Os-OsCs) + gauche(Os(CsR)) + other(R) + ring(Ring)""")
ipdb> mmm
Molecule(SMILES="[C].C[O].[O].[O].[H]") Recall, it only breaks for cyclic things, I expect the trouble is around line 738 of data/thermo.py |
Yes, that looks like the trouble point. This should be closer (not yet tested): # Make a temporary structure containing only the atoms in the ring
ringStructure = Molecule()
newAtoms = [atom.copy() for atom in ring]
for atom in newAtoms: ringStructure.addAtom(atom)
for atom1 in ring:
for atom2 in ring:
if molecule.hasBond(atom1, atom2):
ringStructure.addBond(newAtoms[molecule.atoms.index(atom1)], newAtoms[molecule.atoms.index(atom2)], molecule.getBond(atom1, atom2).copy()) Basically the idea is that you now need to use a copy of the atoms and bonds; since they store the connectivity of the graph, they can only belong to one graph at a time. |
No dice! The index of an atom in the original molecule may be way higher than the number of atoms in the ring, and the way # Make a temporary structure containing only the atoms in the ring
ringStructure = Molecule()
newAtoms = dict()
for atom in ring:
newAtoms[atom] = atom.copy()
ringStructure.addAtom(newAtoms[atom]) # (addAtom deletes the atom's bonds)
for atom1 in ring:
for atom2 in ring:
if molecule.hasBond(atom1, atom2):
ringStructure.addBond(Bond(newAtoms[atom1], newAtoms[atom2], atom1.bonds[atom2].order )) Some functioning unit tests in the |
…tabase_81 Fix bug RMG-database #81
Running the methylformate example on @jwallen's molecule branch (jwallen/RMG-Py@d177753) it crashes pretty quickly with this:
or, running after a
make decython
:The text was updated successfully, but these errors were encountered: