PubChem API tutorial¶
This tutorial explains some use cases of the PubChem API. Note that we also have another API in this package called pubchemview
that has its separate tutorial.
# Import the required modules for PubChem API
from provesid.pubchem import PubChemAPI, Domain, CompoundProperties
import json # mostly for nicer printing :-)
# Initialize the PubChem API client
pc = PubChemAPI()
CID, SID, and AID¶
CID (Compound ID), SID (Substance ID), and AID (Assay ID) are unique identifiers used by PubChem:
CID (Compound ID): Identifies a unique chemical structure in the PubChem Compound database. Each distinct molecule has a single CID, regardless of how it was submitted or by whom. Example: formaldehyde has CID 712.
SID (Substance ID): Identifies a record in the PubChem Substance database, which represents a substance as submitted by a depositor. Multiple SIDs can map to the same CID if different sources submit the same compound. Example: formaldehyde may have many SIDs from different submitters.
AID (Assay ID): Identifies a bioassay record in the PubChem BioAssay database. Each AID corresponds to a specific biological test or experiment, which may reference one or more CIDs or SIDs.
In summary:
- CID = unique chemical structure
- SID = depositor-submitted sample/record
- AID = bioassay/experiment
Whatever we need to retrieve from PubChem, we first need to look for these IDs.
How to search for IDs?¶
The next code cell demonstrates how to use the PubChemAPI
to search for CIDs (Compound IDs) and SIDs (Substance IDs) in PubChem by querying with different types of identifiers such as chemical names, SMILES strings, or CAS numbers.
pc.get_cids_by_name('aspirin')
looks up CIDs by the compound name "aspirin".pc.get_cids_by_name('water', domain=Domain.COMPOUND)
searches for CIDs in the compound domain using the name "water".pc.get_cids_by_name('8000-78-0', domain=Domain.SUBSTANCE)
searches for CIDs in the substance domain using a CAS number.pc.find_cids_comprehensive('8000-78-0')
performs a comprehensive search across both compound and substance domains for the given CAS number, returning the found cid numbers and how they are found.pc.get_sids_by_name('8000-78-0')
retrieves SIDs by searching with a CAS number.
You can use these methods to retrieve PubChem IDs by providing any identifier (name, SMILES, CAS, etc.). The API will return the corresponding CIDs or SIDs, making it easy to map between different chemical identifiers and PubChem records. This is useful for integrating chemical data from various sources or for further property lookups in PubChem.
# 1. Default behavior (backward compatible)
cids_aspirin = pc.get_cids_by_name('aspirin') # Returns clean list of CIDs
print(f"cids found for the name aspirin: {cids_aspirin}")
# 2. Explicit compound domain
cids_water = pc.get_cids_by_name('water', domain=Domain.COMPOUND)
print(f"cids found for the name water: {cids_water}")
# 3. Search in substance domain (new capability)
cids_garlic_oil = pc.get_cids_by_name('8000-78-0', domain=Domain.SUBSTANCE) # [6850738]
print(f"cid found for the CAS number 8000-78-0: {cids_garlic_oil}")
# 4. Comprehensive search across both domains
results = pc.find_cids_comprehensive('8000-78-0')
# Returns detailed results with recommendations
print(f"comprehensive search results for the CAS number 8000-78-0: {results}")
# 5. Enhanced SID search
sids = pc.get_sids_by_name('8000-78-0') # Returns clean list of SIDs
print(f"first 5 sids found for the CAS number 8000-78-0: {sids[:5]}")
cids found for the name aspirin: [2244, 1983, 9871508, 56842252, 145904, 3776, 3032790, 16099592, 24936226, 24847798, 23666729, 11980079, 3014024, 24847791, 169926, 91626, 702, 123131972, 69725476, 24847819, 12280114, 9905405, 133472, 119032, 68484, 15110, 6247, 10245201, 10245200, 56841602, 9938610, 10745, 68749, 23676700, 4064, 30987, 71586755, 25157143, 156866, 16126783, 155576, 12759847, 171511, 5748307, 5793, 222, 24847961, 24666, 44219, 9841438, 53040, 54681542, 8591, 9818919, 24847966, 31869, 131750206, 3080848, 137329, 57384021, 5161, 187065, 53477504, 46780045, 29971035, 90478514, 162733, 21102, 522325, 91758292, 46186934, 23680279, 69975280, 530150, 56843206, 199027, 131953074, 77845952, 72204814, 11508774, 6453785, 91820534, 79668, 67421543, 5492635, 139196123, 139196122, 139196121, 71508666, 129672411, 86676097, 9864979, 132282528, 67463240, 54404402, 9935793, 225394, 133162, 83966, 12490, 135, 176479303, 176479302, 134716626, 131716973, 129682947, 53633780, 51404094, 44153517, 20975655, 13037297, 12332833, 11182709, 11139098, 93093, 83151, 69039, 11812, 71593881, 67546490, 62705023, 23452462, 526502, 73922, 138319320, 91820043, 91819941, 2820813, 9863414, 338] cids found for the name water: [702, 962, 3007857, 3014024, 10129877, 24341, 3776, 6251, 23053647, 56841620, 24602, 57417360, 61789, 8518, 5564, 1038, 936, 753, 76958463, 71401949, 20055509, 16203739, 6914120, 5362443, 5282241, 656838, 316175, 237873, 105142, 104752, 61818, 60754, 14923, 338, 135564751, 135526609, 129010977, 86291593, 71405231, 25022378, 24906252, 24847974, 23677831, 23677829, 23665760, 23503278, 22242641, 21993411, 21962138, 21899381, 21892291, 21889133, 21886435, 21881883, 18673298, 18373917, 18366337, 11990828, 11431811, 5463880, 5362461, 5282315, 4327536, 656867, 517202, 447138, 357763, 274331, 162263, 153388, 62921, 26042, 24843, 23954, 23266, 17559, 14804, 13755, 11048, 8478, 2519, 807, 204, 22272175, 21534740, 13001166, 22026445, 18504229, 71346483, 67803299, 17768942, 22066309, 71425804, 71366719, 71350427, 71346967, 57498073, 21585139, 16217612, 13000445, 71405760, 71353825, 69879782, 71344735, 186342, 19429818, 16216984, 22366125, 22146520, 21871715, 20266850, 72499223, 57422062, 22673283, 6093208, 71348332, 12203052, 27521, 10197601, 71331287, 56972364, 56972317, 22734730, 22135787, 13000306, 71414876, 71346929, 57350232, 21651140, 21584184, 19419857, 71344303, 9553856, 132274861, 22728543, 22023151, 132274950, 86587095, 69863147, 67004557, 176399, 167994672, 56972365, 25022097, 19773970, 961, 118324268, 135487615, 57351388, 61363, 22230, 71414259, 23665762, 28179, 135522907, 25210323, 24643, 24470, 71445275, 59904312, 57350948, 57348145, 57348098, 22717375, 18988970, 10199332, 5460604, 92028246, 72500034, 71360288, 71352781, 71350869, 71331635, 71317684, 68762216, 66633516, 56840831, 44135796, 22743540, 22141362, 21743480, 18541607, 17994152, 16213174, 16212540, 16212115, 15787826, 15390102, 3955344, 138396476, 71443208, 71400815, 71381438, 71356641, 71353527, 71350986, 71347766, 66732985, 57377122, 57376989, 57370492, 57370235, 57348105, 56924536, 56845692, 56842124, 23446377, 22377415, 22118245, 18519412, 17749104, 16213628, 16212879, 16211491, 16211462, 16211397, 16211218, 10290741, 6327870, 6093252, 3083938, 197162, 82163, 62672, 61509, 52483, 71361162, 71360908, 71358413, 71353797, 71346507, 71345419, 71310089, 68431776, 67528686, 67150293, 57377123, 56972689, 56777013, 53249209, 51035319, 46173011, 44135853, 25022096, 25021755, 25021616, 23700837, 23671208, 23663941, 23371183, 22138077, 20541540, 20223355, 20038200, 19884450, 18618641, 17749097, 16217276, 16213108, 16212264, 16212051, 16211958, 16211483, 16211467, 16211221, 14639556, 14639555, 14381521, 14174818, 13223556, 6451167, 167150, 61444, 24463, 92020445, 74764991, 72941472, 71441376, 71440897, 71432831, 71414593, 71367967, 71361566, 71317428, 71311207, 70700090, 66713581, 57370938, 57358548, 57352087, 57347804, 56972366, 56924513, 45790035, 44890813, 44119686, 25021676, 25021601, 24884271, 24884197, 23696962, 23693099, 23676759, 21616660, 20499058, 18180031, 17749212, 17749146, 16218760, 16217374, 16217084, 16213581, 16212299, 16212049, 16211857, 16211258, 15942308, 15774553, 516949, 136236057, 92028149, 92025418, 74765564, 71433871, 71422776, 71394215, 71374124, 71373932, 71345808, 71328216, 71317441, 71311513, 71311432, 66776672, 57349102, 54759107, 53384552, 53302125, 45357804, 45075687, 45074958, 44134512, 43835312, 25021469, 25021442, 25021325, 23683129, 23681144, 23318533, 21123078, 21114734, 20537282, 19261730, 18610802, 18454344, 16218610, 16218114, 16217246, 16213560, 16212733, 16212080, 16211806, 16211671, 15556730, 12496994, 11953895, 2724350, 92028950, 78759299, 71440872, 71405338, 71380181, 71378577, 71363259, 71358185, 71356213, 71338211, 71328494, 71312597, 71311505, 71310220, 71310192, 71309463, 57483993, 53384386, 44828775, 44717661, 44134537, 24211897, 23697313, 23212559, 21894687, 20849112, 19083739, 16212032, 16211745, 16211718, 15911372, 13054407, 138395382, 138395364, 138395350, 138395343, 131667319, 71491874, 71311831, 71310180, 71310016, 71306850, 70678853, 57376030, 56844299, 44630771, 23724856, 23679071, 21116606, 18674933, 17749098, 16685740, 16213065, 16211644, 6330566, 5492889, 2778096, 784, 86587398, 21864270, 16212939, 13060963, 752, 86278147, 22996550, 16219577, 5360545, 636371, 31239, 5754, 46874763, 21908982, 5282412, 104769, 14797, 11430, 977, 5355130, 15541, 123720, 5327, 2723, 5362549, 7896, 76045754, 16760658, 139859, 26041, 16247398, 3034828, 33919, 19096565, 22136924, 23938, 129867334, 90474021, 71317429, 71311462, 71311333, 71311140, 71310156, 71310154, 45051880, 45051677, 45051676, 21513379, 20449313, 16217299, 16217072, 16212363, 16211494, 62669, 86584229, 22392675, 22145617, 86585896, 22253497, 135430271, 21864137, 21910475, 18732, 21877175, 18672661, 86607755, 31255, 168937, 22595341, 22592949, 92933, 22124471, 18417210, 3485, 22592919, 2757371, 21885828, 22056973, 69104347, 86623588, 8337, 23719242, 82930, 23948, 20586, 11872, 297, 86602953, 6410, 1493, 67831299, 162650, 760, 76956083, 13000549, 5460177, 86590524, 23684896, 22272177, 85699776, 22504935, 67901, 21553975, 2796029, 157568, 7955, 7434, 33, 86597087, 71353075, 22722550, 6474107, 88483, 23950, 6509, 3496, 68147410, 66926435, 57468513, 56841779, 22418719, 22114717, 21999908, 87521027, 21958822, 21835276, 19815812, 14009234, 11029752, 446416, 47364, 12967, 10690, 86626548, 22342424, 11701241, 5289590, 33286, 9492, 86604601, 67825834, 44630158, 22326455, 12210273, 10890738, 6912088, 5360621, 428573, 118525, 23719240, 21409480, 19370624, 2723671, 119022, 78740, 73189, 6954, 135442942, 86654442, 86618275, 86589665, 22185937, 6433718, 2735133, 11024, 7187, 90473789, 66847609, 57443785, 21889635, 20437942, 74601, 21534, 7866, 880, 168007050, 135436526, 122130249, 86287517, 56845703, 14475644, 170058, 91525, 61158, 86643495, 86173777, 23690256, 23158968, 21998236, 18509570, 11830845, 93968, 6962, 6350, 129816435, 129726105, 129724380, 129718070, 86759356, 86652750, 86591755, 71375230, 71374526, 71374525, 71359202, 71353397, 71350479, 71349689, 71349112, 57351627, 46835179, 22737866, 22272224, 21954885, 19805595, 12252961, 9886258, 6857362, 5815585, 116941, 75921, 24568, 11348, 129774608, 129721969, 129677632, 118855779, 101288925, 87977824, 86597598, 86586962, 85716407, 71380225, 71356234, 71347261, 57475903, 23713072, 23616914, 23431894, 22673091, 22247451, 22222942, 21871863, 21689904, 20299614, 17913362, 9942167, 4306514, 2723939, 371707, 232711, 165887, 160430, 61078, 60966, 22253, 16666, 15938, 12699, 7857, 222, 138398586, 131728955, 118855885, 118484112, 86668779, 85888458, 73425430, 71368490, 71345901, 57469574, 55255088, 23662399, 23219155, 19695116, 17858755, 12021749, 10441651, 20280, 13740, 6552, 769, 135565636, 131731673, 129778761, 129723846, 129700863, 129689778, 129679291, 129675734, 129671478, 129657478, 91972093, 88505004, 87656717, 86741597, 86689193, 86664769, 86641310, 86628739, 86622776, 86609354, 86605536, 86588300, 86199765, 71367722, 70394911, 60146744, 23703071, 23681166, 22235265, 18377865, 11433187, 24261, 4765, 131636577, 86735838, 86648037, 86607486, 86603989, 71440782, 71402709, 71369415, 71368313, 71359808, 71347816, 71310629, 68812705, 57429219, 57370680, 44537614, 22287110, 19804522, 12203051, 6101932, 5284544, 5284498, 78830, 13762, 13157, 11768, 10624, 135421797, 129818964, 129701434, 129681220, 129677776, 129676264, 90034590, 89251972, 86747957, 86683494, 86649789, 86625244, 86606854, 86585368, 86180758, 85602025, 71362604, 69597608, 66916791, 66808090, 66602552, 60161466, 57426399, 57349646, 57348178, 57347188, 23677046, 22386424, 22373257, 22315797, 21916312, 21894508, 21866399, 21610435, 18914200, 14513727, 6419933, 5460674, 519034, 108762, 94176, 88163, 70620, 33258, 24654, 14798, 8905, 946, 787, 156588798, 135398740, 131727349, 129759742, 118796904, 90472776, 87149943, 86736801, 86634112, 85558312, 71425292, 71425290, 71310495, 55297133, 23686675, 23667259, 20548581, 15763986, 15620607, 11500504, 10197721, 2733487, 444972, 170750, 165295, 162073, 91502, 88045, 84487, 68152, 61482, 33344, 21674, 16887, 8555, 7860, 6059, 2266, 171714294, 129762446, 129728305, 117065089, 87481768, 87120601, 87063789, 86753056, 86709899, 86633292, 86584666, 86171738, 85770644, 71309211, 69477857, 67393429, 66577907, 23675322, 23670318, 23668465, 23664709, 23662383, 23434731, 22066310, 21325672, 20041894, 19987080, 18799168, 18432037, 16638467, 16211025, 12961638, 12598086, 12306753, 12056760, 9859805, 2794891, 464205, 85181, 72324, 67815, 36605, 33129, 31298, 24424, 18205, 9539, 6579, 712, 155889382, 138401843, 138399938, 86641670, 86615699, 86606902, 72206655, 56972387, 54587890, 51342034, 23702478, 23693092, 23687555, 21146529, 19893943, 12000666, 11966044, 5359260, 3017080, 2734570, 107957, 104811, 72755, 69398, 31295, 19522, 18134, 12660, 1146, 996, 131733698, 129736564, 129730284, 129690789, 87769700, 86745966, 86733486, 86732972, 86587932, 72608568, 69202663, 57448088, 57369836, 55281145, 45358975, 44149824, 24768591, 23714421, 16211447, 15991576, 11540687, 5359596, 5282372, 4585873, 3660445, 3014526, 441129, 148123, 104930, 75634, 75311, 60933, 8490, 6794, 6518, 943, 169443792, 139060188, 139025121, 101591487, 78067556, 78063621, 78062595, 78062569, 78061897, 78061255, 78060609, 78060507, 71710952, 71370608, 53888304, 24940680, 23692293, 23689131, 23671664, 22814120, 16212126, 14099368, 6455118, 6102355, 6096643, 5484731, 4292413, 181649, 129596, 83273, 70297, 23939, 18462, 17596, 9357, 168356055, 166643219, 156630724, 145707123, 141216119, 141203038, 141089488, 140213962, 139267690, 138402891, 137218996, 136467089, 135495951, 133053673, 132471396, 132427470, 131738012, 131735004, 131735001, 131727087, 131721204, 131711019, 129868489, 129851793, 129851246, 129849865, 129849183, 129846600, 129844625, 129831837, 129830210, 129828960, 129821872, 129821223, 129818797, 129816442, 129814532, 129801703, 129800930, 129777732, 129776806, 129774768, 129774752, 129761635, 129735777, 129733137, 129731298, 129729228, 129723800, 129723698, 129723678, 129723497, 129722896, 129722488, 129722063, 129720538, 129717101, 129714186, 129712510, 129710631, 129709961, 129702968, 129701830, 129700086, 129696259, 129696000, 129695455, 129694510, 129690921, 129689933, 129686485, 129685523, 129682141, 129681784, 129680616, 129678652, 129676924, 129676266, 129675966, 129675779, 129675553, 129675363, 129675036, 129674481, 129673362, 129673347, 129673181, 129672411, 129671737, 129670412, 129670221, 129669670, 129668636, 129656466, 129655597, 129651599, 129643640, 129637324, 129631210, 126455774, 122690552, 118050117, 101943059, 101917263, 101917241, 101917240, 91886582, 91886299, 90470232, 89943362, 89905098, 89898153, 89400709, 88739116, 88695168, 88671665, 88666521, 88639310, 88384120, 88265678, 88064042, 87967907, 87873806, 87853654, 87636061, 87601860, 87584685, 87499386, 87457314, 87444821, 87428479, 87355078, 87343261, 87324624, 87232499, 87217968, 87215580, 87210857, 87207964, 87106786, 86751974, 86741158, 86622996, 86604269, 86587238, 86199760, 86191910, 85878677, 85866601, 85794222, 85770529, 85701161, 85612092, 85369471, 78333428, 76650988, 76055162, 72710723, 71777661, 71443505, 71443210, 71443209, 71425803, 71405999, 71401999, 71363300, 70608210, 70538087, 70149958, 69865713, 69780942, 69602139, 69483014, 69327031, 69301655, 69115321, 69115191, 68654644, 68431579, 68276293, 68134142, 67948767, 67910133, 67896833, 67744387, 67723360, 67513613, 67195532, 66978509, 66895719, 66894041, 66809815, 66781230, 66728037, 66667939, 66587617, 57506708, 57489594, 57485836, 57469757, 57450237, 57439894, 57436787, 57426053, 57419141, 57417501, 57370964, 57345277, 55300695, 53471183, 50920014, 42626543, 24942383, 24942035, 24941040, 23284060, 23219156, 22908381, 22484390, 22272179, 21983494, 21907589, 21798619, 21659908, 21611925, 20571595, 20435904, 20082953, 19805102, 19756075, 19705606, 18680725, 18674898, 18403962, 18355644, 17985087, 17837970, 17819051, 17765803, 13010706, 12896473, 12305791, 12201322, 12161499, 6915905, 6286755, 6102352, 6102340, 6102333, 6102329, 6102328, 6101205, 3314739, 2737518, 643989, 525128, 449052, 447626, 171528, 168060, 62728, 23978, 23925, 8376, 6422, 5234, 3314, 2285, 172990165, 169490686, 168433974, 162370932, 156614053, 146037931, 145915956, 141318349, 141293884, 139175519, 135813746, 131749950, 131740210, 131738798, 131735003, 131732583, 131731185, 131729174, 131728255, 131727260, 131726924, 131725982, 131725292, 131713080, 129892784, 129891948, 129889604, 129867740, 129865590, 129858831, 129852334, 129852046, 129850250, 129847610, 129845511, 129837372, 129834197, 129829468, 129824316, 129824283, 129823664, 129822216, 129821361, 129817179, 129812192, 129810662, 129801791, 129801096, 129783317, 129776108, 129775645, 129774899, 129773375, 129773258, 129765630, 129763021, 129762770, 129757392, 129737493, 129736285, 129735107, 129734959, 129731851, 129730518, 129729883, 129726369, 129724175, 129723765, 129723740, 129723700, 129722893, 129722635, 129722409, 129722321, 129722272, 129722022, 129721138, 129720199, 129719865, 129719405, 129719359, 129719255, 129717106, 129710156, 129704855, 129700522, 129700168, 129700019, 129695531, 129695441, 129695407, 129694987, 129694711, 129693847, 129692845, 129691929, 129689808, 129687616, 129682081, 129681760, 129681750, 129681585, 129681529, 129681286, 129680180, 129679788, 129678972, 129678800, 129675770, 129675690, 129674795, 129674273, 129674063, 129673763, 129673558, 129671600, 129670138, 129669158, 129669125, 129668800, 129668169, 129664504, 129663718, 129662601, 129662560, 129661925, 129661345, 129657662, 129656525, 129655495, 129654820, 129651772, 129628771, 122690555, 121364172, 118352659, 91886665, 88833085, 88774532, 88757371, 88749193, 88732318, 88690988, 88672111, 88614842, 88484704, 88455395, 88388053, 88285094, 88218405, 88211116, 88195325, 88174295, 88111403, 87705869, 87669415, 87563500, 87547083, 87512721, 87394417, 87370726, 87358792, 87239058, 87222130, 87111508, 87102970, 86759322, 86752302, 86720799, 86718372, 86686658, 86675365, 86672217, 86653311, 86646639, 86645562, 86636928, 86636527, 86628345, 86610273, 86609355, 86609353, 86587264, 86189816, 86172866, 85994546, 85968546, 85941047, 85941015, 85856990, 85801572, 85779021, 85767504, 85607610, 78070260, 73425395, 71656137, 71464356, 71418121, 71402399, 71396114, 71396113, 71367571, 71360104, 71356755, 71356660, 71356118, 71347512, 71337975, 71333887, 70551173, 70423715, 68431578, 68278177, 68133037, 68131454, 67908624, 67703522, 67630282, 67567074, 66898929, 66631872, 57432895, 57370287, 57346125, 56972828, 56972429, 45051631, 25021465, 23690614, 23688577, 23686037, 23675106, 23290101, 23057176, 22995068, 22812903, 22619266, 22482783, 22472390, 22355462, 22129409, 21951433, 21703499, 21509454, 21464649, 21463045, 21314177, 21072248, 20521938, 20491302, 20475614, 20240720, 19755102, 19692084, 19604751, 19363080, 19023059, 18997684, 18410394, 17867088, 16639139, 16212846, 12209671, 12200817, 12199051, 11979385, 10010955, 5702198, 2724197, 542762, 521998, 458216, 439341, 204168, 185507, 82938, 78738, 29089, 24408, 23931, 23930, 12586, 10613, 3964, 170999885, 168475821, 168349619, 167680753, 164890320, 162540392, 157378284, 155928331, 154701911, 151692815, 146680245, 146036804, 146020714, 145945727, 145915963, 145915955, 145915954, 141037369, 141030903, 140755910, 140412813, 140307403, 139063674, 137219078, 135442941, 133188498, 133188491, 132471432, 132276692, 131748825, 131744751, 131738264, 131736877, 131726685, 131719387, 131716747, 131711047, 129887634, 129878639, 129866108, 129866038, 129860956, 129858638, 129858174, 129856307, 129856097, 129852768, 129850717, 129846999, 129845847, 129845548, 129837375, 129831533, 129828965, 129828917, 129827334, 129827186, 129825684, 129824315, 129824241, 129824220, 129824189, 129824186, 129823716, 129822273, 129821664, 129821509, 129821289, 129818975, 129818801, 129816999, 129815978, 129814341, 129806277, 129804761, 129803424, 129802326, 129802245, 129801669, 129801571, 129801042, 129800911, 129800906, 129795249, 129789221, 129783436, 129776811, 129775692, 129775222, 129773632, 129772795, 129761452, 129761372, 129761229, 129748380, 129740063, 129736572, 129736513, 129735897, 129731865, 129731801, 129729189, 129728588, 129728457, 129728426, 129728026, 129728000, 129727047, 129726533, 129725087, 129724630, 129724361, 129724264, 129724237, 129723701, 129723692, 129722636, 129722449, 129722444, 129722420, 129722387, 129722377, 129722370, 129722210, 129722177, 129722159, 129721814, 129721044, 129717057, 129716763, 129714457, 129714042, 129713855, 129713789, 129713707, 129711713, 129706954, 129705100, 129704045, 129704041, 129701944, 129701569, 129698241, 129696910, 129695828, 129694739, 129693524, 129693438, 129693048, 129692870, 129692063, 129691878, 129691449, 129691315, 129691312, 129690537, 129689598, 129689591, 129689582, 129689561, 129689143, 129681479, 129680605, 129678605, 129678428, 129677618, 129677031, 129676292, 129675952, 129675932, 129675755, 129675004, 129674257, 129674252, 129674249, 129674178, 129672405, 129670597, 129670129, 129668662, 129668439, 129666629, 129664841, 129664744, 129662325, 129662192, 129660678, 129659069, 129656492, 129656417, 129653440, 129651309, 129645095, 129641233, 129216226, 129206506, 122690549, 118307501, 88784357, 88772125, 88731141, 88541435, 88391422, 88331337, 88245840, 87785223, 87686944, 87670898, 87640794, 87579661, 87223372, 87222642, 87187855, 87078381, 86758607, 86755393, 86752929, 86747175, 86745547, 86740279, 86734818, 86734814, 86711776, 86700882, 86663602, 86658869, 86653884, 86640070, 86619100, 86616699, 86609212, 86597967, 86596730, 86584346, 86070621, 86037584, 85983570, 85983568, 85941044, 85853018, 85768189, 85640159, 78060957, 78060906, 76957584, 75531242, 73178999, 71408632, 71401545, 71393790, 71374023, 71372270, 71361463, 71358165, 70629306, 70593637, 70462750, 70408227, 70030519, 69989986, 69968969, 69889523, 69864905, 69536162, 69505824, 69298618, 69115188, 69019638, 68834865, 68819625, 68445989, 68427920, 67843107, 67805491, 67483236, 67420962, 67047509, 57370410, 57348039, 45926634, 23718182, 23689076, 23663426, 23445216, 22679077, 22611478, 22593499, 22501395, 22251345, 22215981, 22102213, 21999729, 21976680, 21899746, 21895857, 21639426, 21287093, 20511524, 20385292, 20242335, 20040703, 19956690, 19902870, 19817402, 19809534, 19429817, 18616040, 18506713, 17770231, 16750101, 16218596, 15135452, 13871125, 12567338, 6419957, 6328657, 4648096, 4378561, 449047, 448068, 446551, 439586, 414251, 340067, 201412, 186703, 85025, 67818, 62781, 31146, 19648, 9554, 5258, 4775, 284, 172433105, 172432184, 154732526, 146001291, 146001272, 145944173, 141757339, 141750416, 139776674, 138115792, 135823796, 135565581, 132278256, 131741646, 131738371, 131734313, 131718373, 131714480, 131711181, 131664222, 129861620, 129856671, 129856512, 129851047, 129848124, 129846906, 129831485, 129828981, 129824305, 129824295, 129824266, 129824229, 129820865, 129820139, 129818308, 129803561, 129801069, 129801045, 129799623, 129793133, 129792499, 129777636, 129774980, 129774611, 129774606, 129773404, 129762637, 129738175, 129736405, 129735641, 129735044, 129731862, 129729709, 129726270, 129724595, 129724130, 129723540, 129723236, 129722726, 129722378, 129722280, 129722167, 129721977, 129721976, 129720620, 129714199, 129712306, 129711462, 129705115, 129701800, 129701785, 129695597, 129693992, 129693587, 129692310, 129691811, 129690925, 129690899, 129689772, 129685559, 129682027, 129678547, 129674266, 129671673, 129671292, 129669665, 129664675, 129664674, 129664655, 129662248, 129656055, 129652261, 129651231, 129651144, 122674143, 92022697, 90118051, 88483820, 88456705, 87522641, 87323518, 87302362, 87220393, 87194293, 87154089, 87074870, 86754923, 86751209, 86745446, 86744677, 86663138, 86660791, 86657083, 86647907, 86642596, 86634241, 86620092, 86619547, 86618345, 86618021, 86603848, 86601158, 86598986, 86595252, 86593820, 86187791, 85941019, 85770526, 78064039, 77168287, 73995024, 71445296, 71441813, 71441803, 71441490, 71441097, 71422021, 71422020, 71421979, 71400273, 71399970, 71391337, 71387895, 71375026, 71374247, 71374093, 71373115, 71372707, 71367966, 71365319, 71350593, 71348019, 71347639, 71343972, 71343379, 71343378, 71341447, 71331411, 70523385, 70386577, 70275222, 69987886, 68492200, 68461907, 67934685, 67827592, 67721007, 67720230, 67645664, 67448433, 66989973, 66930505, 57466195, 57451193, 57370470, 57369408, 57348662, 56841935, 56607088, 54430733, 49868301, 49868300, 49868298, 49868232, 49868230, 49868226, 45120043, 45117791, 44630374, 42608358, 24801876, 23667612, 23666456, 23353430, 23287276, 22497775, 22410973, 21703503, 21389512, 20437090, 18967484, 18472940, 16218734, 16217081, 16211588, 16211505, 13223555, 10130790, 6102337, 6097027, 3270262, 3031184, 439665, 190201, 170682, 159290, 101561, 42981, 23995, 14800, 12496, 6036, 3366, 1049, 768, 172914360, 172432196, 164890331, 145722117, 139201574, 139196824, 139175517, 139064950, 139062845, 139061433, 139033726, 138388112, 136343917, 136241773, 132471982, 132280054, 131749551, 131749107, 131740685, 131727010, 131713566, 131713223, 129866193, 129865264, 129857501, 129824227, 129823605, 129820835, 129820643, 129818919, 129817926, 129809350, 129801802, 129801378, 129800881, 129784439, 129776935, 129775270, 129774825, 129774410, 129774391, 129772342, 129772092, 129770292, 129766664, 129764523, 129764482, 129760175, 129751748, 129733574, 129731815, 129729527, 129723996, 129722870, 129722493, 129722402, 129720778, 129720776, 129719860, 129717931, 129717319, 129717146, 129717145, 129714550, 129714549, 129712360, 129711856, 129703878, 129703688, 129702984, 129702191, 129693037, 129689548, 129681177, 129678455, 129675772, 129674301, 129674287, 129671295, 129670400, 129670186, 129664695, 129657142, 129628727, 126743892, 121237577, 91972120, 91757761, 89488055, 87399670, 87256863, 87217295, 86760518, 86759410, 86756116, 86754654, 86753879, 86752900, 86744058, 86738608, 86736560, 86734189, 86700888, 86688587, 86621318, 86620073, 86598827, 86596525, 86037579, 86015820, 78060874, 73791813, 73308938, 71753004, 71442353, 71396115, 71380224, 71380223, 71380222, 71380221, 71380220, 71380219, 71373234, 71368688, 71367715, 71366893, 71350987, 71341448, 71339122, 71329600, 71325663, 71325660, 71312420, 71311269, 69946099, 69342014, 69007964, 68594318, 67689272, 66669738, 57370974, 57357737, 57349063, 57348042, 57348032, 56972428, 56972427, 56972368, 54684459, 54682468, 53472099, 53471399, 53471181, 51003670, 50921721, 50921326, 50920973, 50920764, 49849586, 46780452, 24802442, 23685997, 23682789, 23665404, 22041847, 21961003, 21933621, 21873181, 21663323, 21259550, 20625617, 20568798, 20552521, 20308954, 20085856, 19426511, 18756449, 18697624, 18694733, 18002671, 17749110, 16686084, 16212900, 16212119, 16211656, 16211596, 16211524, 16211523, 16211485, 16211236, 10219754, 9800166, 6437376, 6093260, 5489029, 5284346, 5282253, 3033839, 2724065, 2723854, 449488, 197172, 166871, 161040, 134930, 75771, 73972, 67734, 66854, 64763, 62649, 62133, 61474, 41679, 28015, 24928, 24645, 24597, 24203, 22324, 17466, 13387, 11668, 11312, 8577, 7847, 6116, 6049, 3837, 887, 190, 180, 167531355, 164185914, 155801781, 154700982, 145722123, 139147519, 139079822, 139062179, 139056279, 139038964, 138400296, 136239744, 136239715, 136239714, 135398752, 134821334, 134813005, 132993175, 131747051, 131742577, 131742160, 131728552, 131726756, 131721206, 131715182, 131715164, 131711295, 129887322, 129866951, 129858850, 129845853, 129826752, 129820753, 129805196, 129802537, 129802401, 129791860, 129774947, 129774920, 129774346, 129772271, 129761178, 129741639, 129726580, 129726529, 129722453, 129722447, 129722314, 129717254, 129717151, 129717086, 129704706, 129703874, 129701905, 129695193, 129692291, 129691292, 129689750, 129682130, 129674244, 129671609, 129669981, 129664656, 129664647, 129657389, 129656509, 129656479, 129653479, 124219871, 91825725, 88725650, 87842193, 87704458, 87398885, 87222037, 87148445, 86750994, 86750993, 86744678, 86744338, 86743190, 86738406, 86691358, 86682550, 86633216, 86633214, 86625663, 86597456, 86587466, 86037585, 78061501, 74933466, 73770655, 73308869, 73308868, 71444859, 71441438, 71402278, 71394885, 71380213, 71376920, 71374051, 71370064, 71368852, 71365808, 71365806, 71365777, 71356980, 71350901, 71350318, 71347237, 71345823, 71343935, 71330698, 71330542, 71329117, 71318034, 71311426, 71310074, 71309985, 70700020, 67108121, 57376986, 57376417, 57375635, 57372096, 57370373, 57370370, 57351626, 57351463, 57351250, 57350480, 57348038, 57348023, 57348022, 57346060, 57346057, 57346056, 57346054, 56972369, 53471987, 53471885, 53471339, 53443006, 53249218, 53249207, 51346568, 51346567, 50934495, 50920696, 49868510, 49868292, 49868282, 47002317, 45120044, 45051750, 45051674, 44537612, 44154603, 25022292, 25022213, 25022212, 25021854, 25021617, 25021615, 25021600, 24884366, 24884165, 24820382, 24212121, 23708904, 23704354, 23702287, 23700087, 23698049, 23688291, 23688289, 23688288, 23681143, 23679066, 23676710, 23673029, 23671439, 23213303, 23084028, 23065692, 22731701, 22613964, 22572548, 22348481, 22242376, 22138113, 22002992, 21923999, 21901312, 21694667, 20734543, 20565568, 20360350, 20142034, 19938959, 19850629, 19818017, 19103329, 18530245, 18475367, 18407952, 18355679, 17749157, 17749147, 17749113, 17749100, 16218649, 16213106, 16212943, 16212852, 16212572, 16212063, 16212054, 16211966, 16211847, 16211569, 16211501, 16211473, 16211464, 16211346, 15619088, 14127923, 13982876, 12211273, 11263466, 11137276, 9810996, 9795465, 6093259, 5462451, 5284429, 5281752, 5281750, 5281743, 5281735, 5281729, 3084221, 3084150, 3084147, 3084136, 2783194, 2735107, 906426, 368154, 202215, 198005, 197915, 186043, 181526, 177577, 176168, 170358, 168046, 167363, 167265, 166918, 165791, 165644, 165350, 160166, 159250, 155385, 146100, 122156, 114843, 107938, 104981, 94507, 71376, 68240, 62712, 62671, 62662, 62640, 61475, 24821, 24644, 24564, 23964, 23462, 8028, 8021, 6209, 5793, 1221, 1140, 935, 750, 260, 177, 172966209, 171039874, 171039853, 171039816, 171039774, 171039753, 171039674, 168337262, 168307971, 168307627, 156580238, 155817542, 155294752, 154827467, 139145628, 139080347, 139074575, 139063450, 139062345, 139033727, 138401821, 138398431, 138396478, 135524906, 135409852, 135403647, 131719237, 131664165, 129865158, 129856312, 129830690, 129818470, 129807604, 129802543, 129801692, 129773791, 129772087, 129768719, 129727765, 129722448, 129722109, 129720775, 129719759, 129717212, 129717156, 129717072, 129694526, 129688817, 129674239, 129674225, 129672985, 129670377, 129668193, 129664651, 129656450, 122174003, 121232713, 118796939, 101453941, 92026000, 92003261, 91886362, 91826577, 90469715, 88684523, 86750997, 86750996, 86750630, 86747429, 86735039, 86672619, 86643822, 86619912, 86608888, 86603147, 76965330, 76334042, 72710688, 72458207, 71714410, 71447185, 71445544, 71443057, 71443007, 71441139, 71428160, 71422773, 71417680, 71415868, 71405918, 71404207, 71383446, 71379447, 71366919, 71362659, 71358111, 71354441, 71350746, 71344145, 71343574, 71333335, 71331199, 71322487, 71322486, 71310010, 68110089, 67852048, 57375648, 57370928, 57370413, 57358903, 57356985, 57351143, 57350330, 57348740, 57348514, 57346090, 57346009, 56972363, 53485203, 53471880, 53471875, 53471197, 53470804, 53442939, 53442863, 53249650, 53249303, 50921931, 50921461, 49822542, 46739021, 44890729, 44144468, 44135752, 44134881, 44118703, 25087130, 25022290, 25021990, 25021251, 24884280, 24884256, 24802115, 24208755, 23680479, 23666339, 23664054, 23663403, 23662406, 23165641, 22286931, 22220764, 22042048, 21931398, 21657042, 21584532, 21584119, 21546488, 21330797, 20847945, 20205723, 19390379, 19013755, 19006901, 18519411, 17943241, 17924347, 16218764, 16218593, 16218430, 16217342, 16217278, 16216920, 16213643, 16213310, 16213235, 16213153, 16213068, 16212893, 16212847, 16212594, 16212505, 16212469, 16212112, 16212056, 16211515, 16211493, 16211490, 16211480, 16211458, 16211120, 15959344, 14389423, 12987845, 12598454, 12416832, 11955373, 11954008, 10220511, 10214376, 6455809, 6453889, 6436139, 6328269, 6101830, 6093274, 5484389, 5380876, 5355258, 5282419, 5281734, 5280906, 5280441, 4921319, 4140276, 3772977, 3310889, 3084145, 3084144, 3083123, 3082854, 3049941, 3048004, 3039901, 2736704, 2735142, 2735101, 2724193, 516858, 516788, 452313, 441374, 439369, 203091, 197963, 186053, 185475, 181855, 181352, 177152, 169049, 165797, 159681, 155074, 154213, 150191, 134672, 111123, 104805, 82291, 77222, 73090, 72325, 71372, 69789, 69121, 67545, 64669, 62667, 62600, 61639, 61460, 61456, 30318, 30200, 25133, 23986, 22985, 17247, 15433, 14017, 8071, 7906, 6581, 5988, 2392, 1464, 1100, 890, 312, 264, 171039722, 171039647, 171039574, 168347268, 168307604, 167531356, 155490185, 141261612, 141025616, 139079436, 139077996, 139075544, 139074843, 139063547, 139063451, 139063449, 139061411, 139061253, 139059514, 138400962, 138399201, 138398117, 138397862, 138397667, 138397665, 138397607, 138397247, 138397246, 138397096, 135511839, 131716952, 129854769, 129842479, 129837333, 129830734, 129817350, 129801753, 129800983, 129773277, 129748083, 129726244, 129711231, 129700163, 129691385, 129656497, 129656493, 129656489, 129656480, 129656447, 127255390, 121225506, 92025731, 91997687, 91826558, 91757802, 90474108, 86750995, 86747645, 86733162, 86620080, 86620077, 86620075, 86616944, 86607620, 86597561, 86584296, 78062986, 77906386, 76974379, 76418877, 76418808, 72720466, 72720461, 71445121, 71429858, 71414849, 71414848, 71413559, 71406926, 71406648, 71405919, 71403690, 71396104, 71380503, 71379928, 71379446, 71369803, 71363744, 71361734, 71348326, 71347845, 71342343, 71339022, 71338958, 71336803, 71329136, 71318605, 71317118, 71311383, 71311290, 71310037, 69591729, 69264014, 69024896, 68706663, 57461243, 57459372, 57377001, 57375828, 57375628, 57373339, 57371038, 57350513, 57348862, 57348453, 57346835, 56972362, 56928061, 56924537, 56924531, 56846332, 56841787, 55278506, 54792425, 53471873, 53471131, 53395443, 53393588, 53393206, 53393195, 53393191, 53249422, 53230138, 53229957, 53217404, 53216300, 51358356, 50998503, 50908986, 49868425, 49822874, 49822712, 46739018, 45117792, 45045680, 45036876, 45036873, 44717127, 44149754, 44135928, 44135619, 44119796, 44119671, 44118760, 44118547, 44118543, 44118539, 42609609, 25022168, 25021861, 24726821, 24207206, 23695977, 23693097, 23687711, 23676737, 23673600, 23672303, 23668795, 23666172, 23665591, 23664778, 23664641, 23662384, 23616301, 22868018, 22836357, 22421176, 22421165, 22397602, 21946612, 21910000, 21158021, 21155397, 20977854, 19849276, 19097533, 18526305, 18525703, 18463206, 18410391, 17998756, 16219881, 16217774, 16217484, 16216921, 16213469, 16213449, 16212977, 16212708, 16212360, 16211802, 16211738, 16211737, 16211702, 16211643, 16211474, 15978064, 15771041, 15762351, 14074940, 13417361, 13258912, 12767855, 12677290, 12598458, 12329347, 11954336, 11667949, 11053918, 6331881, 6327210, 6093374, 5458800, 5282393, 5281675, 3084397, 3082049, 3081397, 3042763, 2778068, 2774632, 2724887, 2724496, 520470, 203406, 201470, 195138, 189938, 181978, 167260, 166937, 135805, 124886, 121939, 114660, 114369, 82741, 76219, 73341, 68206, 68166, 61973, 61513, 60825, 55182, 32326, 31374, 30971, 27447, 15906, 13818, 13263, 13214, 11881, 11873, 9033, 8976, 7924, 7729, 6613, 6576, 6359, 5963, 5526, 3283, 2284, 743, 604, 172994210, 171935652, 171042179, 171039834, 171039750, 171039749, 171039746, 168475427, 168475401, 166610795, 163304554, 156613702, 154734867, 139207510, 139196723, 139146793, 139146440, 139146221, 139146220, 139146219, 139088614, 139084101, 139083878, 139082720, 139081912, 139075306, 139075096, 139072404, 139071643, 139069577, 139066713, 139066218, 139063806, 139063546, 139062913, 139060883, 139058713, 139058503, 139058434, 139056683, 139056638, 139048910, 139033729, 139033728, 138402176, 138401598, 138401322, 138401055, 138400125, 138399685, 138397825, 138397783, 138397611, 138397224, 138397057, 137187247, 136241691, 136229439, 136122645, 135886617, 135445674, 135398561, 132285236, 131731354, 131731353, 131731352, 131731351, 131731350, 131728556, 131728554, 131698630, 131667309, 131664288, 129897181, 129881477, 129880811, 129868755, 129849386, 129744777, 129727911, 129694725, 129680246, 129627113, 118222865, 117065159, 117065139, 101243275, 92131860, 92026690, 92020507, 91977408, 91886173, 91658895, 86750998, 86733818, 86672623, 86672621, 86620079, 86594115, 86289284, 76972264, 76198563, 74087698, 73416432, 71779126, 71720943, 71627109, 71445366, 71445158, 71445157, 71430086, 71426722, 71426146, 71415631, 71414854, 71412953, 71412677, 71407118, 71406294, 71405701, 71405288, 71382174, 71380701, 71379872, 71378969, 71376647, 71376646, 71375341, 71370904, 71367774, 71367319, 71362465, 71361685, 71357094, 71353890, 71350495, 71349395, 71347948, 71347883, 71347820, 71343898, 71342355, 71338653, 71338510, 71328508, 71328506, 71328361, 71328217, 71315147, 71312417, 71311553, 71311418, 71311154, 71311130, 71310924, 71310033, 71309961, 71300854, 70408236, 69883617, 68490823, 67506348, 57377177, 57377071, 57375642, 57375632, 57367720, 57356836, 57349412, 56924507, 56840912, 54772454, 54732208, 53471679, 53471235, 53393441, 53393196, 53393190, 53393136, 53262281, 53216747, 50922182, 46878366, 46739011, 45121920, 45116610, 45074957, 45051793, 45036875, 45036874, 45036871, 45036869, 44717711, 44119088, 44118759, 44118758, 44118546, 44118545, 44118544, 44118540, 44118538, 44118537, 43835013, 42626544, 42609668, 24802213, 24801922, 24213488, 24211900, 23697406, 23693102, 23693098, 23690860, 23690406, 23685788, 23682957, 23678966, 23678863, 23678556, 23676746, 23676745, 23675796, 23674745, 23671663, 23669238, 23667639, 23665651, 23663974, 22873087, 21983433, 21881435, 21554742, 21328163, 21119850, 20518352, 20515418, 20140301, 19431961, 18525844, 17786732, 17749119, 17749111, 17749107, 16641190, 16219420, 16218899, 16218633, 16218417, 16217316, 16213871, 16213315, 16213027, 16212498, 16212487, 16212405, 16212300, 16212010, 16211852, 16211818, 16211734, 16211711, 16211366, 16211205, 13587848, 12297759, 12001831, 11947542, 11102868, 10224595, 9931492, 9571075, 6452394, 6441068, 6419954, 6419877, 5492888, 5463864, 5460516, 5360315, 5339038, 5284472, 5282468, 4738123, 4192170, 3816071, 3084148, 3084067, 3056911, 3034943, 3018355, 2774651, 2760812, 2736543, 2728507, 2724367, 2724118, 2723901, 517409, 443311, 441347, 433294, 237332, 212237, 209843, 201899, 189830, 179546, 167547, 167271, 165453, 138835, 119950, 116255, 116253, 115329, 111260, 106027, 102175, 83166, 82029, 81318, 78763, 74483, 71474, 67822, 67636, 67539, 66289, 64640, 64639, 62406, 61298, 61198, 60837, 47964, 46536, 46400, 43362, 34090, 29131, 24477, 24327, 22856, 19999, 19463, 16698, 15413, 14802, 11427, 11009, 9555, 9532, 8779, 8777, 8530, 7879, 7301, 6450, 6342, 6191, 5967, 5904, 5818, 4510, 1176, 729, 679, 176489889, 176489876, 176489874, 176489868, 176489837, 176489822, 172642516, 171379185, 171379184, 171379183, 171379182, 171379177, 171371356, 171039902, 171039900, 171039899, 171039886, 171039872, 171039871, 171039869, 171039868, 171039857, 171039855, 171039854, 171039851, 171039849, 171038643, 169452270, 168475400, 168354115, 168339163, 168337877, 168337299, 168326334, 168310278, 168310270, 168310229, 168310190, 168310089, 168309961, 168309865, 168309708, 168309360, 168308323, 168308154, 168308040, 168307984, 166625107, 165437648, 165363580, 165360295, 165360293, 165360291, 164887196, 164186538, 162623634, 155818441, 154735074, 154735055, 154735025, 154734826, 154734824, 154734822, 154734818, 139207400, 139207315, 139206983, 139197872, 139179102, 139179100, 139177518, 139177250, 139164523, 139141325, 139139137, 139130964, 139129599, 139120761, 139107536, 139105598, 139088368, 139086390, 139085676, 139084807, 139084629, 139083698, 139083582, 139082073, 139081829, 139081513, 139081495, 139080793, 139080095, 139079863, 139078844, 139078769, 139078704, 139078638, 139078331, 139077907, 139077739, 139077246, 139076923, 139076734, 139076334, 139075878, 139075649, 139075004, 139073931, 139073575, 139071029, 139070016, 139069403, 139069213, 139068399, 139067418, 139067061, 139065674, 139065475, 139063758, 139063441, 139063388, 139063380, 139062327, 139062248, 139062073, 139062006, 139061945, 139061786, 139061738, 139061394, 139061392, 139060997, 139060978, 139060332, 139060043, 139059896, 139058649, 139058349, 139057980, 139056981, 139056296, 139055790, 139055499, 139055304, 139054122, 139052392, 139039134, 139036446, 139036433, 139036432, 138402844, 138402627, 138402410, 138402347, 138402331, 138402300, 138401868, 138401638, 138401331, 138401238, 138400436, 138400378, 138400274, 138400253, 138400065, 138400043, 138399702, 138399617, 138398919, 138398790, 138398742, 138398686, 138398685, 138398422, 138398296, 138398211, 138398176, 138398134, 138398120, 138397975, 138397974, 138397829, 138397818, 138397817, 138397684, 138397643, 138397573, 138397572, 138397571, 138397535, 138397529, 138397367, 138397366, 138397314, 138397313, 138396938, 138396884, 138396848, 138396842, 138396774, 138396484, 138395372, 138395368, 138395353, 138395330, 138394691, 137192644, 137185115, 137177177, 137176385, 136250560, 136250511, 136242243, 136234167, 136234109, 135930273, 135885222, 135818271, 135818266, 135616735, 135580441, 135554549, 135502779, 135465063, 135453973, 135442965, 135442940, 135442939, 135414247, 135413545, 135398631, 134812837, 132989253, 132988638, 132984093, 131746452, 131746450, 131746449, 131746448, 131732655, 131731338, 131731337, 131728557, 131728555, 131728553, 131675392, 131664344, 129851818, 129822616, 129787239, 129776229, 127255860, 124204198, 123531720, 118937461, 117065090, 101646889, 101322218, 92043346, 92020504, 91997812, 91666359, 87137604, 86733819, 86725199, 86672600, 86672599, 86649874, 86604311, 86587427, 78382078, 76973075, 76419482, 75596255, 74765096, 74765009, 74330641, 74330637, 73981517, 73555603, 73307871, 72720472, 72720463, 71750920, 71607443, 71587575, 71576652, 71464075, 71463910, 71445949, 71445922, 71445588, 71445370, 71445365, 71445342, 71445298, 71445212, 71444754, 71433852, 71433770, 71433724, 71433667, 71426411, 71425553, 71423309, 71422343, 71422080, 71416779, 71416777, 71416700, 71413561, 71413553, 71412975, 71407147, 71407124, 71405638, 71405557, 71398908, 71394016, 71391161, 71375253, 71372282, 71372240, 71370505, 71368159, 71367302, 71363384, 71363353, 71362766, 71359979, 71359484, 71350738, 71350737, 71349404, 71348764, 71347645, 71347433, 71347144, 71336608, 71330746, 71330677, 71330380, 71328962, 71328147, 71320744, 71317104, 71315423, 71313430, 71312327, 71312243, 71312020, 71311904, 71311610, 71311562, 71311519, 71311288, 71310494, 71310082, 71308803, 71308758, 71308592, 71308499, 71306904, 71301240, 71301095, 71300741, 70679123, 70551960, 69609073, 67660249, 66916532, 66834029, 66822438, 66754998, 57370623, 57370339, 57357928, 57351055, 57349622, 57347183, 57347049, 56927674, 56845822, 56845531, 56843867, 56843846, 56843238, 56842474, 56842468, 56842185, 56841742, 56841623, 56763849, 54729367, 54710414, 54691414, 54684461, 54682502, 53488072, 53472088, 53471170, 53395982, 53297473, 53249332, 52915299, 51003678, 50908997, 50851128, 49822621, 49767006, 46891799, 46891797, 46783812, 46174101, 45933813, 45933790, 45377724, 45357325, 45051996, 45040562, 45036872, 44890780, 44658139, 44181989, 44154839, 44154493, 44151346, 44150415, 44149404, 44149287, 44148373, 44146398, 44140551, 44134828, 44134821, 44134710, 44134593, 44119580, 44119429, 44119425, 44119333, 44119319, 44118679, 44118590, 42627692, 25210512, 25150812, 25021605, 24997615, 24892837, 24847524, 24846132, 24845819, 24845765, 24845285, 24844530, 24844528, 24844514, 24844470, 24844469, 24844361, 24843592, 24843497, 24843302, 24843201, 24842746, 24842243, 24842122, 24840422, 24839160, 24839159, 24837897, 24837894, 24837711, 24837386, 24835601, 24835600, 24834689, 24834466, 24820762, 23724987, 23724982, 23724916, 23724874, 23723057, 23711569, 23706211, 23704959, 23695925, 23694213, 23693103, 23690067, 23687546, 23681927, 23681919, 23679067, 23678596, 23677974, 23677940, 23676756, 23676754, 23675786, 23663991, 22836308, 22141944, 21118760, 21114962, 20057212, 20055600, 19903139, 19083738, 18528807, 18528118, 18525908, 18525746, 18503821, 18446095, 18431527, 18392195, 17750287, 17684448, 17040190, 16760670, 16738693, 16722143, 16721171, 16682940, 16219941, 16219655, 16219408, 16219290, 16219263, 16218964, 16218586, 16218555, 16218487, 16218422, 16218238, 16217736, 16217324, 16217231, 16216929, 16216922, 16213111, 16213101, 16212504, 16212490, 16212468, 16212459, 16212433, 16212415, 16212392, 16212308, 16212147, 16212116, 16211916, 16211832, 16211831, 16211752, 16211736, 16211647, 16211287, 16211271, 16211255, 16211242, 16211168, 16088020, 16007393, 15806548, 15404302, 14664348, 13131683, 12998343, 12498036, 12302905, 12198046, 11971530, 11956149, 11954316, 11954233, 11653565, 11564683, 10479418, 9930448, 9826324, 9825634, 9804991, 9568637, 6918323, 6918313, 6918111, 6918047, 6917719, 6536864, 6452309, 6448182, 6431863, 6419976, 6410532, 6303773, 6099081, 6018215, 5712259, 5466536, 5462348, 5379057, 5360112, 5282518, 5282366, 5282317, 5270518, 5270485, 5125273, 4068533, 3085135, 3084061, 3083139, 3083000, 3081828, 3081569, 3076801, 3076668, 3062696, 3060700, 3060206, 3057649, 3057347, 3057151, 3056947, 3056691, 3056687, 3056685, 3056492, 3056404, 3056345, 3052977, 3052711, 3048887, 3048886, 3048880, 3048661, 3048498, 3048303, 3048301, 3048254, 3048220, 3047780, 3047648, 3047522, 3047520, 3047518, 3045015, 3038424, 3036661, 3036165, 3034468, 3033221, 3033217, 3025285, 3016044, 3015711, 2776662, 2776190, 2764096, 2737188, 2735208, 2724330, 2724232, 2723844, 656609, 644083, 636377, 549976, 516951, 493570, 459910, 459871, 445639, 216231, 208845, 204630, 204107, 201714, 201632, 201397, 200600, 197856, 196062, 195090, 195089, 192413, 192262, 191649, 191587, 190009, 188910, 185476, 185132, 183809, 183604, 178572, 177922, 173612, 170374, 168379, 159356, 159292, 159218, 158189, 157433, 156922, 156665, 156363, 155375, 155071, 154264, 151114, 149521, 148277, 146493, 138321, 134497, 134284, 132844, 132314, 131410, 122128, 120228, 119688, 116517, 116283, 116128, 116070, 116064, 116019, 115955, 115771, 115769, 115765, 115761, 115427, 115397, 114481, 114351, 114349, 114328, 114114, 114113, 114111, 114107, 113954, 113952, 113817, 113813, 113807, 113805, 113761, 113759, 113712, 113708, 113706, 112916, 110835, 110750, 106428, 102285, 93859, 92938, 91442, 85941, 85128, 81133, 73246, 71997, 71476, 71177, 70208, 67803, 66321, 65476, 64770, 64768, 64765, 64648, 64474, 64453, 63738, 63208, 62998, 62979, 62933, 62884, 61421, 59125, 57042, 57019, 56960, 56329, 54759, 53655, 51038, 48816, 47868, 47162, 42830, 42561, 39862, 38101, 33544, 31953, 31927, 31926, 31924, 31922, 31918, 31916, 31275, 23476, 22475, 22420, 21784, 18387, 17141, 16697, 16673, 14806, 14710, 11807, 11205, 10112, 9693, 9528, 8308, 7387, 6328, 6202, 5994, 3414, 3305, 313, 261] cid found for the CAS number 8000-78-0: [6850738] comprehensive search results for the CAS number 8000-78-0: {'query': '8000-78-0', 'name_type': 'word', 'compound_domain': {'cids': [], 'success': False, 'error': 'Internal server error'}, 'substance_domain': {'cids': [6850738], 'success': True, 'error': None}, 'total_unique_cids': [6850738], 'recommended_domain': 'substance'} first 5 sids found for the CAS number 8000-78-0: [442031951, 445479966, 446464370, 479884108, 480557704]
pc.find_cids_comprehensive('8000-78-0')
{'query': '8000-78-0', 'name_type': 'word', 'compound_domain': {'cids': [], 'success': False, 'error': 'Resource not found'}, 'substance_domain': {'cids': [6850738], 'success': True, 'error': None}, 'total_unique_cids': [6850738], 'recommended_domain': 'substance'}
One of the main use cases for me was to look up a compound by its CAS number and if nothing is found look up a substance by the same CAS number, especially for those that are not found in CAS Common Registry.
Synonyms and specific IDs¶
After finding the cid
using "one" identifier, we can obtain a list of synonyms (e.g. chemical name, CAS number, etc.) and also extract certain identifiers from the list:
synonyms = pc.get_compound_synonyms(cids_aspirin[0])
ids = pc.get_compound_identifiers(cids_aspirin[0])
print(synonyms[:5])
print(ids)
['aspirin', 'ACETYLSALICYLIC ACID', '50-78-2', '2-Acetoxybenzoic acid', '2-(Acetyloxy)benzoic acid'] {'success': True, 'cid': 2244, 'error': None, 'total_synonyms': 692, 'casrn': ['50-78-2', '001-16-2', '001-17-0', '001-18-8', '11126-35-5'], 'nsc': ['NSC406186', 'NSC27223', 'NSC755899'], 'dtxsid': ['DTXSID5020108'], 'dtxcid': ['DTXCID50108'], 'ec_number': [], 'chebi_id': ['CHEBI:15365'], 'chembl': ['CHEMBL25']}
Compound property¶
After obtaining the cid
of a compound, we can obtain compound properties by calling one of the following functions, that can give basic, selected, or all available properties.
res_basic = pc.get_basic_compound_info(cids_aspirin[0])
# Pretty print the result
print(json.dumps(res_basic, indent=2))
{ "CID": 2244, "MolecularFormula": "C9H8O4", "MolecularWeight": "180.16", "SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "InChI": "InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)", "InChIKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N", "IUPACName": "2-acetyloxybenzoic acid", "success": true, "cid": 2244, "error": null }
res_selected = pc.get_compound_properties(cids_aspirin[0],
[CompoundProperties.SMILES,
CompoundProperties.INCHI,
CompoundProperties.INCHIKEY],
include_synonyms=False)
print(json.dumps(res_selected, indent=2))
{ "CID": 2244, "SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "InChI": "InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)", "InChIKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N", "success": true, "cid": 2244, "error": null }
res_all = pc.get_all_compound_info(cids_aspirin[0])
print(json.dumps(res_all, indent=2))
{ "CID": 2244, "MolecularFormula": "C9H8O4", "MolecularWeight": "180.16", "SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "ConnectivitySMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "InChI": "InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)", "InChIKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N", "IUPACName": "2-acetyloxybenzoic acid", "XLogP": 1.2, "ExactMass": "180.04225873", "MonoisotopicMass": "180.04225873", "TPSA": 63.6, "Complexity": 212, "Charge": 0, "HBondDonorCount": 1, "HBondAcceptorCount": 4, "RotatableBondCount": 3, "HeavyAtomCount": 13, "IsotopeAtomCount": 0, "AtomStereoCount": 0, "DefinedAtomStereoCount": 0, "UndefinedAtomStereoCount": 0, "BondStereoCount": 0, "DefinedBondStereoCount": 0, "UndefinedBondStereoCount": 0, "CovalentUnitCount": 1, "Volume3D": 136, "XStericQuadrupole3D": 3.86, "YStericQuadrupole3D": 2.45, "ZStericQuadrupole3D": 0.89, "FeatureCount3D": 5, "FeatureAcceptorCount3D": 3, "FeatureDonorCount3D": 0, "FeatureAnionCount3D": 1, "FeatureCationCount3D": 0, "FeatureRingCount3D": 1, "FeatureHydrophobeCount3D": 0, "ConformerModelRMSD3D": 0.6, "EffectiveRotorCount3D": 3, "ConformerCount3D": 10, "Fingerprint2D": "AAADccBwOAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAABAAAAGgAACAAADASAmAAyDoAABgCIAiDSCAACCAAkIAAIiAEGCMgMJzaENRqCe2Cl4BEIuYeIyCCOAAAAAAAIAAAAAAAAABAAAAAAAAAAAA==", "Title": "Aspirin", "PatentCount": 101562, "PatentFamilyCount": 45279, "LiteratureCount": 138993, "AnnotationTypes": "Biological Test Results: Active|Biological Test Results: Micromolar|Biological Test Results: Nanomolar|Associated Disorders and Diseases|Biological Test Results|Chemical and Physical Properties|Classification|Drug and Medication Information|Identification|Interactions and Pathways|Literature|Patents|Pharmacology and Biochemistry|Safety and Hazards|Spectral Information|Taxonomy|Toxicity", "AnnotationTypeCount": 17, "SourceCategories": "Chemical Vendors|Curation Efforts|Governmental Organizations|Journal Publishers|Legacy Depositors|NIH Initiatives|Research and Development|Subscription Services", "success": true, "cid": 2244, "error": null }
Substance properties¶
The substance properties can be found by providing a sid
to the
sids = pc.get_sids_by_name("garlic oil")
res = pc.get_substance_by_sid(sids[1])
res
{'sid': {'id': 479884108, 'version': 1}, 'source': {'db': {'name': '21014', 'source_id': {'str': 'AA01FZ9M'}}}, 'synonyms': ['Garlic Oil', '8000-78-0'], 'xref': [{'rn': '8000-78-0'}, {'dburl': 'https://www.aablocks.com'}, {'sburl': 'https://www.aablocks.com/prod/8000-78-0'}, {'regid': 'AA01FZ9M'}], 'compound': [{'id': {'type': 0}, 'atoms': {'aid': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], 'element': [6, 6, 6, 16, 16, 6, 6, 6, 6, 6, 6, 16, 16, 16, 6, 6, 6, 6, 6, 6, 16, 16, 8, 6, 6, 6]}, 'bonds': {'aid1': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 22, 24, 25], 'aid2': [2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26], 'order': [1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2]}, 'coords': [{'type': [1, 3], 'aid': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], 'conformers': [{'x': [0, 1.3856, 2.7713, 4.1569, 5.5426, 6.9282, 8.3138, 9.6995, 12.8995, 14.2851, 15.6708, 17.0564, 18.442, 19.8277, 21.2133, 22.599, 23.9846, 0, 1.3856, 2.7713, 4.1569, 5.5426, 5.5426, 6.9282, 8.3138, 9.6995], 'y': [0, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0, 5.6, 6.4, 5.6, 6.4, 5.6, 4, 6.4, 5.6, 6.4]}]}], 'charge': 0}, {'id': {'type': 1, 'id': {'cid': 6850738}}}, {'id': {'type': 2, 'id': {'cid': 16315}}}, {'id': {'type': 2, 'id': {'cid': 16591}}}, {'id': {'type': 2, 'id': {'cid': 65036}}}]}
PubChem View¶
from provesid import PubChemView, get_property_table
logp_table = get_property_table(cids_aspirin[0], "LogP")
logp_table
CID | StringWithMarkup | ExperimentalValue | Unit | Temperature | Conditions | FullReference | |
---|---|---|---|---|---|---|---|
0 | 2244 | None | None | None | None | DrugBank | Acetylsalicylic acid | The DrugBank... | |
1 | 2244 | log Kow = 1.19 | 1.19 | None | None | None | Hazardous Substances Data Bank (HSDB) | ACETYL... |
2 | 2244 | 1.19 | 1.19 | None | None | None | Human Metabolome Database (HMDB) | Aspirin | T... |
3 | 2244 | 1.19 | 1.19 | None | None | None | ILO-WHO International Chemical Safety Cards (I... |
pcv = PubChemView()
res_logP = pcv.get_property_summary(cids_aspirin[0], "LogP")
print(json.dumps(res_logP, indent=2))
{ "property": "LogP", "values": [ "", "log Kow = 1.19", "1.19", "1.19" ], "references": [ "https://www.fip.org/files/fip/BPS/BCS/Monographs/AcetylsalicylicAcid.pdf", "Hansch, C., Leo, A., D. Hoekman. Exploring QSAR - Hydrophobic, Electronic, and Steric Constants. Washington, DC: American Chemical Society., 1995., p. 54", "HANSCH,C ET AL. (1995)" ], "units": [], "conditions": [], "count": 4 }
Advanced PubChem API Features¶
The PubChem API has been improved to provide more elegant data access. Previously, methods like get_substance_by_sid()
and get_compound_by_cid()
returned data wrapped in redundant structures requiring access like result["PC_Substances"][0]
or result["PC_Compounds"][0]
. Now these methods automatically extract the relevant data for easier access.
Batch Processing and Multiple Compounds¶
Let's explore how to work with multiple compounds and batch processing:
# Batch processing for multiple compounds
compound_names = ["aspirin", "caffeine", "acetaminophen", "ibuprofen"]
all_cids = []
for name in compound_names:
cids = pc.get_cids_by_name(name)
if cids:
all_cids.append(cids[0]) # Take the first CID for each compound
print(f"{name}: CID {cids[0]}")
print(f"\nCollected CIDs: {all_cids}")
# Batch property retrieval
properties = [CompoundProperties.MOLECULAR_WEIGHT,
CompoundProperties.MOLECULAR_FORMULA,
CompoundProperties.SMILES]
batch_results = pc.get_compound_properties_batch(all_cids, properties)
print("\nBatch property results:")
print(json.dumps(batch_results, indent=2))
aspirin: CID 2244 caffeine: CID 9871508 caffeine: CID 9871508 acetaminophen: CID 1983 acetaminophen: CID 1983 ibuprofen: CID 24848049 Collected CIDs: [2244, 9871508, 1983, 24848049] ibuprofen: CID 24848049 Collected CIDs: [2244, 9871508, 1983, 24848049] Batch property results: [ { "CID": 2244, "MolecularFormula": "C9H8O4", "MolecularWeight": "180.16", "SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "success": true, "cid": 2244, "error": null }, { "CID": 9871508, "MolecularFormula": "C25H27N5O8", "MolecularWeight": "525.5", "SMILES": "CC(=O)NC1=CC=C(C=C1)O.CC(=O)OC1=CC=CC=C1C(=O)O.CN1C=NC2=C1C(=O)N(C(=O)N2C)C", "success": true, "cid": 9871508, "error": null }, { "CID": 1983, "MolecularFormula": "C8H9NO2", "MolecularWeight": "151.16", "SMILES": "CC(=O)NC1=CC=C(C=C1)O", "success": true, "cid": 1983, "error": null }, { "CID": 24848049, "MolecularFormula": "C36H47NO10", "MolecularWeight": "653.8", "SMILES": "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O.CN(C)CCOC(C1=CC=CC=C1)C2=CC=CC=C2.C(C(=O)O)C(CC(=O)O)(C(=O)O)O", "success": true, "cid": 24848049, "error": null } ] Batch property results: [ { "CID": 2244, "MolecularFormula": "C9H8O4", "MolecularWeight": "180.16", "SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O", "success": true, "cid": 2244, "error": null }, { "CID": 9871508, "MolecularFormula": "C25H27N5O8", "MolecularWeight": "525.5", "SMILES": "CC(=O)NC1=CC=C(C=C1)O.CC(=O)OC1=CC=CC=C1C(=O)O.CN1C=NC2=C1C(=O)N(C(=O)N2C)C", "success": true, "cid": 9871508, "error": null }, { "CID": 1983, "MolecularFormula": "C8H9NO2", "MolecularWeight": "151.16", "SMILES": "CC(=O)NC1=CC=C(C=C1)O", "success": true, "cid": 1983, "error": null }, { "CID": 24848049, "MolecularFormula": "C36H47NO10", "MolecularWeight": "653.8", "SMILES": "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O.CN(C)CCOC(C1=CC=CC=C1)C2=CC=CC=C2.C(C(=O)O)C(CC(=O)O)(C(=O)O)O", "success": true, "cid": 24848049, "error": null } ]
Chemical Structure Searching¶
PubChem API supports searching by various chemical identifiers including SMILES and InChI keys. Both get_cids_by_smiles()
and get_cids_by_inchikey()
methods return clean lists of CIDs, and the corresponding get_compounds_by_*()
methods return the compound data directly without wrapper structures:
# Search by SMILES string (caffeine)
caffeine_smiles = "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"
cids_by_smiles = pc.get_cids_by_smiles(caffeine_smiles)
print(f"CIDs found by SMILES: {cids_by_smiles}")
# Get compound record by SMILES (new improved method - no wrapper needed!)
compound_by_smiles = pc.get_compounds_by_smiles(caffeine_smiles)
print(f"Compound data type: {type(compound_by_smiles)}")
if isinstance(compound_by_smiles, dict):
print(f"Direct access to compound keys: {list(compound_by_smiles.keys())}")
# Search by InChI Key
inchikey = "RYYVLZVUVIJVGH-UHFFFAOYSA-N" # caffeine InChI key
cids_by_inchikey = pc.get_cids_by_inchikey(inchikey)
print(f"CIDs found by InChI Key: {cids_by_inchikey}")
# Get compound record by InChI Key (new improved method)
compound_by_inchikey = pc.get_compounds_by_inchikey(inchikey)
print(f"Compound by InChI Key - type: {type(compound_by_inchikey)}")
CIDs found by SMILES: [2519] Compound data type: <class 'dict'> Direct access to compound keys: ['id', 'atoms', 'bonds', 'coords', 'charge', 'props', 'count'] Compound data type: <class 'dict'> Direct access to compound keys: ['id', 'atoms', 'bonds', 'coords', 'charge', 'props', 'count'] CIDs found by InChI Key: [2519] CIDs found by InChI Key: [2519] Compound by InChI Key - type: <class 'dict'> Compound by InChI Key - type: <class 'dict'>
Comprehensive PubChem View Tutorial¶
PubChemView provides access to experimental properties that are not available through the standard PubChem API. These include physical and chemical properties like melting point, boiling point, solubility, vapor pressure, and many others.
Available Experimental Properties¶
Let's first explore what experimental properties are available for a compound:
# Check what experimental properties are available for aspirin
available_props = pcv.get_available_properties(cids_aspirin[0])
print(f"Available experimental properties for aspirin ({len(available_props)} total):")
for prop in available_props:
print(f" - {prop}")
# Show the standard experimental properties mapping
print(f"\nTotal standard experimental properties supported: {len(pcv.experimental_properties)}")
print("Some examples:")
for i, (key, value) in enumerate(list(pcv.experimental_properties.items())[:10]):
print(f" {key} -> {value}")
print(" ...")
Available experimental properties for aspirin (16 total): - Physical Description - Color/Form - Odor - Boiling Point - Melting Point - Flash Point - Solubility - Density - Vapor Pressure - LogP - Stability/Shelf Life - Decomposition - Dissociation Constants - Collision Cross Section - Kovats Retention Index - Other Experimental Properties Total standard experimental properties supported: 44 Some examples: Accelerating Rate Calorimetry (ARC) -> Accelerating+Rate+Calorimetry+(ARC) Acid Value -> Acid+Value Autoignition Temperature -> Autoignition+Temperature Boiling Point -> Boiling+Point Caco2 Permeability -> Caco2+Permeability Collision Cross Section -> Collision+Cross+Section Color/Form -> Color/Form Corrosivity -> Corrosivity Decomposition -> Decomposition Density -> Density ...
Common Physical Properties¶
Let's extract some common physical and chemical properties using the convenience methods:
# Melting Point
melting_point = pcv.get_melting_point(cids_aspirin[0])
print("Melting Point data:")
for i, mp in enumerate(melting_point[:3]): # Show first 3 entries
print(f" {i+1}: {mp.value} (Ref: {mp.reference_number})")
# Boiling Point
boiling_point = pcv.get_boiling_point(cids_aspirin[0])
print(f"\nBoiling Point data ({len(boiling_point)} entries):")
for i, bp in enumerate(boiling_point[:2]):
print(f" {i+1}: {bp.value}")
# Solubility
solubility = pcv.get_solubility(cids_aspirin[0])
print(f"\nSolubility data ({len(solubility)} entries):")
for i, sol in enumerate(solubility[:3]):
print(f" {i+1}: {sol.value}")
# Density
density = pcv.get_density(cids_aspirin[0])
print(f"\nDensity data ({len(density)} entries):")
for i, dens in enumerate(density[:2]):
print(f" {i+1}: {dens.value}")
Melting Point data: 1: 275 °F (NTP, 1992) (Ref: 7) 2: 138-140 (Ref: 35) 3: 135 °C (rapid heating) (Ref: 60) Boiling Point data (4 entries): 1: 284 °F at 760 mmHg (decomposes) (NTP, 1992) 2: Boiling Point data (4 entries): 1: 284 °F at 760 mmHg (decomposes) (NTP, 1992) 2: Solubility data (6 entries): 1: less than 1 mg/mL at 73 °F (NTP, 1992) 2: 3: 1 g sol in: 300 mL water at 25 °C, 100 mL water at 37 °C, 5 mL alcohol, 17 mL chloroform, 10-15 mL ether; less sol in anhydrous ether Solubility data (6 entries): 1: less than 1 mg/mL at 73 °F (NTP, 1992) 2: 3: 1 g sol in: 300 mL water at 25 °C, 100 mL water at 37 °C, 5 mL alcohol, 17 mL chloroform, 10-15 mL ether; less sol in anhydrous ether Density data (5 entries): 1: 1.4 (NTP, 1992) - Denser than water; will sink 2: 1.40 Density data (5 entries): 1: 1.4 (NTP, 1992) - Denser than water; will sink 2: 1.40
Note that the experimental data are not reported homogeneously and therefore it becomes difficult to come up with a single method to extract values, units, and experimental conditions from the reported data that are always in string
format. We will gradually improve this feature by adding more formats to our regex
code as we encounted them.
Property Tables with Full References¶
The get_property_table()
function provides comprehensive property data in a pandas DataFrame format with full reference information and parsed experimental values:
# Get comprehensive LogP data with references
logp_table = get_property_table(cids_aspirin[0], "LogP")
print("LogP Property Table:")
print(logp_table)
print(f"\nColumns: {list(logp_table.columns)}")
# Show some specific data
if len(logp_table) > 0:
print(f"\nExample extracted values:")
for i, row in logp_table.iterrows():
if row['ExperimentalValue'] is not None:
print(f" Original: '{row['StringWithMarkup']}'")
print(f" Extracted: {row['ExperimentalValue']} {row['Unit'] if row['Unit'] else '(unitless)'}")
break
LogP Property Table: CID StringWithMarkup ExperimentalValue Unit Temperature Conditions \ 0 2244 None None None None 1 2244 log Kow = 1.19 1.19 None None None 2 2244 1.19 1.19 None None None 3 2244 1.19 1.19 None None None FullReference 0 DrugBank | Acetylsalicylic acid | The DrugBank... 1 Hazardous Substances Data Bank (HSDB) | ACETYL... 2 Human Metabolome Database (HMDB) | Aspirin | T... 3 ILO-WHO International Chemical Safety Cards (I... Columns: ['CID', 'StringWithMarkup', 'ExperimentalValue', 'Unit', 'Temperature', 'Conditions', 'FullReference'] Example extracted values: Original: 'log Kow = 1.19' Extracted: 1.19 (unitless)
# Compare different properties for aspirin
properties_to_check = ["Vapor Pressure", "Melting Point", "Boiling Point", "Solubility"]
for prop in properties_to_check:
table = get_property_table(cids_aspirin[0], prop)
if len(table) > 0:
valid_values = table[table['ExperimentalValue'].notna()]
print(f"{prop}: {len(valid_values)} experimental values extracted from {len(table)} total entries")
if len(valid_values) > 0:
# Show one example
example = valid_values.iloc[0]
print(f" Example: {example['ExperimentalValue']} {example['Unit'] if example['Unit'] else ''}")
else:
print(f"{prop}: No data available")
print()
Vapor Pressure: 4 experimental values extracted from 5 total entries Example: 0 mmHg Melting Point: 5 experimental values extracted from 7 total entries Example: 275 °F Melting Point: 5 experimental values extracted from 7 total entries Example: 275 °F Boiling Point: 3 experimental values extracted from 4 total entries Example: 284 °F Boiling Point: 3 experimental values extracted from 4 total entries Example: 284 °F Solubility: 1 experimental values extracted from 6 total entries Example: 1 mg/mL Solubility: 1 experimental values extracted from 6 total entries Example: 1 mg/mL
Advanced Pattern Recognition¶
PubChemView includes sophisticated pattern recognition for extracting experimental values from various text formats. The recent improvements include support for formats like "log Kow = 1.19" for LogP data:
# Demonstrate the improved LogP pattern recognition
logp_data = pcv.extract_property_data(cids_aspirin[0], "LogP")
print("LogP pattern recognition examples:")
for i, data in enumerate(logp_data):
if data.value: # Only show non-empty values
# Test the extraction function directly
exp_value, unit, temp, cond = pcv._extract_experimental_value_and_unit(data.value, "LogP")
print(f" {i+1}: '{data.value}' -> {exp_value} {unit if unit else '(unitless)'}")
# Test with a compound that has vapor pressure data
caffeine_cid = pc.get_cids_by_name("caffeine")[0]
vp_data = pcv.extract_property_data(caffeine_cid, "Vapor Pressure")
print(f"\nVapor Pressure pattern recognition examples (CID {caffeine_cid}):")
for i, data in enumerate(vp_data[:3]): # Show first 3
if data.value:
exp_value, unit, temp, cond = pcv._extract_experimental_value_and_unit(data.value, "Vapor Pressure")
print(f" {i+1}: '{data.value}' -> {exp_value} {unit if unit else 'no unit'}")
LogP pattern recognition examples: 2: 'log Kow = 1.19' -> 1.19 (unitless) 3: '1.19' -> 1.19 (unitless) 4: '1.19' -> 1.19 (unitless)
Property 'Vapor Pressure' not found for CID 9871508
Vapor Pressure pattern recognition examples (CID 9871508):
Batch Property Extraction¶
For multiple compounds, you can extract properties in batch:
# Batch extraction for multiple properties of aspirin
target_properties = ["LogP", "Melting Point", "Boiling Point", "Solubility", "Vapor Pressure"]
batch_results = pcv.batch_extract_properties(cids_aspirin[0], target_properties)
print("Batch extraction results for aspirin:")
for prop_name, prop_data in batch_results.items():
print(f"\n{prop_name}: {len(prop_data)} entries")
if prop_data:
# Show first non-empty value
for data in prop_data:
if data.value and data.value.strip():
print(f" Example: {data.value}")
break
# Extract all experimental properties for a compound
print(f"\n" + "="*50)
print("ALL EXPERIMENTAL PROPERTIES")
print("="*50)
all_properties = pcv.extract_all_experimental_properties(cids_aspirin[0])
print(f"Total experimental property categories found: {len(all_properties)}")
for prop_name, data_list in list(all_properties.items())[:5]: # Show first 5
print(f"{prop_name}: {len(data_list)} entries")
Batch extraction results for aspirin: LogP: 4 entries Example: log Kow = 1.19 Melting Point: 7 entries Example: 275 °F (NTP, 1992) Boiling Point: 4 entries Example: 284 °F at 760 mmHg (decomposes) (NTP, 1992) Solubility: 6 entries Example: less than 1 mg/mL at 73 °F (NTP, 1992) Vapor Pressure: 5 entries Example: 0 mmHg (approx) (NIOSH, 2024) ================================================== ALL EXPERIMENTAL PROPERTIES ================================================== Total experimental property categories found: 16 Physical Description: 6 entries Color/Form: 2 entries Odor: 2 entries Boiling Point: 4 entries Melting Point: 7 entries Total experimental property categories found: 16 Physical Description: 6 entries Color/Form: 2 entries Odor: 2 entries Boiling Point: 4 entries Melting Point: 7 entries
import pandas as pd
# Example: Build a small database of pharmaceutical compounds
pharma_compounds = {
"aspirin": 2244,
"ibuprofen": 3672,
"acetaminophen": 1983,
"caffeine": 2519
}
# Create a comprehensive database
database_records = []
for name, cid in pharma_compounds.items():
print(f"Processing {name} (CID: {cid})...")
# Get basic compound info
basic_info = pc.get_basic_compound_info(cid)
# Get experimental properties
logp_table = get_property_table(cid, "LogP")
mp_table = get_property_table(cid, "Melting Point")
sol_table = get_property_table(cid, "Solubility")
# Extract first valid experimental value for each property
logp_exp = logp_table[logp_table['ExperimentalValue'].notna()]['ExperimentalValue'].iloc[0] if len(logp_table[logp_table['ExperimentalValue'].notna()]) > 0 else None
mp_exp = mp_table[mp_table['ExperimentalValue'].notna()]['ExperimentalValue'].iloc[0] if len(mp_table[mp_table['ExperimentalValue'].notna()]) > 0 else None
sol_count = len(sol_table[sol_table['ExperimentalValue'].notna()])
record = {
'name': name,
'cid': cid,
'molecular_formula': basic_info.get('MolecularFormula'),
'molecular_weight': basic_info.get('MolecularWeight'),
'smiles': basic_info.get('CanonicalSMILES'),
'logp_experimental': logp_exp,
'melting_point_experimental': mp_exp,
'solubility_data_points': sol_count
}
database_records.append(record)
# Create DataFrame
pharma_db = pd.DataFrame(database_records)
print("\nPharmaceutical Compounds Database:")
print(pharma_db.to_string(index=False))
Processing aspirin (CID: 2244)... Processing ibuprofen (CID: 3672)... Processing ibuprofen (CID: 3672)... Processing acetaminophen (CID: 1983)... Processing acetaminophen (CID: 1983)... Processing caffeine (CID: 2519)... Processing caffeine (CID: 2519)... Pharmaceutical Compounds Database: name cid molecular_formula molecular_weight smiles logp_experimental melting_point_experimental solubility_data_points aspirin 2244 C9H8O4 180.16 None 1.19 275 1 ibuprofen 3672 C13H18O2 206.28 None 3.97 75-77 1 acetaminophen 1983 C8H9NO2 151.16 None 0.46 168 2 caffeine 2519 C8H10N4O2 194.19 None -0.07 460 2 Pharmaceutical Compounds Database: name cid molecular_formula molecular_weight smiles logp_experimental melting_point_experimental solubility_data_points aspirin 2244 C9H8O4 180.16 None 1.19 275 1 ibuprofen 3672 C13H18O2 206.28 None 3.97 75-77 1 acetaminophen 1983 C8H9NO2 151.16 None 0.46 168 2 caffeine 2519 C8H10N4O2 194.19 None -0.07 460 2
Error Handling and Best Practices¶
When working with PubChem APIs, it's important to handle errors gracefully:
from provesid import PubChemNotFoundError, PubChemError, PubChemViewNotFoundError
# Example of robust compound lookup
def safe_compound_lookup(identifier, search_type="name"):
"""Safely look up a compound with error handling"""
try:
if search_type == "name":
cids = pc.get_cids_by_name(identifier)
elif search_type == "smiles":
cids = pc.get_cids_by_smiles(identifier)
else:
raise ValueError(f"Unsupported search type: {search_type}")
if not cids:
print(f"No compounds found for '{identifier}'")
return None
print(f"Found {len(cids)} compound(s) for '{identifier}': {cids[:5]}...") # Show first 5
return cids[0] # Return first CID
except PubChemNotFoundError:
print(f"Compound '{identifier}' not found in PubChem")
return None
except PubChemError as e:
print(f"PubChem API error: {e}")
return None
except Exception as e:
print(f"Unexpected error: {e}")
return None
# Test with various inputs
test_compounds = [
("aspirin", "name"),
("invalid_compound_name_xyz", "name"),
("CC(=O)OC1=CC=CC=C1C(=O)O", "smiles"), # aspirin SMILES
("invalid_smiles", "smiles")
]
for compound, search_type in test_compounds:
print(f"\nTesting: {compound} (search type: {search_type})")
cid = safe_compound_lookup(compound, search_type)
if cid:
print(f" Success! CID: {cid}")
# Safe property extraction
def safe_property_extraction(cid, property_name):
"""Safely extract property data with error handling"""
try:
data = pcv.extract_property_data(cid, property_name)
return data
except PubChemViewNotFoundError:
print(f"Property '{property_name}' not found for CID {cid}")
return []
except Exception as e:
print(f"Error extracting {property_name} for CID {cid}: {e}")
return []
print(f"\n" + "="*40)
print("Safe property extraction example:")
logp_safe = safe_property_extraction(cids_aspirin[0], "LogP")
print(f"LogP data extracted safely: {len(logp_safe)} entries")
Testing: aspirin (search type: name) Found 130 compound(s) for 'aspirin': [2244, 1983, 9871508, 56842252, 145904]... Success! CID: 2244 Testing: invalid_compound_name_xyz (search type: name) Found 130 compound(s) for 'aspirin': [2244, 1983, 9871508, 56842252, 145904]... Success! CID: 2244 Testing: invalid_compound_name_xyz (search type: name) Unexpected error: Resource not found Testing: CC(=O)OC1=CC=CC=C1C(=O)O (search type: smiles) Unexpected error: Resource not found Testing: CC(=O)OC1=CC=CC=C1C(=O)O (search type: smiles) Found 1 compound(s) for 'CC(=O)OC1=CC=CC=C1C(=O)O': [2244]... Success! CID: 2244 Testing: invalid_smiles (search type: smiles) Found 1 compound(s) for 'CC(=O)OC1=CC=CC=C1C(=O)O': [2244]... Success! CID: 2244 Testing: invalid_smiles (search type: smiles) Unexpected error: Bad request: { "Fault": { "Code": "PUGREST.BadRequest", "Message": "Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?", "Details": [ "error: ", "status: 400", "output: Caught ncbi::CException: Standardization failed", "Output Log:", "Record 1: Warning: Cactvs Ensemble cannot be created from input string", "Record 1: Error: Unable to convert input into a compound object", "", "" ] } } ======================================== Safe property extraction example: Unexpected error: Bad request: { "Fault": { "Code": "PUGREST.BadRequest", "Message": "Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?", "Details": [ "error: ", "status: 400", "output: Caught ncbi::CException: Standardization failed", "Output Log:", "Record 1: Warning: Cactvs Ensemble cannot be created from input string", "Record 1: Error: Unable to convert input into a compound object", "", "" ] } } ======================================== Safe property extraction example: LogP data extracted safely: 4 entries LogP data extracted safely: 4 entries
Summary¶
This tutorial covered the comprehensive functionality of both PubChem APIs in the PROVESID package:
PubChemAPI (Standard API)¶
- Improved Data Access: Methods like
get_compound_by_cid()
andget_substance_by_sid()
now return data directly without redundant wrapper structures - Multiple Search Methods: Search by name, SMILES, InChI key, CAS number
- Comprehensive ID Resolution: Find CIDs across both compound and substance domains
- Batch Processing: Handle multiple compounds efficiently
- Property Extraction: Get basic, selected, or all compound properties
PubChemView (Experimental Properties API)¶
- Experimental Properties: Access to 40+ experimental properties not available in the standard API
- Advanced Pattern Recognition: Sophisticated text parsing for extracting numerical values from diverse formats
- Property Tables: Comprehensive DataFrames with full reference information
- Batch Extraction: Extract multiple properties for compounds efficiently
- Temperature and Conditions: Automatic extraction of experimental conditions
Key Improvements¶
- Elegant Data Access: No more
["PC_Compounds"][0]
or["PC_Substances"][0]
needed - Enhanced LogP Recognition: Now supports "log Kow = 1.19" and similar formats
- Robust Error Handling: Proper exception handling for network and data issues
- Comprehensive Pattern Support: Handles scientific notation, comparison operators, and diverse units
Best Practices¶
- Always use error handling for production code
- Use batch methods for multiple compounds
- Check data availability before processing
- Respect PubChem's rate limits (built into the APIs)
The PROVESID package provides a powerful and user-friendly interface to PubChem's vast chemical database, making it easy to integrate chemical data into your research workflows.