fragment_elaboration_scripts package¶
fragment_elaboration_scripts.enamine_catalog_download module¶
fragment_elaboration_scripts.enamine_store module¶
This uses the new Enamine Store which does not require authentication. But the old store does not work anymore so that API is a dead end.
The new one is a REST API, but the documentation is not public. This is meant to be used by the browser. Safeguards are in place and will not work on residential IPs. I set a sleep of 30 seconds between calls to be safe.
from fragment_elaboration_scripts.enamine_store import search, StoreCatalog, StoreCurrency
get_price(enamine_code, catalogue=StoreCatalog.REALDB, currency=StoreCurrency.EUR)
import pandas as pd
from rdkit import Chem
from fragment_elaboration_scripts.enamine_store import search, StoreCatalog, StoreTypes, StoreSSTypes
mol: Chem.Mol
df: pd.DataFrame = search(mol, catalogue=StoreCatalog.REALDB, search_type=StoreTypes.SMARTS)
CLI Usage¶
$ enamine-store price Z12345678 --catalogue REALDB --currency EUR
or
$ enamine-store search Cn1cnc2c1c(=O)n(C)c(=O)n2C > caffeine_analogues.csv
Installation¶
No special installation requirements beyond pip install fragment_elaboration_scripts
- class fragment_elaboration_scripts.enamine_store.StoreCatalog(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumEnamineStore catalogues: SCR, BB, REALDB, MADE, EBC
- BB = 2¶
- EBC = 5¶
- MADE = 4¶
- REALDB = 3¶
- SCR = 1¶
- class fragment_elaboration_scripts.enamine_store.StoreCurrency(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumEnamineStore currencies: USD, EUR
No other currencies are supported.
- EUR = 2¶
- USD = 1¶
- class fragment_elaboration_scripts.enamine_store.StoreSSTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumEnamineStore types of structural searches: EXACT, SUB, SIM
- EXACT = 1¶
- SIM = 3¶
- SUB = 2¶
- class fragment_elaboration_scripts.enamine_store.StoreTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumEnamineStore types of searches: ID, CAS, MFCD, SMARTS
- CAS = 2¶
- ID = 1¶
- MFCD = 3¶
- SMARTS = 4¶
- fragment_elaboration_scripts.enamine_store.get_price(enamine_code: str, catalogue: StoreCatalog = StoreCatalog.REALDB, currency: StoreCurrency = StoreCurrency.EUR) float[source]¶
Get the price of a compound from the Enamine Store.
price: float = get_price(enamine_code, catalogue=StoreCatalog.REALDB, currency=StoreCurrency.EUR)
- Parameters:
enamine_code – str. Enamine code, e.g. Z12345678
catalogue – see StoreCatalog enum. Options: SCR, BB, REALDB, MADE, EBC
currency – see StoreCurrency enum. Options: USD, EUR
- Returns:
price for 1 mg (fudged math for higher amounts)
- fragment_elaboration_scripts.enamine_store.search(mol_or_smarts: Mol | str, catalogue: StoreCatalog = StoreCatalog.REALDB, search_type: StoreTypes = StoreTypes.SMARTS, structural_type: StoreSSTypes = StoreSSTypes.SIM, size: int = 100, sim: float = 0.1) DataFrame[source]¶
Search the Enamine Store.
- Parameters:
mol_or_smarts – rdkit Mol or SMARTS string
catalogue – see StoreCatalog enum. Options: SCR, BB, REALDB, MADE, EBC
search_type – see StoreTypes enum. Options: ID, CAS, MFCD, SMARTS
structural_type – see StoreSSTypes enum. Options: EXACT, SUB, SIM
size – number of results to return
sim – similarity threshold
- Returns:
pandas DataFrame
fragment_elaboration_scripts.fauxalysis module¶
- fragment_elaboration_scripts.fauxalysis.make_fauxalysis(hits: List[Mol], target_name: str, base_folder='.') None[source]¶
Given a list of hits, make a fragalysis-download-like folder structure
- Parameters:
hits
target_name
base_folder
- Returns:
target_name = ‘👾👾👾’ make_fauxalysis(hits, target_name, os.path.join(os.getcwd(), ‘fauxalysis’))
fragment_elaboration_scripts.fragalysis_download module¶
A quick download functionality for the impatient.
- class fragment_elaboration_scripts.fragalysis_download.QuickDownloader(target_name: str, **options)[source]¶
Bases:
objectThis is simply a polished interface to the api/download_structures endpoint, which is the same as the download button on the Fragalysis website. Namely, it lacks the extended functionality of the xcexporter module. Instantiating it with the target name will download the zip file of these and can be interactive with via different methods.
- Cvar:
fragalysis_api_url: The URL of the Fragalysis API.
- Cvar:
api_data: The default options for the API endpoint. Can be also overridden in the constructor.
- Ivar:
target_name: The name of the target as on the main Fragalysis page, e.g. ‘Mpro’, case sensitive
- Ivar:
zf: The zip file object. see https://docs.python.org/3/library/zipfile.html
The contents of the
zipfile.ZipFileobject stored in the attribute.zfcan be written to disk with.write_all().The contents of a file within the zipfile can be accessed by subscripting the
QuickDownloaderinstance, with a string that is contained in the filename, e.g.quick['metadata'], will return the metadata.csv file content without having to waste time with filepaths.from fragalysis_api import QuickDownloader import pandas as pd from typing import List print(f'Default settings are: {QuickDownloader.api_data}') # Check if the target name is right target_names: List[str] = QuickDownloader.retrieve_target_names() target_name='Mpro' assert target_name in target_names, f'Target named "{target_name}" not found in the list of targets' # Download the data quick = QuickDownloader(target_name=target_name) quick.write_all(directory='downloads') hits: pd.DataFrame = quick.to_pandas(star_dummy=True) # Not all files have the reference pdb block, so if it does not the template is returned: reference_pdbblock: str = quick.reference_pdbblock
The class method
QuickDownloader.retrieve_target_datawill download all the metadata for the targets. whileQuickDownloader.retrieve_target_nameswill return their names.- __init__(target_name: str, **options)[source]¶
Given a target download the zip file and store it in
self.zf.- Parameters:
target_name – The name of the target as on the main Fragalysis page, e.g. ‘Mpro’, case sensitive
options – Any of the options for the endpoint, e.g.
event_info=True, cf.cls.api_data
- api_data = {'NAN': False, 'NAN2': False, 'bound_info': True, 'cif_info': False, 'diff_info': False, 'event_info': False, 'file_url': '', 'map_info': False, 'metadata_info': True, 'mtz_info': False, 'pdb_info': False, 'proteins': '', 'sdf_info': False, 'sigmaa_info': False, 'single_sdf_file': True, 'smiles_info': True, 'static_link': False, 'trans_matrix_info': False}¶
- fragalysis_api_url = 'fragalysis.diamond.ac.uk'¶
- property reference_pdbblock: str¶
Not all files have the reference pdb block, so if it does not the template is returned.
- Returns:
The reference PDB for the target.
- classmethod retrieve_target_data() List[Dict[str, Any]][source]¶
- Returns:
A list of all the target metadata available on the Fragalysis API.
- classmethod retrieve_target_names() List[str][source]¶
- Returns:
A list of all the target names available on the Fragalysis API.
fragment_elaboration_scripts.fragmenstein_merge_sw_place module¶
fragment_elaboration_scripts.fragment module¶
fragment_elaboration_scripts.lock_n_keyify module¶
fragment_elaboration_scripts.misc module¶
fragment_elaboration_scripts.oe_conformer_gen module¶
fragment_elaboration_scripts.plip module¶
fragment_elaboration_scripts.prep_fragalysis module¶
fragment_elaboration_scripts.pyrosetta_min module¶
fragment_elaboration_scripts.retrieve_PDB_ligands module¶
fragment_elaboration_scripts.row_getter module¶
fragment_elaboration_scripts.upload_fragalysis module¶
fragment_elaboration_scripts.zinc_data module¶
A very simple script to get info from Zinc. Zinc, as far as I can tell, does not have an API, so the HTML has to be scraped.
NB. I have not asked for permission to query ZINC programmatically
See ZincInformer for the class.
CLI Usage¶
$ python -m zinc_data ZINC00000001 ZINC00000002 ZINC00000003 > zinc.json
or
$ python -m zinc_data ZINC00000001 ZINC00000002 ZINC00000003 -o zinc.csv
Installation¶
No special installation requirements beyond pip install fragment_elaboration_scripts
- class fragment_elaboration_scripts.zinc_data.ZincInformer(suppressed_exception=<class 'Exception'>)[source]¶
Bases:
MutableMappingA simple class to get Zinc info.
A class that stores the retieved values —in
.data(.dumpand.loadto store). The values can be accessed as a subscript or by calling the instance, the latter captures errors declared during initialisation by the argumentsuppressed_exception.The instance is callable, so can be used in a
pandas.Series.apply:The data is stored in a dictionary, so can be dumped to a JSON file and loaded back in. This is useful for caching without repeating requests.
The data is fetched via a call by
get_soupand then parsed byget_zinc_info, which callsget_dlandpolísh.