Created
October 19, 2022 00:21
-
-
Save lubianat/cf5da0af0911dc74a0a8742ad491709c to your computer and use it in GitHub Desktop.
pubchem2wikidata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pubchempy as pcp | |
cid = 44584134 | |
name = "cannabisin D" | |
compound = pcp.Compound.from_cid(cid) | |
ref = "|S248|Q278487" | |
quickstatements = ( | |
"CREATE\n" | |
f'LAST|Len|"{name}"\n' | |
'LAST|Den|"chemical compound"\n' | |
f'LAST|P31|Q11173{ref}\n' | |
f'LAST|P233|"{compound.canonical_smiles}"{ref}\n' | |
f'LAST|P234|"{compound.inchi}"{ref}\n' | |
f'LAST|P235|"{compound.inchikey}"{ref}\n' | |
f'LAST|P662|"{cid}"{ref}\n' | |
f'LAST|P2017|"{compound.isomeric_smiles}"{ref}\n' | |
f'LAST|P2067|{compound.exact_mass}U483261{ref}' | |
) | |
for synonym in compound.synonyms: | |
quickstatements += "\n" + f'LAST|Aen|"{synonym}"' | |
print(quickstatements) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment