Class PubChem

java.lang.Object
org.episteme.natural.chemistry.loaders.PubChem

public class PubChem extends Object
Connector to PubChem (National Institutes of Health).

What it does: Provides access to chemical data for millions of compounds. Retrieves structures, properties (molecular weight, formula), and identifiers.

Data Source: PubChem PUG REST API (https://pubchem.ncbi.nlm.nih.gov/)

License: Public Domain (US Government work).

Usage example:

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • search

      public static String search(String name)
      Searches for a compound by name and returns full record.
      Parameters:
      name - compound name (e.g., "aspirin", "water")
      Returns:
      JSON response
    • searchCompound

      public static CompoundInfo searchCompound(String name)
      Searches for a compound and returns a parsed CompoundInfo object. This is a convenience method that combines search() with JSON parsing.
      Parameters:
      name - compound name (e.g., "aspirin")
      Returns:
      CompoundInfo with parsed data, or null if not found
    • map

      public static <T> T map(String json, Class<T> target)
      Maps JSON response to a domain object.
      Parameters:
      json - raw JSON from PubChem API
      target - target class (currently supports CompoundInfo.class)
      Returns:
      mapped object or null if mapping not supported
    • getProperties

      public static String getProperties(String name, String properties)
      Retrieves specific properties for a compound.
      Parameters:
      name - compound name
      properties - comma-separated list (e.g., "MolecularFormula,MolecularWeight,InChIKey")
      Returns:
      JSON response