PubChemPy icon indicating copy to clipboard operation
PubChemPy copied to clipboard

to_dic bugs on Substance

Open HYUNSEONG-KIM opened this issue 4 years ago • 0 comments

Some data in Pubchem does not provides compound value while other data source provides. In this case, to_dataframe or to_dict funtion generate error no "compound"

    """
    Some substances of pubchem data doesnot provide compound key
    for c in self.record['compound']:
        if c['id']['type'] == CompoundIdType.STANDARDIZED:
            return c['id']['id']['cid']

    """
    if 'compound' in self.record:
        for c in self.record['compound']:
            if c['id']['type'] == CompoundIdType.STANDARDIZED:
                return c['id']['id']['cid']

I think it can be fixed with checking whether Substances has a "compound" key in record

example case bug occurres: pcp.get_substances("65983-31-5", "name")

It return almost 21 substance from pubchem server and 20th substance

Substance(342573178) has no "compound" key in record, therefore it generates errors when you use to_dataframe or to_dict

HYUNSEONG-KIM avatar Aug 18 '21 04:08 HYUNSEONG-KIM