Molecule Properties¶
Molecules in OEChem TK are represented by
OEMolBases
. In addition to keeping track
of the atoms and bonds that constitute a molecule, the
OEMolBase is also used to store global information
and Generic Data about the molecule.
Read/Write Molecule Properties¶
The OEMolBase API provides the following methods for storing common global information about the molecule.
Property Name |
Type |
Get Method |
Set Method |
See Also |
---|---|---|---|---|
Coordinates |
|
|||
Dimension |
|
|||
Energy |
|
|||
Perception |
|
|||
Rxn |
|
|||
Title |
|
Title¶
The Title property is a string used to represent the name of the molecule. The default value is an empty string. This field may be used to store a registry number or other identifier, instead of a common name. The string is typically trimmed of white space by most file format readers.
The following code uses the GetTitle
method to list the names of the molecules in a file.
The input file is read and the list of identifiers
(molecule names) are written to standard-out.
Listing 1: Printing molecule titles
package openeye.docexamples.oechem;
import openeye.oechem.*;
public class GetTitle {
public static void main(String argv[]) {
OEGraphMol mol = new OEGraphMol();
oemolistream ifs = new oemolistream(argv[0]);
while (oechem.OEReadMolecule(ifs, mol))
System.out.println(mol.GetTitle());
ifs.close();
}
}
Atoms and Bonds¶
The OEMolBase API provides the following methods for accessing and altering the connection table of the molecule.
Description |
Return Type |
Method |
See Also |
---|---|---|---|
Number of Atoms |
|
||
Number of Bonds |
|
||
Maximum Atom Index |
|
||
Maximum Bond Index |
|
||
Access to an Atom |
|||
Access to a Bond |
|||
Access to all Atoms |
|||
Access to all Bonds |
|||
Create a new Atom |
|||
Create a new Bond |
|||
Remove an Atom |
|
||
Remove a Bond |
|
||
Rearrange Atoms |
|
||
Rearrange Bonds |
|
Atom and Bond Creation¶
OEChem TK contains functions that allow molecules to be constructed
from atoms and bonds explicitly. Listing 2
demonstrates how to create the water molecule.
Atoms are created by calling the OEMolBase.NewAtom
method, and bonds are created by calling the
OEMolBase.NewBond
method. NewAtom
takes the atomic
number of the atom to create and returns the new
OEAtomBase.
NewBond
takes two
OEAtomBases
and an integer bond order as
arguments and returns the new OEBondBase.
Listing 2: Creating new atoms and bonds
package openeye.docexamples.oechem;
import openeye.oechem.*;
public class CreatingAtoms {
public static void main(String argv[]) {
OEGraphMol mol = new OEGraphMol();
OEAtomBase o = mol.NewAtom(8);
OEAtomBase h1 = mol.NewAtom(1);
OEAtomBase h2 = mol.NewAtom(1);
OEBondBase b1 = mol.NewBond(o,h1,1);
OEBondBase b2 = mol.NewBond(o,h2,1);
}
}
In Listing 2
the atomic numbers of oxygen, 8,
and hydrogen, 1, are explicitly encoded in the program. To make code
easier to read and less error prone, OEChem TK provides symbolic
constants for the first 109 elements in the
OEElemNo
namespace. The
OEElemNo
namespace defines the atomic symbols
with the appropriate atomic number.
Listing 3: Using OEElemNo namespace
package openeye.docexamples.oechem;
import openeye.oechem.*;
public class CreatingAtoms2 {
public static void main(String argv[]) {
OEGraphMol mol = new OEGraphMol();
OEAtomBase o = mol.NewAtom(OEElemNo.O);
OEAtomBase h1 = mol.NewAtom(OEElemNo.H);
OEAtomBase h2 = mol.NewAtom(OEElemNo.H);
OEBondBase b1 = mol.NewBond(o,h1,1);
OEBondBase b2 = mol.NewBond(o,h2,1);
}
}
Note
The atoms and bonds of a molecule are automatically deleted when their parent molecule is destroyed.
Attach Generic Data to Molecules¶
Generic data can be attached to any object that derives from the OEBase class. The following two snippets demonstrate how generic data (e.g. molecule weight) can be attached to a molecule:
int tag = oechem.OEGetTag("MolWeight");
mol.SetDoubleData(tag, oechem.OECalculateMolecularWeight(mol));
mol.SetDoubleData("MolWeight", oechem.OECalculateMolecularWeight(mol));
After annotation, the data can be accessed with the same integer or character string identifier:
tag = oechem.OEGetTag("MolWeight");
System.out.println(mol.GetDoubleData(tag));
System.out.println(mol.GetDoubleData("MolWeight"));
The OEMolBase API provides the following methods, publicly inherited from OEBase, that allow the manipulation of generic data.
Method |
Description |
---|---|
sets a generic data associating it with the given tag |
|
adds a generic data associating it with the given tag |
|
determines whether a molecule has any generic data with a given tag |
|
returns the generic data associated with the given tag |
|
deletes all generic data with the given tag |
|
clears all stored generic data |
Note
Generic data attached to a molecule or any of its atoms or bonds is automatically
saved when the molecule is written into an .oeb
file.
See also
Attaching other objects section
SD Tagged Data Manipulation section
PDB Tagged Data Manipulation section
For using tag data with multi-conformer molecules, see Dude, where’s my SD data?