Skip to content

1 test fails: KeyError: 85783535 #380

Description

@yurivict

Describe the bug

========================================================================================================================== FAILURES ==========================================================================================================================
__________________________________________________________________________________________________________________ test_pubchem_multiout_g ___________________________________________________________________________________________________________________

    @using_web
    def test_pubchem_multiout_g():
        subject = """
        #pubchem: gobbledegook
        #pubchem: c6h12o
        #pubchem: formaldehyde*
        pubchem: tropolone*
    """
    
        with pytest.raises(qcelemental.ChoicesError) as e:
            with xfail_on_pubchem_busy():
                qcelemental.molparse.from_string(subject, return_processed=True)
    
        try:
            with xfail_on_pubchem_busy():
>               qcelemental.molparse.from_string(subject, return_processed=True)

qcelemental/tests/test_molparse_pubchem.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
qcelemental/molparse/from_string.py:236: in from_string
    molstr, molinit = parse_as_psi4_ish(molstr, unsettled=False)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qcelemental/molparse/from_string.py:201: in parse_as_psi4_ish
    molstr, processed = _filter_pubchem(molstr)
                        ^^^^^^^^^^^^^^^^^^^^^^^
qcelemental/molparse/from_string.py:357: in _filter_pubchem
    line = re.sub(pubchemre, process_pubchem, line.strip())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.11/re/__init__.py:185: in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

matchobj = <re.Match object; span=(0, 19), match='pubchem: tropolone*'>

    def process_pubchem(matchobj):
        pubsearch = matchobj.group("pubsearch")
    
        # search pubchem for the provided string
        try:
            results = pubchem.get_pubchem_results(pubsearch)
        except Exception as e:
            raise ValidationError(e.message)
    
        if pubsearch.endswith("*"):
            pubsearch = pubsearch[:-1]
        if len(results) == 1:
            # There's only 1 result - use it
            xyz = results[0].get_molecule_string()
            processed["name"] = "IUPAC {}".format(results[0].name())
            processed["molecular_charge"] = float(results[0].molecular_charge)
            if "Input Error" in xyz:
                raise ValidationError(xyz)
        else:
            # There are multiple results -- print and exit
            # * formerly, this checked for (then used) any exact match, but now (LAB; Sep 2018), disabling that
            #   since user explicitly added '*' char & "best match" (not available formerly) returned w/o '*'
            msg = "\tPubchemError\n"
            msg += "\tMultiple pubchem results were found. Replace\n\n\t\tpubchem:%s\n\n" % (pubsearch)
            msg += "\twith the Chemical ID number or exact name from one of the following and re-run.\n\n"
            msg += "\t Chemical ID     IUPAC Name\n\n"
            ematches = {}
            for result in results:
                msg += "%s" % (result)
                ematches[result.cid] = result.iupac
>           raise ChoicesError(msg, ematches)
E           qcelemental.exceptions.ChoicesError: ("\tPubchemError\n\tMultiple pubchem results were found. Replace\n\n\t\tpubchem:tropolone\n\n\twith the Chemical ID number or exact name from one of the following and re-run.\n\n\t Chemical ID     IUPAC Name\n\n            10789   2-hydroxycyclohepta-2,4,6-trien-1-one\n           562886   (7-oxocyclohepta-1,3,5-trien-1-yl) 4-methylbenzenesulfonate\n           123928   indium(3+);tris(7-oxocyclohepta-1,3,5-trien-1-olate)\n            16546   2-methoxycyclohepta-2,4,6-trien-1-one\n            20751   4-hydroxycyclohepta-2,4,6-trien-1-one\n           214692   (7-oxocyclohepta-1,3,5-trien-1-yl) acetate\n            11424   2-hydroxy-6-methylcyclohepta-2,4,6-trien-1-one\n           594578   2-hydroxy-5-(3-methylbut-2-enyl)-6-prop-1-en-2-ylcyclohepta-2,4,6-trien-1-one\n            36590   2-hydroxy-3-oxocyclohepta-1,4,6-triene-1-carboxylic acid\n           157625   indium-111(3+);tris(7-oxocyclohepta-1,3,5-trien-1-olate)\n            23450   5-amino-2-hydroxycyclohepta-2,4,6-trien-1-one\n             3611   2-hydroxy-6-propan-2-ylcyclohepta-2,4,6-trien-1-one\n          2808275   2-hydroxy-3-prop-1-en-2-ylcyclohepta-2,4,6-trien-1-one\n           237837   12-ethyl-6,15-dihydroxy-17,19-dimethoxy-14-(methoxymethyl)-12-azapentacyclo[8.7.2.01,11.03,9.014,18]nonadeca-3,6,8-trien-5-one\n        169447557   2-hydroxy(1,2-13C2)cyclohepta-2,4,6-trien-1-one\n            42068   azanium 4-hydroxy-5-oxocyclohepta-1,3,6-triene-1-sulfonate\n         23663429   sodium 7-oxocyclohepta-1,3,5-trien-1-olate\n           254856   (7-oxocyclohepta-1,3,5-trien-1-yl) 4-nitrobenzoate\n         87068883   ethanol;2-hydroxycyclohepta-2,4,6-trien-1-one\n         86744165   2-hydroxycyclohepta-2,4,6-trien-1-one;nickel\n         86744164   cobalt;2-hydroxycyclohepta-2,4,6-trien-1-one\n         86744163   copper;2-hydroxycyclohepta-2,4,6-trien-1-one\n         13764752   4-[(2-hydroxy-3-oxocyclohepta-1,4,6-trien-1-yl)methyl]benzonitrile\n         13764751   2-hydroxy-3-[(2-nitrophenyl)methyl]cyclohepta-2,4,6-trien-1-one\n         13609891   2-hydroxy-3-[(4-nitrophenyl)methyl]cyclohepta-2,4,6-trien-1-one\n         10975475   3-hydroxycyclohepta-2,4,6-trien-1-one\n           622296   2-hydroxy-6-(5-phenyl-4,5-dihydro-1H-pyrazol-3-yl)cyclohepta-2,4,6-trien-1-one\n         13838342   3-[(2,5-dihydroxyphenyl)methyl]-2-hydroxycyclohepta-2,4,6-trien-1-one\n           614931   3-bromo-6-(2-bromoacetyl)-2-hydroxycyclohepta-2,4,6-trien-1-one\n           560055   2-hydroxy-6-(2-methyl-1,3-dioxolan-2-yl)cyclohepta-2,4,6-trien-1-one\n        129699366   2-hydroxycyclohepta-2,4,6-trien-1-one;hydrochloride\n         12557665   3-amino-2-hydroxycyclohepta-2,4,6-trien-1-one\n           571356   N-[2-[benzoyl-(4-hydroxy-5-oxocyclohepta-1,3,6-trien-1-yl)amino]phenyl]benzamide\n           564118   6-ethyl-2-hydroxy-3-iodo-5-[(4-methylphenyl)diazenyl]cyclohepta-2,4,6-trien-1-one\n           373247   6-chloro-2-hydroxy-3,4-dimethoxycyclohepta-2,4,6-trien-1-one\n           237838   12-ethyl-15-hydroxy-5,17,19-trimethoxy-14-(methoxymethyl)-12-azapentacyclo[8.7.2.01,11.03,9.014,18]nonadeca-3(9),4,7-trien-6-one\n            12773   6-amino-2-hydroxycyclohepta-2,4,6-trien-1-one\n        101190042   4-hydroxy-6-methyl-5-methylidenecyclohepta-3,6-diene-1,2-dione\n           901396   tricyclo[9.4.0.02,7]pentadeca-1(15),2,4,6,11,13-hexaene-8,10-dione\n           562438   7-bromo-2-hydroxy-5-[(4-methylphenyl)diazenyl]-3-propan-2-ylcyclohepta-2,4,6-trien-1-one\n           344925   2-hydroxy-5-phenyldiazenylcyclohepta-2,4,6-trien-1-one\n         24202502   N',N'-bis(2-chloroethyl)ethane-1,2-diamine;cobalt(3+);bis(7-oxocyclohepta-1,3,5-trien-1-olate);perchlorate\n           610315   2-hydroxy-6-(2-methoxypropan-2-yl)-3-(morpholin-4-ylmethyl)cyclohepta-2,4,6-trien-1-one\n           560235   5-amino-2-hydroxy-6-(2-methyl-1,3-dioxolan-2-yl)cyclohepta-2,4,6-trien-1-one\n         15321831   2-hydroxy-3,5,7-tris(methoxymethyl)cyclohepta-2,4,6-trien-1-one\n         13047638   3,7-bis(bromomethyl)-2-hydroxycyclohepta-2,4,6-trien-1-one\n           741311   2-hydroxy-3,5,7-tris(hydroxymethyl)cyclohepta-2,4,6-trien-1-one\n        101618174   2-hydroxy-3,7-bis(methoxymethyl)cyclohepta-2,4,6-trien-1-one\n        139088552   2-hydroxy-5-[(2,4,6-tribromophenyl)diazenyl]cyclohepta-2,4,6-trien-1-one\n        101618189   5-chloro-2-hydroxy-3,7-bis(methoxymethyl)cyclohepta-2,4,6-trien-1-one\n         46913723   2-hydroxy-3,5,7-tris[(4-methylpiperazin-1-yl)methyl]cyclohepta-2,4,6-trien-1-one\n        168341954   4,6-ditert-butyl-2-(4,7-dichloro-8-methylquinolin-2-yl)-3-hydroxy-7-nitrocyclohepta-2,4,6-trien-1-one\n", {10789: '2-hydroxycyclohepta-2,4,6-trien-1-one', 562886: '(7-oxocyclohepta-1,3,5-trien-1-yl) 4-methylbenzenesulfonate', 123928: 'indium(3+);tris(7-oxocyclohepta-1,3,5-trien-1-olate)', 16546: '2-methoxycyclohepta-2,4,6-trien-1-one', 20751: '4-hydroxycyclohepta-2,4,6-trien-1-one', 214692: '(7-oxocyclohepta-1,3,5-trien-1-yl) acetate', 11424: '2-hydroxy-6-methylcyclohepta-2,4,6-trien-1-one', 594578: '2-hydroxy-5-(3-methylbut-2-enyl)-6-prop-1-en-2-ylcyclohepta-2,4,6-trien-1-one', 36590: '2-hydroxy-3-oxocyclohepta-1,4,6-triene-1-carboxylic acid', 157625: 'indium-111(3+);tris(7-oxocyclohepta-1,3,5-trien-1-olate)', 23450: '5-amino-2-hydroxycyclohepta-2,4,6-trien-1-one', 3611: '2-hydroxy-6-propan-2-ylcyclohepta-2,4,6-trien-1-one', 2808275: '2-hydroxy-3-prop-1-en-2-ylcyclohepta-2,4,6-trien-1-one', 237837: '12-ethyl-6,15-dihydroxy-17,19-dimethoxy-14-(methoxymethyl)-12-azapentacyclo[8.7.2.01,11.03,9.014,18]nonadeca-3,6,8-trien-5-one', 169447557: '2-hydroxy(1,2-13C2)cyclohepta-2,4,6-trien-1-one', 42068: 'azanium 4-hydroxy-5-oxocyclohepta-1,3,6-triene-1-sulfonate', 23663429: 'sodium 7-oxocyclohepta-1,3,5-trien-1-olate', 254856: '(7-oxocyclohepta-1,3,5-trien-1-yl) 4-nitrobenzoate', 87068883: 'ethanol;2-hydroxycyclohepta-2,4,6-trien-1-one', 86744165: '2-hydroxycyclohepta-2,4,6-trien-1-one;nickel', 86744164: 'cobalt;2-hydroxycyclohepta-2,4,6-trien-1-one', 86744163: 'copper;2-hydroxycyclohepta-2,4,6-trien-1-one', 13764752: '4-[(2-hydroxy-3-oxocyclohepta-1,4,6-trien-1-yl)methyl]benzonitrile', 13764751: '2-hydroxy-3-[(2-nitrophenyl)methyl]cyclohepta-2,4,6-trien-1-one', 13609891: '2-hydroxy-3-[(4-nitrophenyl)methyl]cyclohepta-2,4,6-trien-1-one', 10975475: '3-hydroxycyclohepta-2,4,6-trien-1-one', 622296: '2-hydroxy-6-(5-phenyl-4,5-dihydro-1H-pyrazol-3-yl)cyclohepta-2,4,6-trien-1-one', 13838342: '3-[(2,5-dihydroxyphenyl)methyl]-2-hydroxycyclohepta-2,4,6-trien-1-one', 614931: '3-bromo-6-(2-bromoacetyl)-2-hydroxycyclohepta-2,4,6-trien-1-one', 560055: '2-hydroxy-6-(2-methyl-1,3-dioxolan-2-yl)cyclohepta-2,4,6-trien-1-one', 129699366: '2-hydroxycyclohepta-2,4,6-trien-1-one;hydrochloride', 12557665: '3-amino-2-hydroxycyclohepta-2,4,6-trien-1-one', 571356: 'N-[2-[benzoyl-(4-hydroxy-5-oxocyclohepta-1,3,6-trien-1-yl)amino]phenyl]benzamide', 564118: '6-ethyl-2-hydroxy-3-iodo-5-[(4-methylphenyl)diazenyl]cyclohepta-2,4,6-trien-1-one', 373247: '6-chloro-2-hydroxy-3,4-dimethoxycyclohepta-2,4,6-trien-1-one', 237838: '12-ethyl-15-hydroxy-5,17,19-trimethoxy-14-(methoxymethyl)-12-azapentacyclo[8.7.2.01,11.03,9.014,18]nonadeca-3(9),4,7-trien-6-one', 12773: '6-amino-2-hydroxycyclohepta-2,4,6-trien-1-one', 101190042: '4-hydroxy-6-methyl-5-methylidenecyclohepta-3,6-diene-1,2-dione', 901396: 'tricyclo[9.4.0.02,7]pentadeca-1(15),2,4,6,11,13-hexaene-8,10-dione', 562438: '7-bromo-2-hydroxy-5-[(4-methylphenyl)diazenyl]-3-propan-2-ylcyclohepta-2,4,6-trien-1-one', 344925: '2-hydroxy-5-phenyldiazenylcyclohepta-2,4,6-trien-1-one', 24202502: "N',N'-bis(2-chloroethyl)ethane-1,2-diamine;cobalt(3+);bis(7-oxocyclohepta-1,3,5-trien-1-olate);perchlorate", 610315: '2-hydroxy-6-(2-methoxypropan-2-yl)-3-(morpholin-4-ylmethyl)cyclohepta-2,4,6-trien-1-one', 560235: '5-amino-2-hydroxy-6-(2-methyl-1,3-dioxolan-2-yl)cyclohepta-2,4,6-trien-1-one', 15321831: '2-hydroxy-3,5,7-tris(methoxymethyl)cyclohepta-2,4,6-trien-1-one', 13047638: '3,7-bis(bromomethyl)-2-hydroxycyclohepta-2,4,6-trien-1-one', 741311: '2-hydroxy-3,5,7-tris(hydroxymethyl)cyclohepta-2,4,6-trien-1-one', 101618174: '2-hydroxy-3,7-bis(methoxymethyl)cyclohepta-2,4,6-trien-1-one', 139088552: '2-hydroxy-5-[(2,4,6-tribromophenyl)diazenyl]cyclohepta-2,4,6-trien-1-one', 101618189: '5-chloro-2-hydroxy-3,7-bis(methoxymethyl)cyclohepta-2,4,6-trien-1-one', 46913723: '2-hydroxy-3,5,7-tris[(4-methylpiperazin-1-yl)methyl]cyclohepta-2,4,6-trien-1-one', 168341954: '4,6-ditert-butyl-2-(4,7-dichloro-8-methylquinolin-2-yl)-3-hydroxy-7-nitrocyclohepta-2,4,6-trien-1-one'})

qcelemental/molparse/from_string.py:347: ChoicesError

During handling of the above exception, another exception occurred:

    @using_web
    def test_pubchem_multiout_g():
        subject = """
        #pubchem: gobbledegook
        #pubchem: c6h12o
        #pubchem: formaldehyde*
        pubchem: tropolone*
    """
    
        with pytest.raises(qcelemental.ChoicesError) as e:
            with xfail_on_pubchem_busy():
                qcelemental.molparse.from_string(subject, return_processed=True)
    
        try:
            with xfail_on_pubchem_busy():
                qcelemental.molparse.from_string(subject, return_processed=True)
        except qcelemental.ChoicesError as e:
            assert e.choices[10789] == "2-hydroxycyclohepta-2,4,6-trien-1-one"
            # NOTE: 193687 no longer returned by PubChem. Adding a new choice
            # this is a brittle test due to changes on PubChem's end.
            # assert e.choices[193687] == "2-hydroxy-3-iodo-6-propan-2-ylcyclohepta-2,4,6-trien-1-one"
>           assert e.choices[85783535] == "(4-hydroxy-5-oxocyclohepta-1,3,6-trien-1-yl) dodecanoate"
                   ^^^^^^^^^^^^^^^^^^^
E           KeyError: 85783535

qcelemental/tests/test_molparse_pubchem.py:164: KeyError
-------------------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------------------
        Searching PubChem database for tropolone (all matches returned)
        Found 52 result(s)
        Searching PubChem database for tropolone (all matches returned)
        Found 52 result(s)
====================================================================================================================== warnings summary ======================================================================================================================
qcelemental/tests/test_gph_uno_bipartite.py::test_example2[2]
  /usr/local/lib/python3.11/site-packages/scipy/sparse/_index.py:134: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient.
    self._set_arrayXarray_sparse(i, j, x)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================================================== short test summary info ===================================================================================================================
SKIPPED [1] qcelemental/tests/test_molparse_validate_and_fill_chgmult.py:121: Skipped
============================================================================================== 1 failed, 1235 passed, 1 skipped, 2 xpassed, 1 warning in 10.54s ==============================================================================================

Additional context
Version: 0.29.0
Python 3.11
FreeBSD 15 STABLE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions