[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7360DJNSTZXZFGCP4VCWZAM":3,"skill-same:01M7360DJNSTZXZFGCP4VCWZAM":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7360DJNSTZXZFGCP4VCWZAM","alterlab-pubchem",null,"Query PubChem via PUG-REST API\u002FPubChemPy (110M+ compounds). Search by name\u002FCID\u002FSMILES, retrieve properties, similarity\u002Fsubstructure searches, bioactivity, for cheminformatics. Part of the AlterLab Academic Skills suite.","roohe\u002Fagentic-super-skills","roohe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99054084?v=4","01M734WCDFP6RZVT5CNM00QR26","01M734WCE4BD0T4NZS5PCV9V5F",10,"MIT","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Falterlab-pubchem\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: alterlab-pubchem\ndescription: Query PubChem via PUG-REST API\u002FPubChemPy (110M+ compounds). Search by name\u002FCID\u002FSMILES, retrieve properties, similarity\u002Fsubstructure searches, bioactivity, for cheminformatics. Part of the AlterLab Academic Skills suite.\nlicense: MIT\nmetadata:\n    skill-author: AlterLab\n    version: \"1.0.0\"\n---\n\n# PubChem Database\n\n## Overview\n\nPubChem is the world's largest freely available chemical database with 110M+ compounds and 270M+ bioactivities. Query chemical structures by name, CID, or SMILES, retrieve molecular properties, perform similarity and substructure searches, access bioactivity data using PUG-REST API and PubChemPy.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Searching for chemical compounds by name, structure (SMILES\u002FInChI), or molecular formula\n- Retrieving molecular properties (MW, LogP, TPSA, hydrogen bonding descriptors)\n- Performing similarity searches to find structurally related compounds\n- Conducting substructure searches for specific chemical motifs\n- Accessing bioactivity data from screening assays\n- Converting between chemical identifier formats (CID, SMILES, InChI)\n- Batch processing multiple compounds for drug-likeness screening or property analysis\n\n## Core Capabilities\n\n### 1. Chemical Structure Search\n\nSearch for compounds using multiple identifier types:\n\n**By Chemical Name**:\n```python\nimport pubchempy as pcp\ncompounds = pcp.get_compounds('aspirin', 'name')\ncompound = compounds[0]\n```\n\n**By CID (Compound ID)**:\n```python\ncompound = pcp.Compound.from_cid(2244)  # Aspirin\n```\n\n**By SMILES**:\n```python\ncompound = pcp.get_compounds('CC(=O)OC1=CC=CC=C1C(=O)O', 'smiles')[0]\n```\n\n**By InChI**:\n```python\ncompound = pcp.get_compounds('InChI=1S\u002FC9H8O4\u002F...', 'inchi')[0]\n```\n\n**By Molecular Formula**:\n```python\ncompounds = pcp.get_compounds('C9H8O4', 'formula')\n# Returns all compounds matching this formula\n```\n\n### 2. Property Retrieval\n\nRetrieve molecular properties for compounds using either high-level or low-level approaches:\n\n**Using PubChemPy (Recommended)**:\n```python\nimport pubchempy as pcp\n\n# Get compound object with all properties\ncompound = pcp.get_compounds('caffeine', 'name')[0]\n\n# Access individual properties\nmolecular_formula = compound.molecular_formula\nmolecular_weight = compound.molecular_weight\niupac_name = compound.iupac_name\nsmiles = compound.canonical_smiles\ninchi = compound.inchi\nxlogp = compound.xlogp  # Partition coefficient\ntpsa = compound.tpsa    # Topological polar surface area\n```\n\n**Get Specific Properties**:\n```python\n# Request only specific properties\nproperties = pcp.get_properties(\n    ['MolecularFormula', 'MolecularWeight', 'CanonicalSMILES', 'XLogP'],\n    'aspirin',\n    'name'\n)\n# Returns list of dictionaries\n```\n\n**Batch Property Retrieval**:\n```python\nimport pandas as pd\n\ncompound_names = ['aspirin', 'ibuprofen', 'paracetamol']\nall_properties = []\n\nfor name in compound_names:\n    props = pcp.get_properties(\n        ['MolecularFormula', 'MolecularWeight', 'XLogP'],\n        name,\n        'name'\n    )\n    all_properties.extend(props)\n\ndf = pd.DataFrame(all_properties)\n```\n\n**Available Properties**: MolecularFormula, MolecularWeight, CanonicalSMILES, IsomericSMILES, InChI, InChIKey, IUPACName, XLogP, TPSA, HBondDonorCount, HBondAcceptorCount, RotatableBondCount, Complexity, Charge, and many more (see `references\u002Fapi_reference.md` for complete list).\n\n### 3. Similarity Search\n\nFind structurally similar compounds using Tanimoto similarity:\n\n```python\nimport pubchempy as pcp\n\n# Start with a query compound\nquery_compound = pcp.get_compounds('gefitinib', 'name')[0]\nquery_smiles = query_compound.canonical_smiles\n\n# Perform similarity search\nsimilar_compounds = pcp.get_compounds(\n    query_smiles,\n    'smiles',\n    searchtype='similarity',\n    Threshold=85,  # Similarity threshold (0-100)\n    MaxRecords=50\n)\n\n# Process results\nfor compound in similar_compounds[:10]:\n    print(f\"CID {compound.cid}: {compound.iupac_name}\")\n    print(f\"  MW: {compound.molecular_weight}\")\n```\n\n**Note**: Similarity searches are asynchronous for large queries and may take 15-30 seconds to complete. PubChemPy handles the asynchronous pattern automatically.\n\n### 4. Substructure Search\n\nFind compounds containing a specific structural motif:\n\n```python\nimport pubchempy as pcp\n\n# Search for compounds containing pyridine ring\npyridine_smiles = 'c1ccncc1'\n\nmatches = pcp.get_compounds(\n    pyridine_smiles,\n    'smiles',\n    searchtype='substructure',\n    MaxRecords=100\n)\n\nprint(f\"Found {len(matches)} compounds containing pyridine\")\n```\n\n**Common Substructures**:\n- Benzene ring: `c1ccccc1`\n- Pyridine: `c1ccncc1`\n- Phenol: `c1ccc(O)cc1`\n- Carboxylic acid: `C(=O)O`\n\n### 5. Format Conversion\n\nConvert between different chemical structure formats:\n\n```python\nimport pubchempy as pcp\n\ncompound = pcp.get_compounds('aspirin', 'name')[0]\n\n# Convert to different formats\nsmiles = compound.canonical_smiles\ninchi = compound.inchi\ninchikey = compound.inchikey\ncid = compound.cid\n\n# Download structure files\npcp.download('SDF', 'aspirin', 'name', 'aspirin.sdf', overwrite=True)\npcp.download('JSON', '2244', 'cid', 'aspirin.json', overwrite=True)\n```\n\n### 6. Structure Visualization\n\nGenerate 2D structure images:\n\n```python\nimport pubchempy as pcp\n\n# Download compound structure as PNG\npcp.download('PNG', 'caffeine', 'name', 'caffeine.png', overwrite=True)\n\n# Using direct URL (via requests)\nimport requests\n\ncid = 2244  # Aspirin\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\"\nresponse = requests.get(url)\n\nwith open('structure.png', 'wb') as f:\n    f.write(response.content)\n```\n\n### 7. Synonym Retrieval\n\nGet all known names and synonyms for a compound:\n\n```python\nimport pubchempy as pcp\n\nsynonyms_data = pcp.get_synonyms('aspirin', 'name')\n\nif synonyms_data:\n    cid = synonyms_data[0]['CID']\n    synonyms = synonyms_data[0]['Synonym']\n\n    print(f\"CID {cid} has {len(synonyms)} synonyms:\")\n    for syn in synonyms[:10]:  # First 10\n        print(f\"  - {syn}\")\n```\n\n### 8. Bioactivity Data Access\n\nRetrieve biological activity data from assays:\n\n```python\nimport requests\nimport json\n\n# Get bioassay summary for a compound\ncid = 2244  # Aspirin\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON\"\n\nresponse = requests.get(url)\nif response.status_code == 200:\n    data = response.json()\n    # Process bioassay information\n    table = data.get('Table', {})\n    rows = table.get('Row', [])\n    print(f\"Found {len(rows)} bioassay records\")\n```\n\n**For more complex bioactivity queries**, use the `scripts\u002Fbioactivity_query.py` helper script which provides:\n- Bioassay summaries with activity outcome filtering\n- Assay target identification\n- Search for compounds by biological target\n- Active compound lists for specific assays\n\n### 9. Comprehensive Compound Annotations\n\nAccess detailed compound information through PUG-View:\n\n```python\nimport requests\n\ncid = 2244\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug_view\u002Fdata\u002Fcompound\u002F{cid}\u002FJSON\"\n\nresponse = requests.get(url)\nif response.status_code == 200:\n    annotations = response.json()\n    # Contains extensive data including:\n    # - Chemical and Physical Properties\n    # - Drug and Medication Information\n    # - Pharmacology and Biochemistry\n    # - Safety and Hazards\n    # - Toxicity\n    # - Literature references\n    # - Patents\n```\n\n**Get Specific Section**:\n```python\n# Get only drug information\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug_view\u002Fdata\u002Fcompound\u002F{cid}\u002FJSON?heading=Drug and Medication Information\"\n```\n\n## Installation Requirements\n\nInstall PubChemPy for Python-based access:\n\n```bash\nuv pip install pubchempy\n```\n\nFor direct API access and bioactivity queries:\n\n```bash\nuv pip install requests\n```\n\nOptional for data analysis:\n\n```bash\nuv pip install pandas\n```\n\n## Helper Scripts\n\nThis skill includes Python scripts for common PubChem tasks:\n\n### scripts\u002Fcompound_search.py\n\nProvides utility functions for searching and retrieving compound information:\n\n**Key Functions**:\n- `search_by_name(name, max_results=10)`: Search compounds by name\n- `search_by_smiles(smiles)`: Search by SMILES string\n- `get_compound_by_cid(cid)`: Retrieve compound by CID\n- `get_compound_properties(identifier, namespace, properties)`: Get specific properties\n- `similarity_search(smiles, threshold, max_records)`: Perform similarity search\n- `substructure_search(smiles, max_records)`: Perform substructure search\n- `get_synonyms(identifier, namespace)`: Get all synonyms\n- `batch_search(identifiers, namespace, properties)`: Batch search multiple compounds\n- `download_structure(identifier, namespace, format, filename)`: Download structures\n- `print_compound_info(compound)`: Print formatted compound information\n\n**Usage**:\n```python\nfrom scripts.compound_search import search_by_name, get_compound_properties\n\n# Search for a compound\ncompounds = search_by_name('ibuprofen')\n\n# Get specific properties\nprops = get_compound_properties('aspirin', 'name', ['MolecularWeight', 'XLogP'])\n```\n\n### scripts\u002Fbioactivity_query.py\n\nProvides functions for retrieving biological activity data:\n\n**Key Functions**:\n- `get_bioassay_summary(cid)`: Get bioassay summary for compound\n- `get_compound_bioactivities(cid, activity_outcome)`: Get filtered bioactivities\n- `get_assay_description(aid)`: Get detailed assay information\n- `get_assay_targets(aid)`: Get biological targets for assay\n- `search_assays_by_target(target_name, max_results)`: Find assays by target\n- `get_active_compounds_in_assay(aid, max_results)`: Get active compounds\n- `get_compound_annotations(cid, section)`: Get PUG-View annotations\n- `summarize_bioactivities(cid)`: Generate bioactivity summary statistics\n- `find_compounds_by_bioactivity(target, threshold, max_compounds)`: Find compounds by target\n\n**Usage**:\n```python\nfrom scripts.bioactivity_query import get_bioassay_summary, summarize_bioactivities\n\n# Get bioactivity summary\nsummary = summarize_bioactivities(2244)  # Aspirin\nprint(f\"Total assays: {summary['total_assays']}\")\nprint(f\"Active: {summary['active']}, Inactive: {summary['inactive']}\")\n```\n\n## API Rate Limits and Best Practices\n\n**Rate Limits**:\n- Maximum 5 requests per second\n- Maximum 400 requests per minute\n- Maximum 300 seconds running time per minute\n\n**Best Practices**:\n1. **Use CIDs for repeated queries**: CIDs are more efficient than names or structures\n2. **Cache results locally**: Store frequently accessed data\n3. **Batch requests**: Combine multiple queries when possible\n4. **Implement delays**: Add 0.2-0.3 second delays between requests\n5. **Handle errors gracefully**: Check for HTTP errors and missing data\n6. **Use PubChemPy**: Higher-level abstraction handles many edge cases\n7. **Leverage asynchronous pattern**: For large similarity\u002Fsubstructure searches\n8. **Specify MaxRecords**: Limit results to avoid timeouts\n\n**Error Handling**:\n```python\nfrom pubchempy import BadRequestError, NotFoundError, TimeoutError\n\ntry:\n    compound = pcp.get_compounds('query', 'name')[0]\nexcept NotFoundError:\n    print(\"Compound not found\")\nexcept BadRequestError:\n    print(\"Invalid request format\")\nexcept TimeoutError:\n    print(\"Request timed out - try reducing scope\")\nexcept IndexError:\n    print(\"No results returned\")\n```\n\n## Common Workflows\n\n### Workflow 1: Chemical Identifier Conversion Pipeline\n\nConvert between different chemical identifiers:\n\n```python\nimport pubchempy as pcp\n\n# Start with any identifier type\ncompound = pcp.get_compounds('caffeine', 'name')[0]\n\n# Extract all identifier formats\nidentifiers = {\n    'CID': compound.cid,\n    'Name': compound.iupac_name,\n    'SMILES': compound.canonical_smiles,\n    'InChI': compound.inchi,\n    'InChIKey': compound.inchikey,\n    'Formula': compound.molecular_formula\n}\n```\n\n### Workflow 2: Drug-Like Property Screening\n\nScreen compounds using Lipinski's Rule of Five:\n\n```python\nimport pubchempy as pcp\n\ndef check_drug_likeness(compound_name):\n    compound = pcp.get_compounds(compound_name, 'name')[0]\n\n    # Lipinski's Rule of Five\n    rules = {\n        'MW \u003C= 500': compound.molecular_weight \u003C= 500,\n        'LogP \u003C= 5': compound.xlogp \u003C= 5 if compound.xlogp else None,\n        'HBD \u003C= 5': compound.h_bond_donor_count \u003C= 5,\n        'HBA \u003C= 10': compound.h_bond_acceptor_count \u003C= 10\n    }\n\n    violations = sum(1 for v in rules.values() if v is False)\n    return rules, violations\n\nrules, violations = check_drug_likeness('aspirin')\nprint(f\"Lipinski violations: {violations}\")\n```\n\n### Workflow 3: Finding Similar Drug Candidates\n\nIdentify structurally similar compounds to a known drug:\n\n```python\nimport pubchempy as pcp\n\n# Start with known drug\nreference_drug = pcp.get_compounds('imatinib', 'name')[0]\nreference_smiles = reference_drug.canonical_smiles\n\n# Find similar compounds\nsimilar = pcp.get_compounds(\n    reference_smiles,\n    'smiles',\n    searchtype='similarity',\n    Threshold=85,\n    MaxRecords=20\n)\n\n# Filter by drug-like properties\ncandidates = []\nfor comp in similar:\n    if comp.molecular_weight and 200 \u003C= comp.molecular_weight \u003C= 600:\n        if comp.xlogp and -1 \u003C= comp.xlogp \u003C= 5:\n            candidates.append(comp)\n\nprint(f\"Found {len(candidates)} drug-like candidates\")\n```\n\n### Workflow 4: Batch Compound Property Comparison\n\nCompare properties across multiple compounds:\n\n```python\nimport pubchempy as pcp\nimport pandas as pd\n\ncompound_list = ['aspirin', 'ibuprofen', 'naproxen', 'celecoxib']\n\nproperties_list = []\nfor name in compound_list:\n    try:\n        compound = pcp.get_compounds(name, 'name')[0]\n        properties_list.append({\n            'Name': name,\n            'CID': compound.cid,\n            'Formula': compound.molecular_formula,\n            'MW': compound.molecular_weight,\n            'LogP': compound.xlogp,\n            'TPSA': compound.tpsa,\n            'HBD': compound.h_bond_donor_count,\n            'HBA': compound.h_bond_acceptor_count\n        })\n    except Exception as e:\n        print(f\"Error processing {name}: {e}\")\n\ndf = pd.DataFrame(properties_list)\nprint(df.to_string(index=False))\n```\n\n### Workflow 5: Substructure-Based Virtual Screening\n\nScreen for compounds containing specific pharmacophores:\n\n```python\nimport pubchempy as pcp\n\n# Define pharmacophore (e.g., sulfonamide group)\npharmacophore_smiles = 'S(=O)(=O)N'\n\n# Search for compounds containing this substructure\nhits = pcp.get_compounds(\n    pharmacophore_smiles,\n    'smiles',\n    searchtype='substructure',\n    MaxRecords=100\n)\n\n# Further filter by properties\nfiltered_hits = [\n    comp for comp in hits\n    if comp.molecular_weight and comp.molecular_weight \u003C 500\n]\n\nprint(f\"Found {len(filtered_hits)} compounds with desired substructure\")\n```\n\n## Reference Documentation\n\nFor detailed API documentation, including complete property lists, URL patterns, advanced query options, and more examples, consult `references\u002Fapi_reference.md`. This comprehensive reference includes:\n\n- Complete PUG-REST API endpoint documentation\n- Full list of available molecular properties\n- Asynchronous request handling patterns\n- PubChemPy API reference\n- PUG-View API for annotations\n- Common workflows and use cases\n- Links to official PubChem documentation\n\n## Troubleshooting\n\n**Compound Not Found**:\n- Try alternative names or synonyms\n- Use CID if known\n- Check spelling and chemical name format\n\n**Timeout Errors**:\n- Reduce MaxRecords parameter\n- Add delays between requests\n- Use CIDs instead of names for faster queries\n\n**Empty Property Values**:\n- Not all properties are available for all compounds\n- Check if property exists before accessing: `if compound.xlogp:`\n- Some properties only available for certain compound types\n\n**Rate Limit Exceeded**:\n- Implement delays (0.2-0.3 seconds) between requests\n- Use batch operations where possible\n- Consider caching results locally\n\n**Similarity\u002FSubstructure Search Hangs**:\n- These are asynchronous operations that may take 15-30 seconds\n- PubChemPy handles polling automatically\n- Reduce MaxRecords if timing out\n\n## Additional Resources\n\n- PubChem Home: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002F\n- PUG-REST Documentation: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest\n- PUG-REST Tutorial: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest-tutorial\n- PubChemPy Documentation: https:\u002F\u002Fpubchempy.readthedocs.io\u002F\n- PubChemPy GitHub: https:\u002F\u002Fgithub.com\u002Fmcs07\u002FPubChemPy\n\n","# PubChem Database\n\n## Overview\n\nPubChem is the world's largest freely available chemical database with 110M+ compounds and 270M+ bioactivities. Query chemical structures by name, CID, or SMILES, retrieve molecular properties, perform similarity and substructure searches, access bioactivity data using PUG-REST API and PubChemPy.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Searching for chemical compounds by name, structure (SMILES\u002FInChI), or molecular formula\n- Retrieving molecular properties (MW, LogP, TPSA, hydrogen bonding descriptors)\n- Performing similarity searches to find structurally related compounds\n- Conducting substructure searches for specific chemical motifs\n- Accessing bioactivity data from screening assays\n- Converting between chemical identifier formats (CID, SMILES, InChI)\n- Batch processing multiple compounds for drug-likeness screening or property analysis\n\n## Core Capabilities\n\n### 1. Chemical Structure Search\n\nSearch for compounds using multiple identifier types:\n\n**By Chemical Name**:\n```python\nimport pubchempy as pcp\ncompounds = pcp.get_compounds('aspirin', 'name')\ncompound = compounds[0]\n```\n\n**By CID (Compound ID)**:\n```python\ncompound = pcp.Compound.from_cid(2244)  # Aspirin\n```\n\n**By SMILES**:\n```python\ncompound = pcp.get_compounds('CC(=O)OC1=CC=CC=C1C(=O)O', 'smiles')[0]\n```\n\n**By InChI**:\n```python\ncompound = pcp.get_compounds('InChI=1S\u002FC9H8O4\u002F...', 'inchi')[0]\n```\n\n**By Molecular Formula**:\n```python\ncompounds = pcp.get_compounds('C9H8O4', 'formula')\n# Returns all compounds matching this formula\n```\n\n### 2. Property Retrieval\n\nRetrieve molecular properties for compounds using either high-level or low-level approaches:\n\n**Using PubChemPy (Recommended)**:\n```python\nimport pubchempy as pcp\n\n# Get compound object with all properties\ncompound = pcp.get_compounds('caffeine', 'name')[0]\n\n# Access individual properties\nmolecular_formula = compound.molecular_formula\nmolecular_weight = compound.molecular_weight\niupac_name = compound.iupac_name\nsmiles = compound.canonical_smiles\ninchi = compound.inchi\nxlogp = compound.xlogp  # Partition coefficient\ntpsa = compound.tpsa    # Topological polar surface area\n```\n\n**Get Specific Properties**:\n```python\n# Request only specific properties\nproperties = pcp.get_properties(\n    ['MolecularFormula', 'MolecularWeight', 'CanonicalSMILES', 'XLogP'],\n    'aspirin',\n    'name'\n)\n# Returns list of dictionaries\n```\n\n**Batch Property Retrieval**:\n```python\nimport pandas as pd\n\ncompound_names = ['aspirin', 'ibuprofen', 'paracetamol']\nall_properties = []\n\nfor name in compound_names:\n    props = pcp.get_properties(\n        ['MolecularFormula', 'MolecularWeight', 'XLogP'],\n        name,\n        'name'\n    )\n    all_properties.extend(props)\n\ndf = pd.DataFrame(all_properties)\n```\n\n**Available Properties**: MolecularFormula, MolecularWeight, CanonicalSMILES, IsomericSMILES, InChI, InChIKey, IUPACName, XLogP, TPSA, HBondDonorCount, HBondAcceptorCount, RotatableBondCount, Complexity, Charge, and many more (see `references\u002Fapi_reference.md` for complete list).\n\n### 3. Similarity Search\n\nFind structurally similar compounds using Tanimoto similarity:\n\n```python\nimport pubchempy as pcp\n\n# Start with a query compound\nquery_compound = pcp.get_compounds('gefitinib', 'name')[0]\nquery_smiles = query_compound.canonical_smiles\n\n# Perform similarity search\nsimilar_compounds = pcp.get_compounds(\n    query_smiles,\n    'smiles',\n    searchtype='similarity',\n    Threshold=85,  # Similarity threshold (0-100)\n    MaxRecords=50\n)\n\n# Process results\nfor compound in similar_compounds[:10]:\n    print(f\"CID {compound.cid}: {compound.iupac_name}\")\n    print(f\"  MW: {compound.molecular_weight}\")\n```\n\n**Note**: Similarity searches are asynchronous for large queries and may take 15-30 seconds to complete. PubChemPy handles the asynchronous pattern automatically.\n\n### 4. Substructure Search\n\nFind compounds containing a specific structural motif:\n\n```python\nimport pubchempy as pcp\n\n# Search for compounds containing pyridine ring\npyridine_smiles = 'c1ccncc1'\n\nmatches = pcp.get_compounds(\n    pyridine_smiles,\n    'smiles',\n    searchtype='substructure',\n    MaxRecords=100\n)\n\nprint(f\"Found {len(matches)} compounds containing pyridine\")\n```\n\n**Common Substructures**:\n- Benzene ring: `c1ccccc1`\n- Pyridine: `c1ccncc1`\n- Phenol: `c1ccc(O)cc1`\n- Carboxylic acid: `C(=O)O`\n\n### 5. Format Conversion\n\nConvert between different chemical structure formats:\n\n```python\nimport pubchempy as pcp\n\ncompound = pcp.get_compounds('aspirin', 'name')[0]\n\n# Convert to different formats\nsmiles = compound.canonical_smiles\ninchi = compound.inchi\ninchikey = compound.inchikey\ncid = compound.cid\n\n# Download structure files\npcp.download('SDF', 'aspirin', 'name', 'aspirin.sdf', overwrite=True)\npcp.download('JSON', '2244', 'cid', 'aspirin.json', overwrite=True)\n```\n\n### 6. Structure Visualization\n\nGenerate 2D structure images:\n\n```python\nimport pubchempy as pcp\n\n# Download compound structure as PNG\npcp.download('PNG', 'caffeine', 'name', 'caffeine.png', overwrite=True)\n\n# Using direct URL (via requests)\nimport requests\n\ncid = 2244  # Aspirin\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\"\nresponse = requests.get(url)\n\nwith open('structure.png', 'wb') as f:\n    f.write(response.content)\n```\n\n### 7. Synonym Retrieval\n\nGet all known names and synonyms for a compound:\n\n```python\nimport pubchempy as pcp\n\nsynonyms_data = pcp.get_synonyms('aspirin', 'name')\n\nif synonyms_data:\n    cid = synonyms_data[0]['CID']\n    synonyms = synonyms_data[0]['Synonym']\n\n    print(f\"CID {cid} has {len(synonyms)} synonyms:\")\n    for syn in synonyms[:10]:  # First 10\n        print(f\"  - {syn}\")\n```\n\n### 8. Bioactivity Data Access\n\nRetrieve biological activity data from assays:\n\n```python\nimport requests\nimport json\n\n# Get bioassay summary for a compound\ncid = 2244  # Aspirin\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON\"\n\nresponse = requests.get(url)\nif response.status_code == 200:\n    data = response.json()\n    # Process bioassay information\n    table = data.get('Table', {})\n    rows = table.get('Row', [])\n    print(f\"Found {len(rows)} bioassay records\")\n```\n\n**For more complex bioactivity queries**, use the `scripts\u002Fbioactivity_query.py` helper script which provides:\n- Bioassay summaries with activity outcome filtering\n- Assay target identification\n- Search for compounds by biological target\n- Active compound lists for specific assays\n\n### 9. Comprehensive Compound Annotations\n\nAccess detailed compound information through PUG-View:\n\n```python\nimport requests\n\ncid = 2244\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug_view\u002Fdata\u002Fcompound\u002F{cid}\u002FJSON\"\n\nresponse = requests.get(url)\nif response.status_code == 200:\n    annotations = response.json()\n    # Contains extensive data including:\n    # - Chemical and Physical Properties\n    # - Drug and Medication Information\n    # - Pharmacology and Biochemistry\n    # - Safety and Hazards\n    # - Toxicity\n    # - Literature references\n    # - Patents\n```\n\n**Get Specific Section**:\n```python\n# Get only drug information\nurl = f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug_view\u002Fdata\u002Fcompound\u002F{cid}\u002FJSON?heading=Drug and Medication Information\"\n```\n\n## Installation Requirements\n\nInstall PubChemPy for Python-based access:\n\n```bash\nuv pip install pubchempy\n```\n\nFor direct API access and bioactivity queries:\n\n```bash\nuv pip install requests\n```\n\nOptional for data analysis:\n\n```bash\nuv pip install pandas\n```\n\n## Helper Scripts\n\nThis skill includes Python scripts for common PubChem tasks:\n\n### scripts\u002Fcompound_search.py\n\nProvides utility functions for searching and retrieving compound information:\n\n**Key Functions**:\n- `search_by_name(name, max_results=10)`: Search compounds by name\n- `search_by_smiles(smiles)`: Search by SMILES string\n- `get_compound_by_cid(cid)`: Retrieve compound by CID\n- `get_compound_properties(identifier, namespace, properties)`: Get specific properties\n- `similarity_search(smiles, threshold, max_records)`: Perform similarity search\n- `substructure_search(smiles, max_records)`: Perform substructure search\n- `get_synonyms(identifier, namespace)`: Get all synonyms\n- `batch_search(identifiers, namespace, properties)`: Batch search multiple compounds\n- `download_structure(identifier, namespace, format, filename)`: Download structures\n- `print_compound_info(compound)`: Print formatted compound information\n\n**Usage**:\n```python\nfrom scripts.compound_search import search_by_name, get_compound_properties\n\n# Search for a compound\ncompounds = search_by_name('ibuprofen')\n\n# Get specific properties\nprops = get_compound_properties('aspirin', 'name', ['MolecularWeight', 'XLogP'])\n```\n\n### scripts\u002Fbioactivity_query.py\n\nProvides functions for retrieving biological activity data:\n\n**Key Functions**:\n- `get_bioassay_summary(cid)`: Get bioassay summary for compound\n- `get_compound_bioactivities(cid, activity_outcome)`: Get filtered bioactivities\n- `get_assay_description(aid)`: Get detailed assay information\n- `get_assay_targets(aid)`: Get biological targets for assay\n- `search_assays_by_target(target_name, max_results)`: Find assays by target\n- `get_active_compounds_in_assay(aid, max_results)`: Get active compounds\n- `get_compound_annotations(cid, section)`: Get PUG-View annotations\n- `summarize_bioactivities(cid)`: Generate bioactivity summary statistics\n- `find_compounds_by_bioactivity(target, threshold, max_compounds)`: Find compounds by target\n\n**Usage**:\n```python\nfrom scripts.bioactivity_query import get_bioassay_summary, summarize_bioactivities\n\n# Get bioactivity summary\nsummary = summarize_bioactivities(2244)  # Aspirin\nprint(f\"Total assays: {summary['total_assays']}\")\nprint(f\"Active: {summary['active']}, Inactive: {summary['inactive']}\")\n```\n\n## API Rate Limits and Best Practices\n\n**Rate Limits**:\n- Maximum 5 requests per second\n- Maximum 400 requests per minute\n- Maximum 300 seconds running time per minute\n\n**Best Practices**:\n1. **Use CIDs for repeated queries**: CIDs are more efficient than names or structures\n2. **Cache results locally**: Store frequently accessed data\n3. **Batch requests**: Combine multiple queries when possible\n4. **Implement delays**: Add 0.2-0.3 second delays between requests\n5. **Handle errors gracefully**: Check for HTTP errors and missing data\n6. **Use PubChemPy**: Higher-level abstraction handles many edge cases\n7. **Leverage asynchronous pattern**: For large similarity\u002Fsubstructure searches\n8. **Specify MaxRecords**: Limit results to avoid timeouts\n\n**Error Handling**:\n```python\nfrom pubchempy import BadRequestError, NotFoundError, TimeoutError\n\ntry:\n    compound = pcp.get_compounds('query', 'name')[0]\nexcept NotFoundError:\n    print(\"Compound not found\")\nexcept BadRequestError:\n    print(\"Invalid request format\")\nexcept TimeoutError:\n    print(\"Request timed out - try reducing scope\")\nexcept IndexError:\n    print(\"No results returned\")\n```\n\n## Common Workflows\n\n### Workflow 1: Chemical Identifier Conversion Pipeline\n\nConvert between different chemical identifiers:\n\n```python\nimport pubchempy as pcp\n\n# Start with any identifier type\ncompound = pcp.get_compounds('caffeine', 'name')[0]\n\n# Extract all identifier formats\nidentifiers = {\n    'CID': compound.cid,\n    'Name': compound.iupac_name,\n    'SMILES': compound.canonical_smiles,\n    'InChI': compound.inchi,\n    'InChIKey': compound.inchikey,\n    'Formula': compound.molecular_formula\n}\n```\n\n### Workflow 2: Drug-Like Property Screening\n\nScreen compounds using Lipinski's Rule of Five:\n\n```python\nimport pubchempy as pcp\n\ndef check_drug_likeness(compound_name):\n    compound = pcp.get_compounds(compound_name, 'name')[0]\n\n    # Lipinski's Rule of Five\n    rules = {\n        'MW \u003C= 500': compound.molecular_weight \u003C= 500,\n        'LogP \u003C= 5': compound.xlogp \u003C= 5 if compound.xlogp else None,\n        'HBD \u003C= 5': compound.h_bond_donor_count \u003C= 5,\n        'HBA \u003C= 10': compound.h_bond_acceptor_count \u003C= 10\n    }\n\n    violations = sum(1 for v in rules.values() if v is False)\n    return rules, violations\n\nrules, violations = check_drug_likeness('aspirin')\nprint(f\"Lipinski violations: {violations}\")\n```\n\n### Workflow 3: Finding Similar Drug Candidates\n\nIdentify structurally similar compounds to a known drug:\n\n```python\nimport pubchempy as pcp\n\n# Start with known drug\nreference_drug = pcp.get_compounds('imatinib', 'name')[0]\nreference_smiles = reference_drug.canonical_smiles\n\n# Find similar compounds\nsimilar = pcp.get_compounds(\n    reference_smiles,\n    'smiles',\n    searchtype='similarity',\n    Threshold=85,\n    MaxRecords=20\n)\n\n# Filter by drug-like properties\ncandidates = []\nfor comp in similar:\n    if comp.molecular_weight and 200 \u003C= comp.molecular_weight \u003C= 600:\n        if comp.xlogp and -1 \u003C= comp.xlogp \u003C= 5:\n            candidates.append(comp)\n\nprint(f\"Found {len(candidates)} drug-like candidates\")\n```\n\n### Workflow 4: Batch Compound Property Comparison\n\nCompare properties across multiple compounds:\n\n```python\nimport pubchempy as pcp\nimport pandas as pd\n\ncompound_list = ['aspirin', 'ibuprofen', 'naproxen', 'celecoxib']\n\nproperties_list = []\nfor name in compound_list:\n    try:\n        compound = pcp.get_compounds(name, 'name')[0]\n        properties_list.append({\n            'Name': name,\n            'CID': compound.cid,\n            'Formula': compound.molecular_formula,\n            'MW': compound.molecular_weight,\n            'LogP': compound.xlogp,\n            'TPSA': compound.tpsa,\n            'HBD': compound.h_bond_donor_count,\n            'HBA': compound.h_bond_acceptor_count\n        })\n    except Exception as e:\n        print(f\"Error processing {name}: {e}\")\n\ndf = pd.DataFrame(properties_list)\nprint(df.to_string(index=False))\n```\n\n### Workflow 5: Substructure-Based Virtual Screening\n\nScreen for compounds containing specific pharmacophores:\n\n```python\nimport pubchempy as pcp\n\n# Define pharmacophore (e.g., sulfonamide group)\npharmacophore_smiles = 'S(=O)(=O)N'\n\n# Search for compounds containing this substructure\nhits = pcp.get_compounds(\n    pharmacophore_smiles,\n    'smiles',\n    searchtype='substructure',\n    MaxRecords=100\n)\n\n# Further filter by properties\nfiltered_hits = [\n    comp for comp in hits\n    if comp.molecular_weight and comp.molecular_weight \u003C 500\n]\n\nprint(f\"Found {len(filtered_hits)} compounds with desired substructure\")\n```\n\n## Reference Documentation\n\nFor detailed API documentation, including complete property lists, URL patterns, advanced query options, and more examples, consult `references\u002Fapi_reference.md`. This comprehensive reference includes:\n\n- Complete PUG-REST API endpoint documentation\n- Full list of available molecular properties\n- Asynchronous request handling patterns\n- PubChemPy API reference\n- PUG-View API for annotations\n- Common workflows and use cases\n- Links to official PubChem documentation\n\n## Troubleshooting\n\n**Compound Not Found**:\n- Try alternative names or synonyms\n- Use CID if known\n- Check spelling and chemical name format\n\n**Timeout Errors**:\n- Reduce MaxRecords parameter\n- Add delays between requests\n- Use CIDs instead of names for faster queries\n\n**Empty Property Values**:\n- Not all properties are available for all compounds\n- Check if property exists before accessing: `if compound.xlogp:`\n- Some properties only available for certain compound types\n\n**Rate Limit Exceeded**:\n- Implement delays (0.2-0.3 seconds) between requests\n- Use batch operations where possible\n- Consider caching results locally\n\n**Similarity\u002FSubstructure Search Hangs**:\n- These are asynchronous operations that may take 15-30 seconds\n- PubChemPy handles polling automatically\n- Reduce MaxRecords if timing out\n\n## Additional Resources\n\n- PubChem Home: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002F\n- PUG-REST Documentation: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest\n- PUG-REST Tutorial: https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest-tutorial\n- PubChemPy Documentation: https:\u002F\u002Fpubchempy.readthedocs.io\u002F\n- PubChemPy GitHub: https:\u002F\u002Fgithub.com\u002Fmcs07\u002FPubChemPy\n\n",{"name":5,"license":14,"metadata":23,"description":7},{"version":24,"skill-author":25},"1.0.0","AlterLab","master","f483e54f3ad5f202a77d45f2e57f8d970b71195f","skills_library\u002Falterlab-pubchem",2,"https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills","https:\u002F\u002Fgithub.com\u002Froohe","yoou.link","2026-05-19 15:56:07",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add roohe\u002Fagentic-super-skills --skill alterlab-pubchem",{"tool":40,"command":41},"bunx","bunx skills add roohe\u002Fagentic-super-skills --skill alterlab-pubchem",{"tool":43,"command":44},"pnpm","pnpm dlx skills add roohe\u002Fagentic-super-skills --skill alterlab-pubchem","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Falterlab-pubchem\u002FSKILL.md",true,[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fapi_reference.md","REFERENCE","参考文档",10731,"https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Falterlab-pubchem\u002Freferences\u002Fapi_reference.md",[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M73D865CZME2FCMKA4PQM348","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":18},"01M73D7Z64J4ABWZJD7P44XBBF","youtube-downloader","Download and process YouTube content for research. Use when: downloading competitor videos for analysis; extracting audio for podcasts; getting transcripts for content repurposing; archiving webinars; research content curation","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M73D7K8778TGZV3GJFR3703D","yc-pitch-deck","Create a compelling startup pitch deck that follows the structure proven to raise billions from top investors. Master the YC and Sequoia formats that get founders funded. Use when: **Fundraising** to create investor pitch decks; **YC application** to structure your narrative; **Demo Day prep** to craft your 2-minute pitch; **Angel investors** to communicate your opportunity; **Partnership pitches** to structure compelling asks","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fyc-pitch-deck\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M73D70KJSE0E8Z28YMNNRT04","x-twitter-scraper","Use when the user needs X (Twitter) data or confirmation-gated X actions through Xquik: tweet search, user lookup, follower extraction, media download, monitoring, webhooks, MCP, SDKs, posting, likes, DMs, and profile updates. Requires a Xquik API key. Never ask for X login material.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fx-twitter-scraper\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M73D6ED01GV077R7K4NZNFZJ","write-vignette","Create R package vignettes using R Markdown or Quarto. Covers vignette setup, YAML configuration, code chunk options, building and testing, and CRAN requirements for vignettes. Use when adding a Getting Started tutorial, documenting complex workflows spanning multiple functions, creating domain-specific guides, or when CRAN submission requires user-facing documentation beyond function help pages.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fwrite-vignette\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M73D69YJR0BK3NFHE0CYG3EF","write-validation-documentation","Write IQ\u002FOQ\u002FPQ validation documentation for computerized systems in regulated environments. Covers protocols, reports, test scripts, deviation handling, and approval workflows. Use when validating R or other software for regulated use, preparing for a regulatory audit, documenting qualification of computing environments, or creating and updating validation protocols and reports for new or re-qualified systems.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fwrite-validation-documentation\u002FSKILL.md",[],[]]