SlideShare a Scribd company logo
1 of 2
Download to read offline
// Automatic format perception                        // Molecular formula
                 Open Babel 2.3                     std::ifstream ifs(filename);
                                                    OBConversion conv;
                                                                                                          (std::string) mol.GetFormula();

                 C++ API                            OBFormat* inFormat = conv.FormatFromExt(filename);
                                                    OBFormat* outFormat = conv.SetFormat("SDF");
                                                                                                          // Conformations
                                                                                                          (int) mol.NumConformers();
                                                    if (inFormat && outFormat)
                 Quick reference guide              {
                                                       conv.SetInAndOutFormats(inFormat, outFormat);
                                                                                                          // Smallest set of smallest rings
                                                                                                          (std::vector<OBRing*>) mol.GetSSSR();
                                                    }
                                                                                                          // Hydrogen manipulations
                                                                                                          (bool) mol.DeleteHydrogens();   // All H
                                                                                                          (bool) mol.AddPolarHydrogens(); // Polar H
Namespace
                                          Looping
over
atoms
and
bonds
                         (bool) mol.AddHydrogens();      // All H

                                                                                                          // Generic data
using namespace OpenBabel;                          #include <openbabel/obiter.h>                         std::vector<OBGenericData*>::iterator k;
                                                    #include <openbabel/mol.h>                            std::vector<OBGenericData*> vdata = mol.GetData();
                                                                                                          for (k = vdata.begin(); k != vdata.end(); ++k)
                                                    using namespace OpenBabel;                            if ((*k)->GetDataType() == OBGenericDataType::PairData)
Reading
and
writing
                                OBMol mol;
                                                                                                          {
                                                                                                             std::cout << "> <" << (*k)->GetAttribute();
                                                    OBAtom* atom;                                            std::cout << ">" << std::endl;
#include <openbabel/mol.h>                          OBAtom* nbrAtom;                                         std::cout << ((OBPairData*)(*k))->GetValue();
#include <openbabel/obconversion.h>                 OBBond* bond;                                            std::cout << std::endl;
                                                                                                          }
int main(int argc, char **argv)                     // Looping over all atoms
{                                                   double exactMass(0.0);                                // Remove all but the largest fragments
   OBMol mol;                                       FOR_ATOMS_OF_MOL(atom, mol)                           (bool) mol.StripSalts(0);
                                                    {
    // Read from standard input and write to           exactMass += atom->GetExactMass();                 // Clear molecule for re-use
    // standard output                              }                                                     (bool) mol.Clear();
    OBConversion conv(&std::cin, &std::cout);
                                                    // Looping over all bonds
    // Input format is sd-file, output format       unsigned int totalBondOrder(0);
    // is canonical smiles
    if (conv.SetInAndOutFormats("sdf", "can"))
                                                    FOR_BONDS_OF_MOL(bond, mol)
                                                    {
                                                                                                          Atoms

    {                                                  totalBondOrder += bond->GetBondOrder();
       if (conv.Read(&mol))                         }                                                     #include <openbabel/atom.h>
       {                                            // Looping over all neighbor atoms of given atom
          // Print number of atoms                  unsigned int nAtoms(0);                               OBAtom atom;
          std::cerr << "Molecule has: " <<          FOR_NBORS_OF_ATOM(nbrAtom, atom) ++nAtoms;
          mol.NumAtoms() << " atoms.n";                                                                  // Properties
       }                                                                                                  (int) atom.GetFormalCharge();
       conv->Write(&mol);                                                                                 (unsigned int) atom.GetAtomicNum();
    }
       mol.Clear();                                 Element
table
                                        (double) atom.GetAtomicMass();
    return 0;                                                                                             // Explicit and maximum expected connections
}                                                   #include <openbabel/data.h>                           (unsigned int) atom.GetValence();
                                                                                                          (unsigned int) atom.GetImplicitValence();
                                                    OBElementTable etab;
                                                                                                          // Non-hydrogen connections
Conversion
                                         (char*)
                                                    (int)
                                                                etab.GetSymbol(6);
                                                                etab.GetAtomicNum("C");
                                                                                                          (unsigned int) atom.GetHvyValence();
                                                    (double)    etab.GetVdwRad(7);                        // Implicit and explicit hydrogens
#include <openbabel/obconversion.h>                 (double)    etab.GetCovalentRad(8);                   (unsigned int) atom.ImplicitHydrogenCount();
#include <openbabel/mol.h>                          (double)    etab.GetMass(1);                          (unsigned int) atom.ExplicitHydrogenCount();
// Create molecule from SMILES string                                                                     // Is atom in ring of size 6?
std::string SmilesString("c1ccccc1");                                                                     (bool) atom.IsInRing() && atom.IsInRingSize(6);
OBMol mol;
stringstream ss(SmilesString)
                                                    Molecules
                                            // Size of smallest ring that contains the atom
OBConversion conv(&ss);                                                                                   (unsigned int) atom.MemberOfRingSize();
if (conv.SetInFormat("smi") && conv.Read(&mol))     #include <openbabel/mol.h>
{ /* ... */ }                                       #include <openbabel/generic.h>                        // Number of rings that contain the atom
                                                                                                          (unsigned int) atom.MemberOfRingCount();
// Conversion without manipulation                  OBMol mol;
OBConversion conv(&is, &os);
if (conv.SetInAndOutFormats("SMI", "MOL"))          // Number    of atoms and bonds
{
   // Option "h" adds explicit hydrogens
                                                    (unsigned
                                                    (unsigned
                                                                 int) mol.NumAtoms();    // All atoms
                                                                 int) mol.NumHvyAtoms(); // Non-H atoms
                                                                                                          Bonds

   conv.AddOption("h", OBConversion::GENOPTIONS);   (unsigned    int) mol.NumBonds();    // All bonds
   conv.Convert();                                                                                        #include <openbabel/bond.h>
}                                                   // Molecular weight with implicit hydrogens           #include <openbabel/atom.h>
                                                    (double) mol.GetMolWt(true);



                    www.silicos.com
                                       www.silicos.com
                                   www.silicos.com

OBBond bond;                                            // Set calculation parameters
                                                        spec.SetResolution(3.0);                               Energy
calculations

// Properties                                           spec.SetAccuracy(AngStepSize20);
(unsigned int) bond.GetBondOrder();                     spec.SetStereo(NoStereoSpecificProbes);                #include <openbabel/forcefield.h>
(bool) bond.IsPrimaryAmide(); // and 2 and 3...         spec.SetNormalization(NormalizationTowardsZeroMean);   #include <openbabel/mol.h>
(bool) bond.IsSingle(); // and 2 and 3...
(bool) bond.IsRotor();                                  // Calculate and print                                 OBMol mol;
                                                        std::vector<double> sphore;                            /* ... */
// Flanking atoms                                       sphore = spec.GetSpectrophore(&mol);
(OBAtom*) bond.GetBeginAtom();                          for (int i(0); i < sphore.size(); ++i)                 // Select the MMFF94 forcefield
(OBAtom*) bond.GetEndAtom();                            {                                                      OBForceField* pFF;
OBAtom* atom; (OBAtom*) bond.GetNbrAtom(atom);             std::cout << sphore[i] << "t";                     pFF = OBForceField::FindForceField("MMFF94");
                                                        }                                                      if (!pFF) exit(1);
// Is bond in ring?                                     std::cout << std::endl;
(bool) bond.IsInRing();                                                                                        // Set the logfile
                                                                                                               pFF->SetLogFile(&std::cerr);

                                                        Stereochemistry
                                       // Assign atom types, parameters, ...
Substructure
search
                                                                                           pFF->Setup(mol);
                                                        #include <openbabel/mol.h>                             // Calculate the energy
#include <openbabel/parsmart.h>                         #include <openbabel/obconversion.h>                    pFF->Energy();
#include <openbabel/mol.h>                              #include <openbabel/stereo/tetrahedral.h>
#include <openbabel/atom.h>                                                                                    // Perform maximum 1000 steps of minimization
                                                        OBMol mol;                                             pFF->ConjugateGradients(1000);
OBMol mol;                                              OBConversion conv;
OBAtom* atom;                                           conv.SetInFormat("smi");
/* ... */                                               conv.ReadString(&mol, "C[C@H](Cl)Br");
// Create a SMARTS pattern of a phenyl ring             // Stereofacade object
OBSmartsPattern sp;                                     OBStereoFacade facade(&mol);                           Open
Babel

sp.Init("c1ccccc1");                                    (unsigned int) facade.NumTetrahedralStereo();
                                                        (unsigned int) facade.NumCisTransStereo();             This documentation is part of the Open Babel project. For more information,
// Properties of the substructure                       (unsigned int) facade.SquarePlanarStereo();            see www.openbabel.org. Open Babel is free software; you can redistribute
if (sp.IsValid())                                                                                              it and/or modify it under the terms of the GNU General Public License as
{                                                       // Loop over all atoms to check if stereocenter        published by the Free Software Foundation version 2 of the License. Open
   std::cout << sp.NumAtoms();                          FOR_ATOMS_OF_MOL(atom, mol)                            Babel is distributed in the hope that it will be useful, but without any
   std::cout << sp.NumBonds();                          {
   std::cout << sp.GetSmarts();                            std::cout << atom->GetId() << ": ";                 warranty; without even the implied warranty of merchantability or fitness for
}                                                          if (facade.HasTetrahedralStereo(atom->GetId()))     a particular purpose. See the GNU General Public License for more details.
                                                              std::cout << ": stereo";
// Matching                                                else
(bool) sp.Match(mol, true); // Single matching                std::cout << ": no stereo";                      Spectrophore™
(bool) sp.Match(mol, false); // Complete matching          std::cout << std::endl;
                                                        }                                                      Spectrophore™ is a trademark of Silicos NV and the technology is part of
// Substructure mapping                                                                                        the Open Babel project.
std::vector<std::vector<int> > mapListA;
mapListA = sp.GetMapList(); // Non-unique matches
std::vector<std::vector<int> > mapListU;                Rings
                                                 Silicos
NV

mapListU = sp.GetUMapList(); // Unique matches
for (int m(0); m < mapListU.size(); ++m)                                                                       Silicos is a fee-for-service company empowering open source chemo-
{                                                       #include <openbabel/mol.h>                             informatics virtual screening technologies for the discovery of novel lead
   std::cout << "Unique match " << m << std::endl;      #include <openbabel/ring.h>                            compounds and database characterization. Silicos fully endorses the
   for (int a(0); a < mapListU[m].size(); ++a)          #include <openbabel/math/vector3.h>                    concept of open innovation and open source software development, and
   {                                                                                                           provides its clients with a wide variety of computational chemistry-based
      atom = mol.GetAtom(mapListU[m][a]);               OBMol mol;                                             lead discovery services, including Open Babel support, training and code
      std::cout << atom->GetAtomicNum() << std::endl;   /* ... */
   }                                                                                                           development. Please visit www.silicos.com for more details.
}                                                       // Get the smallest-set-of-smallest-rings
                                                        std::vector<OBRing*> rings = mol.GetSSSR();
                                                        vector3 center;
                                                        vector3 normal_up;
Spectrophores™
                                         vector3 normal_down;
                                                        for (int i(0); i < rings.size(); ++i)
                                                                                                               Copyright © 2010 Silicos NV
                                                        {                                                      Silicos NV
#include <openbabel/obspectrophore.h>                      (bool) rings[i].IsAromatic();
#include <openbabel/mol.h>                                 (int) rings[i].Size();                              Wetenschapspark 7,
                                                           (bool) rings[i].findCenterAndNormal(center,         B-3590 Diepenbeek
OBMol mol;                                                                                     normal_up,      Belgium
/* ... */                                                                                      normal_down);
                                                        }                                                      www.silicos.com
// Create a Spectrophore object                                                                                www.openbabel.org
OBSpectrophore spec;




                   www.silicos.com
                                        www.silicos.com


More Related Content

Viewers also liked

Modeling electrolyte solutions with the extended universal quasi chemical (u...
Modeling electrolyte solutions with the extended universal  quasi chemical (u...Modeling electrolyte solutions with the extended universal  quasi chemical (u...
Modeling electrolyte solutions with the extended universal quasi chemical (u...nazanin25
 
Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...baoilleach
 
Improving enrichment rates
Improving enrichment ratesImproving enrichment rates
Improving enrichment ratesbaoilleach
 
23 3 Quantum Mechanics
23 3 Quantum Mechanics23 3 Quantum Mechanics
23 3 Quantum Mechanicsfysteach
 
Interoperability and the Blue Obelisk
Interoperability and the Blue ObeliskInteroperability and the Blue Obelisk
Interoperability and the Blue Obeliskbaoilleach
 
Cinfony - Bring cheminformatics toolkits into tune
Cinfony - Bring cheminformatics toolkits into tuneCinfony - Bring cheminformatics toolkits into tune
Cinfony - Bring cheminformatics toolkits into tunebaoilleach
 

Viewers also liked (7)

Modeling electrolyte solutions with the extended universal quasi chemical (u...
Modeling electrolyte solutions with the extended universal  quasi chemical (u...Modeling electrolyte solutions with the extended universal  quasi chemical (u...
Modeling electrolyte solutions with the extended universal quasi chemical (u...
 
Post-Vatican II Mass
Post-Vatican II MassPost-Vatican II Mass
Post-Vatican II Mass
 
Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...
 
Improving enrichment rates
Improving enrichment ratesImproving enrichment rates
Improving enrichment rates
 
23 3 Quantum Mechanics
23 3 Quantum Mechanics23 3 Quantum Mechanics
23 3 Quantum Mechanics
 
Interoperability and the Blue Obelisk
Interoperability and the Blue ObeliskInteroperability and the Blue Obelisk
Interoperability and the Blue Obelisk
 
Cinfony - Bring cheminformatics toolkits into tune
Cinfony - Bring cheminformatics toolkits into tuneCinfony - Bring cheminformatics toolkits into tune
Cinfony - Bring cheminformatics toolkits into tune
 

More from baoilleach

We need to talk about Kekulization, Aromaticity and SMILES
We need to talk about Kekulization, Aromaticity and SMILESWe need to talk about Kekulization, Aromaticity and SMILES
We need to talk about Kekulization, Aromaticity and SMILESbaoilleach
 
Open Babel project overview
Open Babel project overviewOpen Babel project overview
Open Babel project overviewbaoilleach
 
So I have an SD File... What do I do next?
So I have an SD File... What do I do next?So I have an SD File... What do I do next?
So I have an SD File... What do I do next?baoilleach
 
Chemistrify the Web
Chemistrify the WebChemistrify the Web
Chemistrify the Webbaoilleach
 
Universal Smiles: Finally a canonical SMILES string
Universal Smiles: Finally a canonical SMILES stringUniversal Smiles: Finally a canonical SMILES string
Universal Smiles: Finally a canonical SMILES stringbaoilleach
 
What's New and Cooking in Open Babel 2.3.2
What's New and Cooking in Open Babel 2.3.2What's New and Cooking in Open Babel 2.3.2
What's New and Cooking in Open Babel 2.3.2baoilleach
 
Intro to Open Babel
Intro to Open BabelIntro to Open Babel
Intro to Open Babelbaoilleach
 
Protein-ligand docking
Protein-ligand dockingProtein-ligand docking
Protein-ligand dockingbaoilleach
 
Cheminformatics
CheminformaticsCheminformatics
Cheminformaticsbaoilleach
 
Making the most of a QM calculation
Making the most of a QM calculationMaking the most of a QM calculation
Making the most of a QM calculationbaoilleach
 
Data Analysis in QSAR
Data Analysis in QSARData Analysis in QSAR
Data Analysis in QSARbaoilleach
 
Large-scale computational design and selection of polymers for solar cells
Large-scale computational design and selection of polymers for solar cellsLarge-scale computational design and selection of polymers for solar cells
Large-scale computational design and selection of polymers for solar cellsbaoilleach
 
My Open Access papers
My Open Access papersMy Open Access papers
My Open Access papersbaoilleach
 
Improving the quality of chemical databases with community-developed tools (a...
Improving the quality of chemical databases with community-developed tools (a...Improving the quality of chemical databases with community-developed tools (a...
Improving the quality of chemical databases with community-developed tools (a...baoilleach
 
De novo design of molecular wires with optimal properties for solar energy co...
De novo design of molecular wires with optimal properties for solar energy co...De novo design of molecular wires with optimal properties for solar energy co...
De novo design of molecular wires with optimal properties for solar energy co...baoilleach
 
Density functional theory calculations on Ruthenium polypyridyl complexes inc...
Density functional theory calculations on Ruthenium polypyridyl complexes inc...Density functional theory calculations on Ruthenium polypyridyl complexes inc...
Density functional theory calculations on Ruthenium polypyridyl complexes inc...baoilleach
 
Application of Density Functional Theory to Scanning Tunneling Microscopy
Application of Density Functional Theory to Scanning Tunneling MicroscopyApplication of Density Functional Theory to Scanning Tunneling Microscopy
Application of Density Functional Theory to Scanning Tunneling Microscopybaoilleach
 
Towards Practical Molecular Devices
Towards Practical Molecular DevicesTowards Practical Molecular Devices
Towards Practical Molecular Devicesbaoilleach
 
Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...baoilleach
 
The Blue Obelisk community
The Blue Obelisk communityThe Blue Obelisk community
The Blue Obelisk communitybaoilleach
 

More from baoilleach (20)

We need to talk about Kekulization, Aromaticity and SMILES
We need to talk about Kekulization, Aromaticity and SMILESWe need to talk about Kekulization, Aromaticity and SMILES
We need to talk about Kekulization, Aromaticity and SMILES
 
Open Babel project overview
Open Babel project overviewOpen Babel project overview
Open Babel project overview
 
So I have an SD File... What do I do next?
So I have an SD File... What do I do next?So I have an SD File... What do I do next?
So I have an SD File... What do I do next?
 
Chemistrify the Web
Chemistrify the WebChemistrify the Web
Chemistrify the Web
 
Universal Smiles: Finally a canonical SMILES string
Universal Smiles: Finally a canonical SMILES stringUniversal Smiles: Finally a canonical SMILES string
Universal Smiles: Finally a canonical SMILES string
 
What's New and Cooking in Open Babel 2.3.2
What's New and Cooking in Open Babel 2.3.2What's New and Cooking in Open Babel 2.3.2
What's New and Cooking in Open Babel 2.3.2
 
Intro to Open Babel
Intro to Open BabelIntro to Open Babel
Intro to Open Babel
 
Protein-ligand docking
Protein-ligand dockingProtein-ligand docking
Protein-ligand docking
 
Cheminformatics
CheminformaticsCheminformatics
Cheminformatics
 
Making the most of a QM calculation
Making the most of a QM calculationMaking the most of a QM calculation
Making the most of a QM calculation
 
Data Analysis in QSAR
Data Analysis in QSARData Analysis in QSAR
Data Analysis in QSAR
 
Large-scale computational design and selection of polymers for solar cells
Large-scale computational design and selection of polymers for solar cellsLarge-scale computational design and selection of polymers for solar cells
Large-scale computational design and selection of polymers for solar cells
 
My Open Access papers
My Open Access papersMy Open Access papers
My Open Access papers
 
Improving the quality of chemical databases with community-developed tools (a...
Improving the quality of chemical databases with community-developed tools (a...Improving the quality of chemical databases with community-developed tools (a...
Improving the quality of chemical databases with community-developed tools (a...
 
De novo design of molecular wires with optimal properties for solar energy co...
De novo design of molecular wires with optimal properties for solar energy co...De novo design of molecular wires with optimal properties for solar energy co...
De novo design of molecular wires with optimal properties for solar energy co...
 
Density functional theory calculations on Ruthenium polypyridyl complexes inc...
Density functional theory calculations on Ruthenium polypyridyl complexes inc...Density functional theory calculations on Ruthenium polypyridyl complexes inc...
Density functional theory calculations on Ruthenium polypyridyl complexes inc...
 
Application of Density Functional Theory to Scanning Tunneling Microscopy
Application of Density Functional Theory to Scanning Tunneling MicroscopyApplication of Density Functional Theory to Scanning Tunneling Microscopy
Application of Density Functional Theory to Scanning Tunneling Microscopy
 
Towards Practical Molecular Devices
Towards Practical Molecular DevicesTowards Practical Molecular Devices
Towards Practical Molecular Devices
 
Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...Why multiple scoring functions can improve docking performance - Testing hypo...
Why multiple scoring functions can improve docking performance - Testing hypo...
 
The Blue Obelisk community
The Blue Obelisk communityThe Blue Obelisk community
The Blue Obelisk community
 

Open Babel 2.3 C++ API Quick Reference

  • 1. // Automatic format perception // Molecular formula Open Babel 2.3 std::ifstream ifs(filename); OBConversion conv; (std::string) mol.GetFormula(); C++ API OBFormat* inFormat = conv.FormatFromExt(filename); OBFormat* outFormat = conv.SetFormat("SDF"); // Conformations (int) mol.NumConformers(); if (inFormat && outFormat) Quick reference guide { conv.SetInAndOutFormats(inFormat, outFormat); // Smallest set of smallest rings (std::vector<OBRing*>) mol.GetSSSR(); } // Hydrogen manipulations (bool) mol.DeleteHydrogens(); // All H (bool) mol.AddPolarHydrogens(); // Polar H Namespace
 Looping
over
atoms
and
bonds
 (bool) mol.AddHydrogens(); // All H // Generic data using namespace OpenBabel; #include <openbabel/obiter.h> std::vector<OBGenericData*>::iterator k; #include <openbabel/mol.h> std::vector<OBGenericData*> vdata = mol.GetData(); for (k = vdata.begin(); k != vdata.end(); ++k) using namespace OpenBabel; if ((*k)->GetDataType() == OBGenericDataType::PairData) Reading
and
writing
 OBMol mol; { std::cout << "> <" << (*k)->GetAttribute(); OBAtom* atom; std::cout << ">" << std::endl; #include <openbabel/mol.h> OBAtom* nbrAtom; std::cout << ((OBPairData*)(*k))->GetValue(); #include <openbabel/obconversion.h> OBBond* bond; std::cout << std::endl; } int main(int argc, char **argv) // Looping over all atoms { double exactMass(0.0); // Remove all but the largest fragments OBMol mol; FOR_ATOMS_OF_MOL(atom, mol) (bool) mol.StripSalts(0); { // Read from standard input and write to exactMass += atom->GetExactMass(); // Clear molecule for re-use // standard output } (bool) mol.Clear(); OBConversion conv(&std::cin, &std::cout); // Looping over all bonds // Input format is sd-file, output format unsigned int totalBondOrder(0); // is canonical smiles if (conv.SetInAndOutFormats("sdf", "can")) FOR_BONDS_OF_MOL(bond, mol) { Atoms
 { totalBondOrder += bond->GetBondOrder(); if (conv.Read(&mol)) } #include <openbabel/atom.h> { // Looping over all neighbor atoms of given atom // Print number of atoms unsigned int nAtoms(0); OBAtom atom; std::cerr << "Molecule has: " << FOR_NBORS_OF_ATOM(nbrAtom, atom) ++nAtoms; mol.NumAtoms() << " atoms.n"; // Properties } (int) atom.GetFormalCharge(); conv->Write(&mol); (unsigned int) atom.GetAtomicNum(); } mol.Clear(); Element
table
 (double) atom.GetAtomicMass(); return 0; // Explicit and maximum expected connections } #include <openbabel/data.h> (unsigned int) atom.GetValence(); (unsigned int) atom.GetImplicitValence(); OBElementTable etab; // Non-hydrogen connections Conversion
 (char*) (int) etab.GetSymbol(6); etab.GetAtomicNum("C"); (unsigned int) atom.GetHvyValence(); (double) etab.GetVdwRad(7); // Implicit and explicit hydrogens #include <openbabel/obconversion.h> (double) etab.GetCovalentRad(8); (unsigned int) atom.ImplicitHydrogenCount(); #include <openbabel/mol.h> (double) etab.GetMass(1); (unsigned int) atom.ExplicitHydrogenCount(); // Create molecule from SMILES string // Is atom in ring of size 6? std::string SmilesString("c1ccccc1"); (bool) atom.IsInRing() && atom.IsInRingSize(6); OBMol mol; stringstream ss(SmilesString) Molecules
 // Size of smallest ring that contains the atom OBConversion conv(&ss); (unsigned int) atom.MemberOfRingSize(); if (conv.SetInFormat("smi") && conv.Read(&mol)) #include <openbabel/mol.h> { /* ... */ } #include <openbabel/generic.h> // Number of rings that contain the atom (unsigned int) atom.MemberOfRingCount(); // Conversion without manipulation OBMol mol; OBConversion conv(&is, &os); if (conv.SetInAndOutFormats("SMI", "MOL")) // Number of atoms and bonds { // Option "h" adds explicit hydrogens (unsigned (unsigned int) mol.NumAtoms(); // All atoms int) mol.NumHvyAtoms(); // Non-H atoms Bonds
 conv.AddOption("h", OBConversion::GENOPTIONS); (unsigned int) mol.NumBonds(); // All bonds conv.Convert(); #include <openbabel/bond.h> } // Molecular weight with implicit hydrogens #include <openbabel/atom.h> (double) mol.GetMolWt(true); 
 www.silicos.com
 www.silicos.com
 www.silicos.com

  • 2. OBBond bond; // Set calculation parameters spec.SetResolution(3.0); Energy
calculations
 // Properties spec.SetAccuracy(AngStepSize20); (unsigned int) bond.GetBondOrder(); spec.SetStereo(NoStereoSpecificProbes); #include <openbabel/forcefield.h> (bool) bond.IsPrimaryAmide(); // and 2 and 3... spec.SetNormalization(NormalizationTowardsZeroMean); #include <openbabel/mol.h> (bool) bond.IsSingle(); // and 2 and 3... (bool) bond.IsRotor(); // Calculate and print OBMol mol; std::vector<double> sphore; /* ... */ // Flanking atoms sphore = spec.GetSpectrophore(&mol); (OBAtom*) bond.GetBeginAtom(); for (int i(0); i < sphore.size(); ++i) // Select the MMFF94 forcefield (OBAtom*) bond.GetEndAtom(); { OBForceField* pFF; OBAtom* atom; (OBAtom*) bond.GetNbrAtom(atom); std::cout << sphore[i] << "t"; pFF = OBForceField::FindForceField("MMFF94"); } if (!pFF) exit(1); // Is bond in ring? std::cout << std::endl; (bool) bond.IsInRing(); // Set the logfile pFF->SetLogFile(&std::cerr); Stereochemistry
 // Assign atom types, parameters, ... Substructure
search
 pFF->Setup(mol); #include <openbabel/mol.h> // Calculate the energy #include <openbabel/parsmart.h> #include <openbabel/obconversion.h> pFF->Energy(); #include <openbabel/mol.h> #include <openbabel/stereo/tetrahedral.h> #include <openbabel/atom.h> // Perform maximum 1000 steps of minimization OBMol mol; pFF->ConjugateGradients(1000); OBMol mol; OBConversion conv; OBAtom* atom; conv.SetInFormat("smi"); /* ... */ conv.ReadString(&mol, "C[C@H](Cl)Br"); // Create a SMARTS pattern of a phenyl ring // Stereofacade object OBSmartsPattern sp; OBStereoFacade facade(&mol); Open
Babel
 sp.Init("c1ccccc1"); (unsigned int) facade.NumTetrahedralStereo(); (unsigned int) facade.NumCisTransStereo(); This documentation is part of the Open Babel project. For more information, // Properties of the substructure (unsigned int) facade.SquarePlanarStereo(); see www.openbabel.org. Open Babel is free software; you can redistribute if (sp.IsValid()) it and/or modify it under the terms of the GNU General Public License as { // Loop over all atoms to check if stereocenter published by the Free Software Foundation version 2 of the License. Open std::cout << sp.NumAtoms(); FOR_ATOMS_OF_MOL(atom, mol) Babel is distributed in the hope that it will be useful, but without any std::cout << sp.NumBonds(); { std::cout << sp.GetSmarts(); std::cout << atom->GetId() << ": "; warranty; without even the implied warranty of merchantability or fitness for } if (facade.HasTetrahedralStereo(atom->GetId())) a particular purpose. See the GNU General Public License for more details. std::cout << ": stereo"; // Matching else (bool) sp.Match(mol, true); // Single matching std::cout << ": no stereo"; Spectrophore™ (bool) sp.Match(mol, false); // Complete matching std::cout << std::endl; } Spectrophore™ is a trademark of Silicos NV and the technology is part of // Substructure mapping the Open Babel project. std::vector<std::vector<int> > mapListA; mapListA = sp.GetMapList(); // Non-unique matches std::vector<std::vector<int> > mapListU; Rings
 Silicos
NV
 mapListU = sp.GetUMapList(); // Unique matches for (int m(0); m < mapListU.size(); ++m) Silicos is a fee-for-service company empowering open source chemo- { #include <openbabel/mol.h> informatics virtual screening technologies for the discovery of novel lead std::cout << "Unique match " << m << std::endl; #include <openbabel/ring.h> compounds and database characterization. Silicos fully endorses the for (int a(0); a < mapListU[m].size(); ++a) #include <openbabel/math/vector3.h> concept of open innovation and open source software development, and { provides its clients with a wide variety of computational chemistry-based atom = mol.GetAtom(mapListU[m][a]); OBMol mol; lead discovery services, including Open Babel support, training and code std::cout << atom->GetAtomicNum() << std::endl; /* ... */ } development. Please visit www.silicos.com for more details. } // Get the smallest-set-of-smallest-rings std::vector<OBRing*> rings = mol.GetSSSR(); vector3 center; vector3 normal_up; Spectrophores™
 vector3 normal_down; for (int i(0); i < rings.size(); ++i) Copyright © 2010 Silicos NV { Silicos NV #include <openbabel/obspectrophore.h> (bool) rings[i].IsAromatic(); #include <openbabel/mol.h> (int) rings[i].Size(); Wetenschapspark 7, (bool) rings[i].findCenterAndNormal(center, B-3590 Diepenbeek OBMol mol; normal_up, Belgium /* ... */ normal_down); } www.silicos.com // Create a Spectrophore object www.openbabel.org OBSpectrophore spec; 
 www.silicos.com
 www.silicos.com