### Command Line Clustering Example Source: https://www.rdkit.org/docs/source/rdkit.Chem.Fingerprints.ClusterMols.html Example of how to use the ClusterMols command-line application for clustering molecules from a data file. ```bash python ClusterMols.py -d data.gdb -t daylight_sig –idName=”CAS_TF” -o clust1.pkl –actTable=”dop_test” –actName=”moa_quant” ``` -------------------------------- ### Command-line App Usage Example Source: https://www.rdkit.org/docs/source/rdkit.Chem.Fingerprints.FingerprintMols.html Example of how to use the command-line application for fingerprinting. Specify input database, target table, and column names for SMILES, IDs, and output. ```bash python FingerprintMols.py -d data.gdb -t ‘raw_dop_data’ –smilesName=”Structure” –idName=”Mol_ID” –outTable=”daylight_sig” ``` -------------------------------- ### Setup Linux Conda Environment for RDKit Build Source: https://www.rdkit.org/docs/Install.html Installs the miniforge installer and creates a conda environment with necessary build dependencies for RDKit on Linux x86_64. ```bash bash Miniforge3-Linux-x86_64.sh conda create -n rdkit_build -c conda-forge gxx_linux-64 cmake cairo pillow eigen pkg-config boost-cpp boost numpy matplotlib pandas pytest ``` -------------------------------- ### Get All Combinations Example 1 Source: https://www.rdkit.org/docs/source/rdkit.Chem.Pharm2D.Utils.html Demonstrates GetAllCombinations with simple choices. Results with duplicates are not generated when noDups is 1. ```python >>> GetAllCombinations([(0, ), (1, ), (2, )]) [[0, 1, 2]] >>> GetAllCombinations([(0, ), (1, 3), (2, )]) [[0, 1, 2], [0, 3, 2]] ``` -------------------------------- ### Install RDKit Source: https://www.rdkit.org/docs/Install.html Install the built RDKit components to their designated locations after a successful build. ```bash make install ``` -------------------------------- ### Python Docstring Example Source: https://www.rdkit.org/docs/GettingStartedWithContributing.html Demonstrates the recommended format for Python docstrings, including a brief explanation, references, argument descriptions, return values, and usage examples. ```python def xy(): """ This is a documentation string. It is continued here... """ ``` -------------------------------- ### ForceField Initialization and Usage Example Source: https://www.rdkit.org/docs/cppapi/ForceField_8h_source.html Schematic example of how to use the ForceField class. It involves adding contributions, setting positions, initializing the field, and then minimizing the energy. ```python ForceField ff; // add contributions: for contrib in contribs: ff.contribs().push_back(contrib); // set up the points: for positionPtr in positions: ff.positions().push_back(point); // initialize: ff.initialize() // and minimize: needsMore = ff.minimize(); ``` -------------------------------- ### Create and Install RDKit Extension Source: https://www.rdkit.org/docs/Cartridge.html Commands to create a new PostgreSQL database and install the RDKit extension. This is a prerequisite for using RDKit's molecular functionalities within PostgreSQL. ```bash ~/RDKit_trunk/Data/emolecules > createdb emolecules ~/RDKit_trunk/Data/emolecules > psql -c 'create extension rdkit' emolecules ``` -------------------------------- ### getNoteStartAngle Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1MolDraw2D__detail_1_1DrawMolMCHCircleAndLine.html Gets the starting angle for a note associated with an atom. ```APIDOC ## getNoteStartAngle ### Description Gets the starting angle for a note associated with an atom. ### Signature `double getNoteStartAngle(const Atom *atom) const` ``` -------------------------------- ### InfoBitRanker Constructor Example (Default Entropy) Source: https://www.rdkit.org/docs/cppapi/InfoBitRanker_8h_source.html Demonstrates the creation of an InfoBitRanker instance using default settings (entropy). It initializes the ranker for a specified number of bits and classes. ```cpp InfoBitRanker ranker(4, 2); // For i, bv in enumerate(bvs): ranker.AccumulateVotes(bv, acts[i]) // ... // for bit, gain, n0, n1 in ranker.GetTopN(3): print int(bit), '%.3f'%gain, int(n0), int(n1) ``` -------------------------------- ### SDSupplyNode Initialization and Iteration Example Source: https://www.rdkit.org/docs/source/rdkit.VLib.NodeLib.SDSupply.html Demonstrates how to initialize an SDSupplyNode with an SDF file path and iterate through the supplied molecules. Shows how to access molecule properties and reset the iterator. ```python import os from rdkit import RDConfig fileN = os.path.join(RDConfig.RDCodeDir,'VLib','NodeLib', 'test_data','NCI_aids.10.sdf') suppl = SDSupplyNode(fileN) ms = [x for x in suppl] len(ms) ms[0].GetProp("_Name") ms[1].GetProp("_Name") suppl.reset() suppl.next().GetProp("_Name") suppl.next().GetProp("_Name") ``` -------------------------------- ### getStartIterator Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1MolStandardize_1_1Layout2DValidation-members.html Gets the start iterator for a collection. This is a standard C++ container operation. ```APIDOC ## getStartIterator ### Description Gets the start iterator for a collection. ### Method Not specified (assumed to be a C++ function call) ### Endpoint Not applicable (C++ API) ### Parameters Not specified in the source text. ### Request Example Not applicable (C++ API) ### Response Not specified in the source text. ``` -------------------------------- ### EvenSamplePairsStrategy Initialization Example Source: https://www.rdkit.org/docs/cppapi/EvenSamplePairs_8h_source.html Demonstrates basic usage for initializing and using EvenSamplePairsStrategy to enumerate RGroups. This involves setting up building blocks and iterating through samples. ```cpp std::vector bbs; bbs.push_back( bbs_for_reactants_1 ); bbs.push_back( bbs_for_reactants_2 ); EvenSamplePairsStrategy rgroups; rgroups.initialize(rxn, bbs); for(boost::uint64_t i=0; i lprops = rxn.RunReactants(rvect); ... ``` -------------------------------- ### initFromFeat basic usage Source: https://www.rdkit.org/docs/source/rdkit.Chem.FeatMaps.FeatMapPoint.html Demonstrates the basic initialization of a FeatMapPoint from a FreeChemicalFeature and verifies that family, type, and position are correctly transferred. Also shows that featDirs is initialized as an empty list. ```python from rdkit import Geometry from rdkit.Chem import ChemicalFeatures sfeat = ChemicalFeatures.FreeChemicalFeature('Aromatic','Foo',Geometry.Point3D(0,0,0)) fmp = FeatMapPoint() fmp.initFromFeat(sfeat) fmp.GetFamily()==sfeat.GetFamily() True fmp.GetType()==sfeat.GetType() True list(fmp.GetPos()) [0.0, 0.0, 0.0] fmp.featDirs == [] True ``` -------------------------------- ### TDTMolSupplier Lazy Evaluation Example Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html Demonstrates lazy evaluation with TDTMolSupplier, where molecules are constructed only when requested. This example shows iterating through the supplier and getting the number of atoms for each molecule. ```python suppl = TDTMolSupplier('in.smi') >>> for mol in suppl: ... mol.GetNumAtoms() ``` -------------------------------- ### Start PostgreSQL Service Source: https://www.rdkit.org/docs/Install.html Command to restart the PostgreSQL service after the RDKit PostgreSQL cartridge has been installed. ```bash "C:\Program Files\PostgreSQL\9.5\bin\pg_ctl.exe" -N "postgresql-9.5" -D "C:\Program Files\PostgreSQL\9.5\data" -w start ``` -------------------------------- ### FPBReader Basic Usage Example Source: https://www.rdkit.org/docs/cppapi/FPBReader_8h_source.html Demonstrates the basic workflow of using FPBReader to read a file, initialize it, retrieve a fingerprint by index, and find Tanimoto neighbors. ```cpp FPBReader reader("foo.fpb"); reader.init(); boost::shared_ptr ebv = reader.getFP(95); std::vector > nbrs = reader.getTanimotoNeighbors(*ebv.get(), 0.70); ``` -------------------------------- ### SupplyNode Initialization and Iteration Example Source: https://www.rdkit.org/docs/source/rdkit.VLib.Supply.html Demonstrates how to initialize a SupplyNode with contents and iterate through its values. Shows the behavior of next() and reset(), including handling StopIteration. ```python >>> supplier = SupplyNode(contents=[1,2,3]) >>> supplier.next() 1 >>> supplier.next() 2 >>> supplier.next() 3 >>> supplier.next() Traceback (most recent call last): ... # doctest: +SKIP StopIteration >>> supplier.reset() >>> supplier.next() 1 >>> [x for x in supplier] [1, 2, 3] ``` -------------------------------- ### Get All Combinations Example 2 Source: https://www.rdkit.org/docs/source/rdkit.Chem.Pharm2D.Utils.html Demonstrates GetAllCombinations with choices containing multiple elements. This generates more complex combinations. ```python >>> GetAllCombinations([(0, 1), (1, 3), (2, )]) [[0, 1, 2], [0, 3, 2], [1, 3, 2]] ``` -------------------------------- ### SmartsMatcher Constructor Examples Source: https://www.rdkit.org/docs/cppapi/FilterMatchers_8h_source.html Demonstrates various ways to construct a SmartsMatcher, including by name, query molecule, SMARTS string, and shared pointer. Default values for minCount and maxCount are provided. ```cpp SmartsMatcher(const std::string &name = SMARTS_MATCH_NAME_DEFAULT) : FilterMatcherBase(name), d_pattern(), d_max_count(UINT_MAX) {} ``` ```cpp SmartsMatcher(const ROMol &pattern, unsigned int minCount = 1, unsigned int maxCount = UINT_MAX); ``` ```cpp SmartsMatcher(const std::string &name, const ROMol &pattern, unsigned int minCount = 1, unsigned int maxCount = UINT_MAX); ``` ```cpp SmartsMatcher(const std::string &name, const std::string &smarts, unsigned int minCount = 1, unsigned int maxCount = UINT_MAX); ``` ```cpp SmartsMatcher(const std::string &name, const std::string &smarts, unsigned int minCount = 1, unsigned int maxCount = UINT_MAX); ``` ```cpp //! Construct a SmartsMatcher from a shared_ptr /* \param name name for the smarts pattern ``` -------------------------------- ### Get Hybridization Type of Atoms Source: https://www.rdkit.org/docs/Cookbook.html Iterates through atoms in a molecule and prints their hybridization type. Requires RDKit to be installed. ```python from rdkit import Chem m = Chem.MolFromSmiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C") for x in m.GetAtoms(): print(x.GetIdx(), x.GetHybridization()) ``` ```text 0 SP3 1 SP2 2 SP2 3 SP2 4 SP2 5 SP2 6 SP2 7 SP2 8 SP2 9 SP2 10 SP2 11 SP3 12 SP3 ``` -------------------------------- ### Basic Usage of EnumerateLibrary Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1EnumerateLibrary.html Demonstrates the fundamental workflow for initializing and using the EnumerateLibrary to generate reaction products. This involves setting up a ChemicalReaction, an EnumerationStrategyBase, and then iterating through the enumerator to obtain product molecules. ```cpp ChemicalReaction rxn = ... BBS bbs(num_rgroups); ... somehow LoadRGroups(bbs[0]); ... somehow LoadRGroups(bbs[1]..); ... EnumerateLibrary enumerator(en, bbs); for(; (bool)en; ++i) { // This is the same as rxn.run_Reactants( reagents ); std::vector products = en.next(); ... } ``` -------------------------------- ### Get Default Crippen Parameters Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1Descriptors_1_1CrippenParamCollection.html Retrieves the default Crippen parameters using the singleton instance. No setup is required. ```cpp CrippenParamCollection *params=CrippenParamCollection::getParams(); ``` -------------------------------- ### Get BitSet Source: https://www.rdkit.org/docs/cppapi/Composition2N_8h_source.html Returns the current inverse bitset. This is used to generate seeds, starting with the largest and decreasing the number of external bonds. ```cpp BitSet getBitSet() const { return InverseBits; // inverse to generate biggest seed first and then // decrease number of external bonds } ``` -------------------------------- ### Initialize Fragment Catalog Parameters Source: https://www.rdkit.org/docs/GettingStartedInPython.html Sets up parameters for creating a fragment catalog, specifying minimum and maximum fragment sizes and a file containing functional group definitions. The number of functional groups loaded is also shown. ```python fName=os.path.join(RDConfig.RDDataDir,'FunctionalGroups.txt') from rdkit.Chem import FragmentCatalog fparams = FragmentCatalog.FragCatParams(1,6,fName) fparams.GetNumFuncGroups() ``` -------------------------------- ### Create and Populate SubstructLibrary Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdSubstructLibrary.html Demonstrates how to create a SubstructLibrary, add molecules from an SDF file, and perform a basic substructure search using SMARTS. This is useful for setting up a library for searching. ```python from __future__ import print_function import os from rdkit import Chem, RDConfig from rdkit.Chem import rdSubstructLibrary library = rdSubstructLibrary.SubstructLibrary() for mol in Chem.SDMolSupplier(os.path.join(RDConfig.RDDataDir, 'NCI', 'first_200.props.sdf')): idx = library.AddMol(mol) core = Chem.MolFromSmarts('CCCCOC') indices = library.GetMatches(core) len(indices) ``` -------------------------------- ### SmilesMolSupplier Lazy Evaluation Example 1 Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html Demonstrates lazy evaluation by creating a SmilesMolSupplier and iterating through it to get molecule atom counts. Molecules are constructed only when accessed. ```python suppl = SmilesMolSupplier('in.smi') for mol in suppl: mol.GetNumAtoms() ``` -------------------------------- ### Iterate Through Bonds to Get Stereochemistry Source: https://www.rdkit.org/docs/Cookbook.html Iterates through each bond in the molecule and prints its start and end atom indices, bond type, and stereochemistry information using `GetStereo()`. ```python # Using GetStereo() for b in mol.GetBonds(): print(b.GetBeginAtomIdx(),b.GetEndAtomIdx(), b.GetBondType(),b.GetStereo()) ``` -------------------------------- ### InfoBitRanker Constructor Example (Biased Chi-Squared) Source: https://www.rdkit.org/docs/cppapi/InfoBitRanker_8h_source.html Demonstrates the initialization of an InfoBitRanker with the biased Chi-Squared metric. This allows for ranking bits based on chi-squared values while also considering a predefined bias. ```cpp InfoBitRanker ranker(4, 2, InfoBitRanker::InfoType::BIASCHISQUARE); ranker.SetBiasList((1,)); // For i, bv in enumerate(bvs): ranker.AccumulateVotes(bv, acts[i]) // ... // for bit, gain, n0, n1 in ranker.GetTopN(3): print int(bit), '%.3f'%gain, int(n0), int(n1) ``` -------------------------------- ### startMol Source: https://www.rdkit.org/docs/cppapi/SLNParseOps_8h_source.html Initializes a new molecule and adds the first atom to it. It also handles the initial setup for SLN parsing, including bookmarking atom IDs and adding explicit hydrogens if not in query mode. ```APIDOC ## startMol ### Description Initializes a molecule and adds the first atom to it. This function is used to begin the process of building a molecule from SLN notation. It handles the creation of a new RWMol, adds the initial atom, and sets up atom ID bookmarking. If not in query mode, it also adds any explicit hydrogens present on the first atom. ### Method `template int startMol(std::vector &molList, AtomType *firstAtom, bool doingQuery)` ### Parameters - `molList` (std::vector &): A reference to a vector of RWMol pointers, where the new molecule will be added. - `firstAtom` (AtomType *): A pointer to the first atom to be added to the molecule. `AtomType` can be any type derived from `Atom`. - `doingQuery` (bool): A flag indicating whether the molecule is being built for a query. If false, explicit hydrogens are handled. ### Returns An integer representing the index of the newly created molecule in the `molList`. ``` -------------------------------- ### Initialize PandasTools and Load Data Source: https://www.rdkit.org/docs/source/rdkit.Chem.PandasTools.html Installs PandasTools for RDKit integration and loads sample antibiotic data into a Pandas DataFrame. This setup is primarily for testing purposes. ```python import pandas as pd from rdkit.Chem import PandasTools PandasTools.InstallPandasTools() # <- only necessary during testing, you don't need to do this import os from rdkit import RDConfig antibiotics = pd.DataFrame(columns=['Name','Smiles']) antibiotics = pd.concat([antibiotics, pd.DataFrame.from_records([{'Smiles':'CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)O)C', 'Name':'Penicilline G'}])], ignore_index=True) #Penicilline G antibiotics = pd.concat([antibiotics,pd.DataFrame.from_records([ {'Smiles':'CC1(C2CC3C(C(=O)C(=C(C3(C(=O)C2=C(C4=C1C=CC=C4O)O)O)O)C(=O)N)N(C)C)O', 'Name':'Tetracycline'}])], ignore_index=True) #Tetracycline antibiotics = pd.concat([antibiotics,pd.DataFrame.from_records([ {'Smiles':'CC1(C(N2C(S1)C(C2=O)NC(=O)C(C3=CC=CC=C3)N)C(=O)O)C', 'Name':'Ampicilline'}])], ignore_index=True) #Ampicilline print([str(x) for x in antibiotics.columns]) print(antibiotics) ``` -------------------------------- ### Get Bond Type as Double Source: https://www.rdkit.org/docs/_downloads/23ca22564d4370078f9b0881568d67ae/Bond.h Returns the bond type represented as a double-precision floating-point number. For example, SINGLE bonds are returned as 1.0, and AROMATIC bonds as 1.5. ```cpp //! double getBondTypeAsDouble() const; ``` -------------------------------- ### Basic Molecule and Template Setup Source: https://www.rdkit.org/docs/source/rdkit.Chem.TemplateAlign.html Initializes molecules and their 2D coordinates for alignment. This sets up the prerequisite structures before performing the alignment. ```python from rdkit import Chem from rdkit.Chem import rdDepictor from rdkit.Chem.TemplateAlign import AlignMolToTemplate2D patt = Chem.MolFromSmiles('C1CC1') rdDepictor.Compute2DCoords(patt) mol = Chem.MolFromSmiles('OC1CC1CC1CCC1') rdDepictor.Compute2DCoords(mol) pc = patt.GetConformer(0) mc = mol.GetConformer(0) ``` -------------------------------- ### Configure PostgreSQL Daemon with Supervisor Source: https://www.rdkit.org/docs/Install.html Example supervisor configuration to run PostgreSQL as a daemon. This requires supervisor to be installed. Adjust '[conda folder]', '/folder/where/data/should/be/stored', and '[your username]' as needed. ```ini [program:postgresql] command=[conda folder]/envs/my-rdkit-env/bin/postgres -D /folder/where/data/should/be/stored user=[your username] autorestart=true ``` -------------------------------- ### AcidBaseCatalogEntry initFromString Method Source: https://www.rdkit.org/docs/cppapi/AcidBaseCatalogEntry_8h_source.html Initializes the catalog entry from a string pickle. ```cpp void initFromString(const std::string &text) override; ``` -------------------------------- ### SmilesMolSupplier Lazy Evaluation Example 2 Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html Shows another lazy evaluation scenario where specific molecules are retrieved using next(), and the supplier can be reset to start from the beginning. ```python suppl = SmilesMolSupplier('in.smi') mol1 = next(suppl) mol2 = next(suppl) suppl.reset() mol3 = next(suppl) ``` -------------------------------- ### SetupNeighbourhood Source: https://www.rdkit.org/docs/cppapi/namespacemembers_func_s.html Sets up neighborhood information for structure checking. ```APIDOC ## SetupNeighbourhood() ### Description Initializes or configures the neighborhood information for atoms, used in various structure validation checks. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters - `mol` (RDKit.Mol): The molecule for which to set up neighborhood information. ### Response None. ``` -------------------------------- ### Get Wavy Line Segments Source: https://www.rdkit.org/docs/cppapi/MolDraw2DDetails_8h_source.html Generates points for a wavy line using Bezier curves. Returns a vector of tuples, each containing the start point, two control points, and the end point of a Bezier segment. ```C++ RDKIT_MOLDRAW2D_EXPORT std::vector> getWavyLineSegments( const Point2D &p1, const Point2D &p2, unsigned int nSegments, double vertOffset); ``` -------------------------------- ### Get Entry by Bit ID Source: https://www.rdkit.org/docs/cppapi/Catalog_8h_source.html Retrieves a constant pointer to an entry based on its bit ID. It iterates through entries starting from the provided bit ID index up to the total number of entries to find a match. Returns `nullptr` if no entry with the specified bit ID is found. ```cpp const entryType *getEntryWithBitId(unsigned int idx) const { URANGE_CHECK(idx, this->getFPLength()); typename boost::property_map::const_type pMap = boost::get(vertex_entry_t(), d_graph); const entryType *res = nullptr; for (unsigned int i = idx; i < this->getNumEntries(); i++) { const entryType *e = pMap[i]; if (e->getBitId() == static_cast(idx)) { res = e; break; } } return res; } ``` -------------------------------- ### MultiFPBReader Basic Usage Example Source: https://www.rdkit.org/docs/cppapi/MultiFPBReader_8h_source.html Demonstrates the basic usage of MultiFPBReader by initializing it with multiple FPBReader objects, performing an initialization, retrieving a fingerprint, and finding Tanimoto neighbors. ```C++ FPBReader r1("foo1.fpb"),r2("foo2.fpb"); std::vector readers; readers.append(&r1); readers.append(&r2); MultiFPBReader fpbs(readers); fpbs.init(); boost::shared_ptr ebv = fpbs.getReader(0)->getFP(95); std::vector > nbrs = fpbs.getTanimotoNeighbors(*ebv.get(), 0.70); ``` -------------------------------- ### example Source: https://www.rdkit.org/docs/cppapi/structRDKit_1_1Deprotect_1_1DeprotectData.html Member data providing an example of the deprotection. ```APIDOC ## example ### Description Provides an example of the deprotection. ### Type `std::string` ### Definition Defined at line 44 of file Deprotect.h. ``` -------------------------------- ### initFromString Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1SubstructLibrary.html Initializes the library from a string pickle. ```APIDOC ## initFromString ### Description Initializes the `SubstructLibrary` from a string containing a pickle (serialized data). ### Method `void initFromString(const std::string &text)` ### Parameters - `text` (const std::string &): The string containing the serialized library data. ``` -------------------------------- ### Initialize and Use Default InfoBitRanker Source: https://www.rdkit.org/docs/cppapi/namespaceRDInfoTheory.html Demonstrates initializing an InfoBitRanker with default settings (infogain) and accumulating votes from bit vectors and activities. Retrieves the top 3 ranked bits. ```python ranker = InfoBitRanker(4,2) for i,bv in enumerate(bvs): ranker.AccumulateVotes(bv,acts[i]) for bit,gain,n0,n1 in ranker.GetTopN(3): print int(bit),'%.3f'gain,int(n0),int(n1) ``` -------------------------------- ### Get Atom Value Source: https://www.rdkit.org/docs/cppapi/Atom_8h_source.html Gets the atom's MDL atom value. ```cpp std::string getAtomValue(const Atom *atom); ``` -------------------------------- ### Initialize and Populate VectCollection Source: https://www.rdkit.org/docs/source/rdkit.DataStructs.VectCollection.html Demonstrates initializing a VectCollection and adding multiple ExplicitBitVects with unique IDs. Shows how to check the collection's size and number of bits. ```python >>> vc = VectCollection() >>> bv1 = DataStructs.ExplicitBitVect(10) >>> bv1.SetBitsFromList((1,3,5)) >>> vc.AddVect(1,bv1) >>> bv1 = DataStructs.ExplicitBitVect(10) >>> bv1.SetBitsFromList((6,8)) >>> vc.AddVect(2,bv1) >>> len(vc) 10 >>> vc.GetNumBits() 10 >>> vc[0] 0 >>> vc[1] 1 >>> vc[9] 0 >>> vc[6] 1 >>> vc.GetBit(6) 1 >>> list(vc.GetOnBits()) [1, 3, 5, 6, 8] ``` -------------------------------- ### Get Atom Alias Source: https://www.rdkit.org/docs/cppapi/Atom_8h_source.html Gets the atom's MDL atom alias. ```cpp std::string getAtomAlias(const Atom *atom); ``` -------------------------------- ### Get Atom RLabel Source: https://www.rdkit.org/docs/cppapi/Atom_8h_source.html Gets the atom's MDL integer RLabel. ```cpp int getAtomRLabel(const Atom *atm); ``` -------------------------------- ### Get Keys Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1SubstructLibrary.html Methods to get access to the underlying key holder, both mutable and constant. ```APIDOC ## Get Keys ### Description Provides access to the `KeyHolderBase` object managed by the `SubstructLibrary`. ### Methods - `KeyHolderBase & getKeys()` - Returns a reference to the mutable key holder. - `const KeyHolderBase & getKeys() const` - Returns a constant reference to the key holder. ``` -------------------------------- ### initialize() Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1EvenSamplePairsStrategy.html Initializes the strategy with a chemical reaction and building blocks. ```APIDOC ## initialize() ### Description Initializes the enumeration strategy with the specified chemical reaction and building blocks. ### Method `void initialize(const ChemicalReaction &reaction, const EnumerationTypes::BBS &building_blocks)` ### Parameters - **reaction**: The chemical reaction to initialize with. - **building_blocks**: The building blocks to use for initialization. ``` -------------------------------- ### Get Fingerprints Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1SubstructLibrary.html Methods to get access to the underlying fingerprint holder, both mutable and constant. ```APIDOC ## Get Fingerprints ### Description Provides access to the `FPHolderBase` object managed by the `SubstructLibrary`. ### Methods - `FPHolderBase & getFingerprints()` - Returns a reference to the mutable fingerprint holder. - `const FPHolderBase & getFingerprints() const` - Returns a constant reference to the fingerprint holder. ``` -------------------------------- ### Build RDKit Documentation with Doxygen Source: https://www.rdkit.org/docs/GettingStartedWithContributing.html Steps to run doxygen and navigate to the documentation build directory for local testing. ```bash # run doxygen cd $RDBASE/Code/ && doxygen doxygen/doxygen.config cd $RDBASE/Docs/Book ``` -------------------------------- ### SubstructLibrary Usage Example Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdSubstructLibrary.html Demonstrates the basic usage of the SubstructLibrary, including adding molecules from an SDF file and performing a substructure search using SMARTS patterns. ```APIDOC ## SubstructLibrary Basic Usage ### Description This example shows how to initialize a SubstructLibrary, add molecules to it from a file, and then perform a substructure search. ### Usage ```python from __future__ import print_function import os from rdkit import Chem, RDConfig from rdkit.Chem import rdSubstructLibrary # Initialize the library library = rdSubstructLibrary.SubstructLibrary() # Add molecules from an SDF file for mol in Chem.SDMolSupplier(os.path.join(RDConfig.RDDataDir, 'NCI', 'first_200.props.sdf')): idx = library.AddMol(mol) # Define a substructure query (SMARTS pattern) core = Chem.MolFromSmarts('CCCCOC') # Get indices of matching molecules indices = library.GetMatches(core) print(len(indices)) # Example with substructure matching options indices_chirality = library.GetMatches(core, useChirality=False) print(len(indices_chirality)) ``` ### Methods - **SubstructLibrary()**: Initializes a new SubstructLibrary instance. - **AddMol(mol)**: Adds a molecule to the library and returns its index. - **GetMatches(query, **kwargs)**: Performs a substructure search with the given query and returns a list of indices of matching molecules. Accepts optional keyword arguments for search customization (e.g., `useChirality`). ``` -------------------------------- ### Get Supplemental Smiles Label Source: https://www.rdkit.org/docs/cppapi/Atom_8h_source.html Gets the supplemental label that will follow the atom when writing smiles strings. ```cpp std::string getSupplementalSmilesLabel(const Atom *atom); ``` -------------------------------- ### startMol Source: https://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1SLNParse.html Initializes a molecule structure, preparing it for further parsing or manipulation. ```APIDOC ## startMol() ### Description Initializes a molecule structure. This function is a template and prepares a molecule for subsequent parsing operations. ### Signature `template int startMol(std::vector< RWMol * > & _molList_, AtomType * _firstAtom_, bool _doingQuery_)` ### Parameters * `_molList_` (std::vector< RWMol * > &) - A reference to a vector of RWMol pointers where the initialized molecule will be stored. * `_firstAtom_` (AtomType *) - A pointer to the first atom of the molecule to be initialized. * `_doingQuery_` (bool) - Flag indicating if a query is being performed. ``` -------------------------------- ### Basic Chemical Reaction Usage Source: https://www.rdkit.org/docs/cppapi/Reaction_8h_source.html Demonstrates the fundamental steps for setting up and running a chemical reaction using the ChemicalReaction class. This includes adding reactant and product templates, initializing matchers, and iterating through potential products. ```cpp ChemicalReaction rxn; rxn.addReactantTemplate(r1); rxn.addReactantTemplate(r2); rxn.addProductTemplate(p1); rxn.initReactantMatchers(); MOL_SPTR_VECT prods; for(MOL_SPTR_VECT::const_iterator r1It=reactantSet1.begin(); r1It!=reactantSet1.end();++r1It;){ for(MOL_SPTR_VECT::const_iterator r2It=reactantSet2.begin(); r2It!=reactantSet2.end();++r2It;){ MOL_SPTR_VECT rVect(2); rVect[0] = *r1It; rVect[1] = *r2It; std::vector lprods; lprods = rxn.runReactants(rVect); for(std::vector::const_iterator lpIt=lprods.begin(); lpIt!=lprods.end();++lpIt){ // we know this is a single-product reaction: prods.push_back((*lpIt)[0]); } } } ``` -------------------------------- ### CollectVotes Source: https://www.rdkit.org/docs/source/rdkit.ML.MLUtils.VoteImg.html Collects the votes from a composite model for a given set of examples. It can optionally filter to include only misclassified examples. ```APIDOC ## CollectVotes ### Description Collects the votes from a composite model for the examples in the provided data. It can optionally filter for misclassified examples. ### Method `CollectVotes(_composite_, _data_, _badOnly_) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments * **composite**: A composite model. * **data**: A list of examples to run through the composite model. * **badOnly**: If set, only bad (misclassified) examples will be kept. ### Returns A 4-tuple containing: 1. The expanded list of vote details. 2. The list of predicted results. 3. The list of true results. 4. The number of miscounted examples. ### Notes The expanded list of vote details consists of: '[ vote1, vote2, … voteN, 0, res, trueRes]', where _res_ is the predicted result and _trueRes_ is the actual result. The extra zero is included to allow a line to be drawn between the votes and the results. ``` -------------------------------- ### EnumerateLibrary Sampling Example Source: https://www.rdkit.org/docs/cppapi/Enumerate_8h_source.html Illustrates how to sample a specific number of products from a potentially large enumeration using EnumerateLibrary. ```cpp for(int i=0;i products = en.next(); ... } ``` -------------------------------- ### RDKit Sphinx Doctest Example Source: https://www.rdkit.org/docs/GettingStartedWithContributing.html Shows how to embed Sphinx doctests in RDKit documentation to display code example results. ```rst .. doctest:: >>> mol = Chem.MolFromSmiles('CO(C)C') >>> print(print(mol.GetNumAtoms())) 4 ``` -------------------------------- ### OutputNode Usage Example Source: https://www.rdkit.org/docs/source/rdkit.VLib.Output.html Demonstrates how to use the OutputNode class to capture output from a SupplyNode. Requires importing SupplyNode and StringIO. The strFunc argument customizes the string representation of the output. ```python from rdkit.VLib.Supply import SupplyNode supplier = SupplyNode(contents=[1,2,3]) from io import StringIO sio = StringIO() node = OutputNode(dest=sio,strFunc=lambda x:'%s '%(str(x))) node.AddParent(supplier) node.next() sio.getvalue() node.next() sio.getvalue() ``` -------------------------------- ### InfoBitRanker Constructor Example (Biased Entropy) Source: https://www.rdkit.org/docs/cppapi/InfoBitRanker_8h_source.html Shows how to instantiate an InfoBitRanker with a specific information type (biased entropy) and set a bias list. This is useful for weighting certain bits or classes. ```cpp InfoBitRanker ranker(4, 2, InfoBitRanker::InfoType::BIASENTROPY); ranker.SetBiasList((1,)); // For i, bv in enumerate(bvs): ranker.AccumulateVotes(bv, acts[i]) // ... // for bit, gain, n0, n1 in ranker.GetTopN(3): print int(bit), '%.3f'%gain, int(n0), int(n1) ``` -------------------------------- ### Get Atom Map Number Source: https://www.rdkit.org/docs/cppapi/Atom_8h_source.html Gets the atom map number of the atom. Returns 0 if no atom map exists. ```cpp int getAtomMapNum() const { int mapno = 0; getPropIfPresent(common_properties::molAtomMapNumber, mapno); return mapno; } ``` -------------------------------- ### Specify RDKit Install Location Source: https://www.rdkit.org/docs/Install.html Use this option to set a custom installation directory for RDKit. Ensure RDK_INSTALL_INTREE is turned off. ```bash cmake -DRDK_INSTALL_INTREE=OFF -DCMAKE_INSTALL_PREFIX=/path/as/you/like .. ``` -------------------------------- ### Initialize Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdChemReactions.html Initializes the reaction so that it can be used. ```APIDOC ## Initialize ### Description Initializes the reaction so that it can be used. ### Method Initialize ### Parameters #### Path Parameters - **silent** (bool) - Optional - If True, initialization will be silent. Defaults to False. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (None) - Initializes the reaction. #### Response Example None ``` -------------------------------- ### Get Atomic Weight by C-style Element Symbol Source: https://www.rdkit.org/docs/cppapi/PeriodicTable_8h_source.html Overload to get atomic weight using a C-style string for the element symbol. ```cpp double getAtomicWeight(const char *elementSymbol) const { return getAtomicWeight(std::string(elementSymbol)); } ``` -------------------------------- ### FeatMapPoint.initFromFeat() Source: https://www.rdkit.org/docs/source/rdkit.Chem.FeatMaps.FeatMapPoint.html Initializes the FeatMapPoint object from an existing ChemicalFeatures.FreeChemicalFeature object. ```APIDOC ## FeatMapPoint.initFromFeat(feat) ### Description Initializes the `FeatMapPoint` object's properties (family, type, position, and feature directions) based on the provided `ChemicalFeatures.FreeChemicalFeature` object. ### Parameters #### Path Parameters - `feat` (ChemicalFeatures.FreeChemicalFeature) - The source feature object from which to initialize. ### Request Example ```python from rdkit import Geometry from rdkit.Chem import ChemicalFeatures sfeat = ChemicalFeatures.FreeChemicalFeature('Aromatic','Foo',Geometry.Point3D(0,0,0)) fmp = FeatMapPoint() fmp.initFromFeat(sfeat) # Verify initialization print(fmp.GetFamily() == sfeat.GetFamily()) print(fmp.GetType() == sfeat.GetType()) print(list(fmp.GetPos()) == [0.0, 0.0, 0.0]) print(fmp.featDirs == []) # Example with feature directions sfeat.featDirs = [Geometry.Point3D(1.0,0,0)] fmp.initFromFeat(sfeat) print(len(fmp.featDirs) == 1) ``` ### Response This method does not return a value; it modifies the `FeatMapPoint` object in place. ``` -------------------------------- ### Python FilterMatcher Example Source: https://www.rdkit.org/docs/source/rdkit.Chem.FilterCatalog.html Demonstrates how to create a custom Python filter by subclassing FilterMatcher. This example defines a filter to check molecular weight constraints. ```python from rdkit.Chem import rdMolDescriptors class MWFilter(FilterMatcher): def __init__(self, minMw, maxMw): FilterMatcher.__init__(self, "MW violation") self.minMw = minMw self.maxMw = maxMw def IsValid(self): return True def HasMatch(self, mol): mw = rdMolDescriptors.CalcExactMolWt(mol) return not self.minMw <= mw <= self.maxMw ``` -------------------------------- ### initFromFeat with feature directions Source: https://www.rdkit.org/docs/source/rdkit.Chem.FeatMaps.FeatMapPoint.html Shows that when initializing a FeatMapPoint from a FreeChemicalFeature, the feature directions from the source feature are correctly transferred. ```python sfeat.featDirs = [Geometry.Point3D(1.0,0,0)] fmp.initFromFeat(sfeat) len(fmp.featDirs) 1 ``` -------------------------------- ### Install RDKit PostgreSQL Cartridge Source: https://www.rdkit.org/docs/Install.html Execute the installation script for the RDKit PostgreSQL cartridge. This script is typically found within the RDKit build directory. ```bash C:\RDKit\build\Code\PgSQL\rdkit\pgsql_install.bat ``` -------------------------------- ### SetupNeighbourhood Source: https://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1StructureCheck.html Sets up the neighborhood information for a molecule. This is a preparatory step for functions that analyze the local environment of atoms within the molecule. ```APIDOC ## SetupNeighbourhood() ### Description Sets up the neighborhood information for a molecule. This is a preparatory step for functions that analyze the local environment of atoms within the molecule. ### Signature `void SetupNeighbourhood(const ROMol & _mol, std::vector< Neighbourhood > & _neighbour_array)` ### Parameters * `_mol` (const ROMol &) - The molecule for which to set up neighborhood information. * `_neighbour_array` (std::vector< Neighbourhood > &) - The vector to be populated with neighborhood information. ### Returns `void` - This function does not return a value. ``` -------------------------------- ### Install RDKit using PIP Source: https://www.rdkit.org/docs/Install.html Use this command to install the RDKit package from PyPI. This is the recommended method for cross-platform compatibility on Linux, Windows, and macOS. ```bash pip install rdkit ``` -------------------------------- ### AcidBaseCatalogEntry initFromStream Method Source: https://www.rdkit.org/docs/cppapi/AcidBaseCatalogEntry_8h_source.html Initializes the catalog entry from a stream pickle. ```cpp void initFromStream(std::istream &ss) override; ``` -------------------------------- ### Install RDKit PostgreSQL Cartridge Source: https://www.rdkit.org/docs/Install.html Installs the RDKit PostgreSQL cartridge and its dependencies using conda. Ensure your conda environment is activated before running this command. ```bash conda install -c rdkit rdkit-postgresql ``` -------------------------------- ### Start PostgreSQL Server Source: https://www.rdkit.org/docs/Install.html Starts the PostgreSQL server in the foreground. Ensure the database has been initialized first. Replace '[conda folder]' and '/folder/where/data/should/be/stored' with your specific paths. ```bash [conda folder]/envs/my-rdkit-env/bin/postgres -D /folder/where/data/should/be/stored ``` -------------------------------- ### RGROUPS Example for Reaction Building Blocks Source: https://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1EnumerationTypes.html Demonstrates how to use RGROUPS to specify indices for building blocks from the BBS type to create a product in a reaction. ```cpp RGROUPS groups; groups.push_back(10); groups.push_back(5); // Will create a product from the following building blocks: MOL_SPTR_VECT building_blocks; building_blocks.push_back( BBS[0][groups[0] ); building_blocks.push_back( BBS[1][groups[1] ); rxn.runReactants( building_blocks ); ``` -------------------------------- ### EnumerateLibrary Basic Usage Example Source: https://www.rdkit.org/docs/cppapi/Enumerate_8h_source.html Demonstrates the basic usage of the EnumerateLibrary class for generating products from a chemical reaction and a set of reagents. ```cpp ChemicalReaction rxn = ... BBS bbs(num_rgroups); ... somehow LoadRGroups(bbs[0]); ... somehow LoadRGroups(bbs[1]..); ... EnumerateLibrary enumerator(en, bbs); for(; (bool)en; ++i) { // This is the same as rxn.run_Reactants( reagents ); std::vector products = en.next(); ... } ``` -------------------------------- ### initialize Source: https://www.rdkit.org/docs/cppapi/ForceField_8h_source.html Performs initialization for the ForceField. ```APIDOC ## ForceField::initialize ### Description Performs initialization for the ForceField. ### Returns * **void** ``` -------------------------------- ### Get Functional Group Hierarchy Matches Source: https://www.rdkit.org/docs/source/rdkit.Chem.rdfiltercatalog.html Demonstrates how to get a functional group hierarchy and find matches for a given molecule. This is useful for hierarchical filtering of chemical structures. ```python from rdkit.Chem import MolFromSmiles from rdkit.Chem.FilterCatalog import * functionalGroups = GetFunctionalGroupHierarchy() [match.filterMatch.GetName() for match in functionalGroups.GetFilterMatches( MolFromSmiles('c1ccccc1Cl'))] ``` -------------------------------- ### Initialize and Use Chi-Squared InfoBitRanker Source: https://www.rdkit.org/docs/cppapi/namespaceRDInfoTheory.html Demonstrates initializing an InfoBitRanker with the Chi-Squared measure. Accumulates votes and retrieves the top 3 ranked bits. ```python ranker = InfoBitRanker(4,2,InfoTheory.InfoType.CHISQUARE) for i,bv in enumerate(bvs): ranker.AccumulateVotes(bv,acts[i]) for bit,gain,n0,n1 in ranker.GetTopN(3): print int(bit),'%.3f'gain,int(n0),int(n1) ``` -------------------------------- ### Basic Usage of RandomSampleAllBBsStrategy Source: https://www.rdkit.org/docs/cppapi/classRDKit_1_1RandomSampleAllBBsStrategy.html Demonstrates the basic usage pattern for initializing and iterating through samples using RandomSampleAllBBsStrategy. This is useful for random enumeration of reagents where all reagents must be sampled. ```cpp std::vector bbs; bbs.push_back( bbs_for_reactants_1 ); bbs.push_back( bbs_for_reactants_2 ); RandomSampleAllBBsStrategy rgroups; rgroups.initialize(rxn, bbs); for(size_t i=0; i lprops = rxn.RunReactants(rvect); ... } ```