pyrfume.odorants module

Classes for odorants, mixtures, chemical orders, etc.

class pyrfume.odorants.ChemicalOrder(molecule: pyrfume.odorants.Molecule, vendor: pyrfume.odorants.Vendor, part_id: str, purity: float = 1, known_impurities: list = None)[source]

Bases: object

known_impurities = None
molecule = None
part_id = ''
purity = 1
vendor = None
class pyrfume.odorants.Compound(chemical_order: pyrfume.odorants.ChemicalOrder, stock: str = '', date_arrived: datetime.datetime = None, date_opened: datetime.datetime = None, is_solvent: bool = False)[source]

Bases: object

chemical_order = None
date_arrived = None
date_opened = None
is_solvent = False
stock = ''
class pyrfume.odorants.Molecule(cid: int, name: str = None, fill: bool = False)[source]

Bases: object

cas = ''
cid = 0
density = None
fill_details()[source]
get_cid_from_api()[source]
get_name_from_api()[source]
iupac = ''
molar_evaporation_rate
molarity
molecular_weight = None
name = ''
synonyms = ''
vapor_pressure = None
class pyrfume.odorants.Solution(components: dict, date_created: datetime.datetime = None)[source]

Bases: object

components = None
compounds
date_created = None
dilutions
molar_evaporation_rate(molecule)[source]
molar_evaporation_rates
molarities

Returns a dictionary with the molarity of each Molecule

mole_fraction(molecule)[source]
mole_fractions

Returns a dictionary with the mole fraction of each Molecule

molecules

Returns a dictionary with the moles of each Molecule

partial_pressure(molecule)[source]
partial_pressures

Computes partial pressures for each odorant in the mixture using Raoult’s law

total_pressure

Computes total pressure of the vapor using Dalton’s law

vapor_concentration(molecule)[source]
vapor_concentrations

Concentrations of each component in the vapor phase at steady state. Units are fraction of volume. Air is assumed to make up the balance

class pyrfume.odorants.Vendor(name: str, url: str)[source]

Bases: object

name = ''
url = ''
pyrfume.odorants.all_cids()[source]

All CIDs found in the file at ODORANTS_BASIC_INFO_PATH

pyrfume.odorants.all_odorants()[source]

All CIDs, SMILES, Names, and Molecular Weights found in the file at ODORANTS_BASIC_INFO_PATH

pyrfume.odorants.all_smiles()[source]

All SMILES found in the file at ODORANTS_BASIC_INFO_PATH. May contain duplicates (if two CIDs give the same SMILES)

pyrfume.odorants.all_sources()[source]

Whether or not each odorant (by CID) is in each of the data sources

pyrfume.odorants.cactus(identifier: str, output: str = 'cas') → str[source]
pyrfume.odorants.cactus_image(smiles: str) → None[source]
pyrfume.odorants.canonical_smiles(smiles: str, kekulize: bool = False) → str[source]

Use rdkit to convert the smiles string to canonical form

pyrfume.odorants.cas_from_synonyms(synonyms: list) → list[source]
pyrfume.odorants.cids_to_cas(cids: list) → collections.OrderedDict[source]
pyrfume.odorants.cids_to_smiles(cids: list) → dict[source]

Returns an ordered dictionary of SMILES strings with CIDs as keys

pyrfume.odorants.crop_image(img, padding=0)[source]

Crop white out of a PIL image.

pyrfume.odorants.deisomerize_smiles(smiles: str) → str[source]
pyrfume.odorants.display_molecules(molecules: pandas.core.frame.DataFrame, no_of_columns=5, figsize=(15, 15))[source]
pyrfume.odorants.embed_molecules(molecules: pandas.core.frame.DataFrame)[source]
pyrfume.odorants.from_cids(cids: list, property_list: bool = None) → list[source]
pyrfume.odorants.get_cid(identifier: str, kind: str = None, verbose: bool = True, fix_smiles_on_error: bool = True, attempt=0) → int[source]

Return data about a molecule from any synonym, including a chemical name or a CAS. change_kind: Whether to try other kinds if the search fails.

pyrfume.odorants.get_cids(identifiers: list, kind: str = None, verbose: bool = True, wait: float = 0, results: dict = None) → dict[source]

Return CIDs for molecule based on any synonym, including a chemical name or a CAS

pyrfume.odorants.get_compound_odor(cid, raw=False)[source]
pyrfume.odorants.get_compound_summary(cid: int, heading: str)[source]

Get summary info about heading from PubChem for the compound given by cid. Example heading: ‘Physical Description’

pyrfume.odorants.get_kind(identifier: str)[source]
pyrfume.odorants.is_kind(identifier: str, kind: str) → bool[source]
pyrfume.odorants.smiles_to_image(smiles, png=True, b64=False, crop=True, padding=10, size=300)[source]

png: Whether to convert to .png data (or to leave as a PIL image) b64: Whether to base64 encode (only possible for .png data)

pyrfume.odorants.smiles_to_mol(smiles: list, max_attempts: int = 10, use_random_coords: bool = False, deisomerize=False) → dict[source]
pyrfume.odorants.url_to_json(url, verbose=True) → str[source]