net.guha.util.cdk
Class Misc

java.lang.Object
  extended by net.guha.util.cdk.Misc

public class Misc
extends java.lang.Object

Miscellaneous utility methods.

Author:
Rajarshi Guha

Field Summary
static java.lang.String VERSION
          Version of this library.
 
Constructor Summary
Misc()
           
 
Method Summary
static org.openscience.cdk.interfaces.IMolecule get2DCoords(org.openscience.cdk.interfaces.IAtomContainer mol)
          Get a molecule with 2D coordinates.
static org.openscience.cdk.interfaces.IAtomContainer getNeedle(org.openscience.cdk.interfaces.IAtomContainer target, java.lang.String pattern)
          Get the substructure of a target structure based on a SMARTS pattern.
static org.openscience.cdk.interfaces.IAtomContainer[] loadMolecules(java.lang.String[] filenames)
          Loads one or more files into IAtomContainer objects.
static void writeMolecules(org.openscience.cdk.interfaces.IAtomContainer[] molecules, java.lang.String prefix, int writeProps)
          Write molecules to individual files.
static void writeMoleculesInOneFile(org.openscience.cdk.interfaces.IAtomContainer[] molecules, java.lang.String filename, int writeProps)
          Write multiple molecules to a single SD file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version of this library.

See Also:
Constant Field Values
Constructor Detail

Misc

public Misc()
Method Detail

writeMoleculesInOneFile

public static void writeMoleculesInOneFile(org.openscience.cdk.interfaces.IAtomContainer[] molecules,
                                           java.lang.String filename,
                                           int writeProps)
                                    throws java.lang.Exception
Write multiple molecules to a single SD file.

Parameters:
molecules - An array of molecules
filename - The filename to write to
writeProps - If true, properties will be added as SD tags
Throws:
java.lang.Exception - if there is an error during writing

writeMolecules

public static void writeMolecules(org.openscience.cdk.interfaces.IAtomContainer[] molecules,
                                  java.lang.String prefix,
                                  int writeProps)
                           throws java.lang.Exception
Write molecules to individual files.

Parameters:
molecules - An array of molecules
prefix - The prefix for the individual files. By default this will be mol
writeProps - If true properties will be written as SD tags
Throws:
java.lang.Exception - if there is an error during writing

loadMolecules

public static org.openscience.cdk.interfaces.IAtomContainer[] loadMolecules(java.lang.String[] filenames)
                                                                     throws org.openscience.cdk.exception.CDKException
Loads one or more files into IAtomContainer objects.

This method does not need knowledge of the format since it is autodetected.

NOTE It does not perform aromaticity detection

Parameters:
filenames - An array of String's containing the filenames of the structures we want to load
Returns:
An array of AtoContainer's
Throws:
org.openscience.cdk.exception.CDKException - if there is an error when reading a file

get2DCoords

public static org.openscience.cdk.interfaces.IMolecule get2DCoords(org.openscience.cdk.interfaces.IAtomContainer mol)
                                                            throws java.lang.Exception
Get a molecule with 2D coordinates.

Parameters:
mol - the input molecule
Returns:
a new molecule with 2D coordinates
Throws:
java.lang.Exception - if there was an error generating coordinates

getNeedle

public static org.openscience.cdk.interfaces.IAtomContainer getNeedle(org.openscience.cdk.interfaces.IAtomContainer target,
                                                                      java.lang.String pattern)
                                                               throws org.openscience.cdk.exception.CDKException
Get the substructure of a target structure based on a SMARTS pattern.

Parameters:
target - The target molecule
pattern - The SMARTS pattern for the substructure. The string can be a plain SMARTS or a Base64 encoded string
Returns:
A fragment representing the fragmentif present, null otherwise
Throws:
org.openscience.cdk.exception.CDKException - if there is an error during SMARTS parsing or matching