to_smiles raises KeyError for N/S-containing adsorbates with vdW bonds
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
Direzione di ricerca
Inizia con lo snippet di riproduzione dell'issue: solleva KeyError: 0.0 in to_ob_mol in rmgpy/molecule/converter.py, dove il dizionario orders mappa gli ordini di legame di RMG a quelli di OpenBabel e manca di una voce per l'ordine 0 (vdW). Confronta con il modo in cui il percorso RDKit in rmgpy/molecule/converter.py mappa i legami vdW a UNSPECIFIED, e decidi se aggiungere una voce 0 o se saltare i legami di ordine zero in to_ob_mol. Si considera completato quando molec.to_smiles() restituisce una SMILES per la lista di adiacenza data, più un test di regressione accanto ai test translator/converter esistenti (ad es. sotto rmgpy/molecule/tests/).
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
As I understand it, when getting the smiles for an RMG molecule, either an RDKit or OpenBabel molecule equivalent is created (to_smiles in rmgpy/molecule/translator.py), and the smiles string is determined by these packages. OpenBabel is used instead of the default RDKit when the species contains N or S atoms. When the molecule is an adsorbate with a vdw bond, there is an RMG bond order of 0, which gives a key error when you try to make the smiles for these molecules (to_ob_mol in rmgpy/molecule/converter.py). This has manifested in the labeling of species in the RMG run. I have found that, if bonds of order 0 are ignored, the RMG runs with these species do not seem to have errors related to it as far as I can tell. However, it may be a concern to skip this if the OpenBabel molecule is used for anything else, since that object will not know about the vdw bond. I noticed that the RDKit handling uses an UNSPECIFIED bond type for vdw since it also does not specifically handle these, and OpenBabel has a bond order of zero which seems to be intended for the same type of unspecified bond. Adding an entry of 0: 0 into the orders dictionary of to_ob_mol also seems to get rid of the error and seems to be close to the RDKit handling of this, so it may be an appropriate change to make.
How To Reproduce
The following code can be run, which produces an error in the current version of RMG. If you implement a change skipping adding bonds to the OpenBabel molecule or adding a zero order bond, you will not have an error.
from rmgpy.molecule import Molecule
adj = '''1 O u0 p2 c0 {3,D} {7,vdW}
2 O u0 p2 c0 {3,S} {8,S}
3 C u0 p0 c0 {1,D} {2,S} {4,S}
4 N u0 p1 c0 {3,S} {5,S} {6,S}
5 H u0 p0 c0 {4,S}
6 H u0 p0 c0 {4,S}
7 X u0 p0 c0 {1,vdW}
8 X u0 p0 c0 {2,S}'''
molec = Molecule().from_adjacency_list(adj)
molec.to_smiles()
The error looks like this:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/RMG-Py/rmgpy/molecule/translator.py:277, in rmgpy.molecule.translator.to_smiles()
KeyError: 'CH2NO2X2'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
Cell In[1], line 14
3 adj = '''1 O u0 p2 c0 {3,D} {7,vdW}
4 2 O u0 p2 c0 {3,S} {8,S}
5 3 C u0 p0 c0 {1,D} {2,S} {4,S}
(...) 9 7 X u0 p0 c0 {1,vdW}
10 8 X u0 p0 c0 {2,S}'''
12 molec = Molecule().from_adjacency_list(adj)
---> 14 molec.to_smiles()
File ~/RMG-Py/rmgpy/molecule/molecule.py:2094, in rmgpy.molecule.molecule.Molecule.to_smiles()
File ~/RMG-Py/rmgpy/molecule/molecule.py:2108, in rmgpy.molecule.molecule.Molecule.to_smiles()
File ~/RMG-Py/rmgpy/molecule/translator.py:256, in rmgpy.molecule.translator.to_smiles()
File ~/RMG-Py/rmgpy/molecule/translator.py:282, in rmgpy.molecule.translator.to_smiles()
File ~/RMG-Py/rmgpy/molecule/translator.py:562, in rmgpy.molecule.translator._write()
File ~/RMG-Py/rmgpy/molecule/translator.py:455, in rmgpy.molecule.translator._openbabel_translator()
File ~/RMG-Py/rmgpy/molecule/converter.py:249, in rmgpy.molecule.converter.to_ob_mol()
File ~/RMG-Py/rmgpy/molecule/converter.py:283, in rmgpy.molecule.converter.to_ob_mol()
KeyError: 0.0
Expected Behavior
I am not sure how this case is meant to be handled, since it seems to be a particular case (vdw bonding) within another particular case (N, S in a molecule).
Additional Context
I am not familiar with all of the uses for to_smiles and how/if the OpenBabel molecule representation is relied upon for other uses that would require the vdw bond, so I am not sure if the proposed solution would be the correct way of handling this.
- Lingua principale
- Python
- Stelle
- 535
- Fork
- 262
- Merge medio
- 3g 19h
- PR unite (30g)
- 2
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ReactionMechanismGenerator/RMG-Py
-
Cantera output: site density and reference pressure are 10× too lowForse già presa @TylerJosephson l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ReactionMechanismGenerator/RMG-Py#3012 · 1 commento ·
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 52/100
ReactionMechanismGenerator/RMG-Py#3016 ·
-
Inconsistent standard state reference pressure (eg. for entropy calculations). 1 bar or 1 atm?Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
ReactionMechanismGenerator/RMG-Py#3015 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
ReactionMechanismGenerator/RMG-Py#3008 · 2 commenti ·
-
Mismatched conformer degrees of freedom pass silently through TST, then surface as a bare "Singular matrix" in the MSC solveForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
ReactionMechanismGenerator/RMG-Py#3003 ·
Tutte le issue di ReactionMechanismGenerator/RMG-Py
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mishraprafful/multihull#150 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
python-caldav/caldav#735 ·
I maintainer di solito rispondono entro 1 giorno
-
bug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mealie-recipes/mealie#8682 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue lane:repo
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100