chemaxon.marvin.util
Class CleanUtil

java.lang.Object
  extended by chemaxon.marvin.util.CleanUtil
All Implemented Interfaces:
HybridizationStateConsts

public class CleanUtil
extends java.lang.Object
implements HybridizationStateConsts

Utility methods for cleaning.

Since:
Marvin 4.1, 01/31/2006
Version:
5.3, 04/27/2009
Author:
Peter Csizmadia, Andras Volford

Field Summary
 
Fields inherited from interface chemaxon.struc.HybridizationStateConsts
HS_S, HS_SP, HS_SP2, HS_SP3, HS_UNKNOWN
 
Constructor Summary
CleanUtil()
           
 
Method Summary
static boolean arrangeComponents(MoleculeGraph mol)
          Arranges molecule components (reactants, agents, products, R-group definitions) nicely.
static boolean arrangeComponents(MoleculeGraph mol, boolean obj)
          Arranges molecule components (reactants, agents, products, R-group definitions, data, brackets) nicely.
static boolean arrangeComponents(MoleculeGraph mol, boolean obj, boolean frags)
          Arranges molecule components (reactants, agents, products, R-group definitions, data, brackets) nicely.
static void arrangeDataSgroupData(MoleculeGraph m)
          Arrange data attached to DataSgroup.
static void arrangeMolecules(MoleculeGraph[] mo, int dist, int col)
          Arrange molecules nicely If we have more molecules try to arrange them in a 2D square lattice.
static void arrangeReaction(RxnMolecule m)
          Arranges reaction components nicely
static void arrangeRelativeDataSgroupData(MoleculeGraph m)
          Arrange data attached to DataSgroup.
static void arrangeSgBrackets(MoleculeGraph m)
          Arrange sgroup brackets in the molecule.
static double calcBadness(MoleculeGraph mol1, MoleculeGraph mol2, MolAtom sa, MolBond[] xbonds)
          Calculates a "badness" value for the atomic coordinates.
static DPoint3[] calcBracketEndPoints(DPoint3[] q, DPoint3 p1, double c)
          Calculates the bracket endpoints from the base line of the bracket.
static DPoint3 calcDividingPoint(DPoint3 p1, DPoint3 p2, double k)
          Calculates the division point of a segment with a given ratio.
static DPoint3[] calcSimplePolymerBracket(DPoint3 p1, DPoint3 p2, double ratio)
          Calculates the points of a simple polymer bracket that belongs to a bond.
static void createBracket(Sgroup sg, DPoint3[] q, int btype)
           
static CTransform3D createRotationAboutBond(MolBond b, double phi)
          Creates a rotation transformation about a bond.
static double[] createSavedCoordsArray(MoleculeGraph g)
          Creates an empty array for the atomic coordinates of a structure.
static void generateBracketCoords(Sgroup sg, int btype)
          Generates brackets with coordinates for a specified S-group.
static void generateBracketCoords(Sgroup sg, int btype, boolean extraSpace)
          Generates brackets with coordinates for a specified S-group.
static boolean hasWiggly(MolAtom a)
          Check if at least one wiggly bond starts from this atom.
static boolean[] isNonPreferredStereoAtom(MoleculeGraph m)
          Check if the atoms in the molecule is in SP2 hybridization state and has wedge whose getAtom1 is the specified atom, but wiggly bonds next to double bonds are allowed.
static boolean removeCTflagFromSmallRings(MoleculeGraph m)
          Remove CIS|TRANS flag from bonds in rings smaller than size 8.
static void restoreCoords(MoleculeGraph g, double[] coords)
          Restores atomic coordinates.
static void saveCoords(MoleculeGraph g, double[] coords)
          Saves atomic coordinates.
static void setBestLigandPosition(MolAtom atom, MolAtom ligand)
          Calculates and sets an optimal position for a ligand atom.
static void setBestLigandPosition(MolAtom atom, MolAtom ligand, double bondlength)
          Calculates and sets an optimal position for a ligand atom.
static void setCTCrossedBond(MoleculeGraph m)
          Convert wiggly type double bonds to crossed.
static boolean setCTWigglyBond(MoleculeGraph m)
          Convert crossed double bonds to wiggly type.
static boolean setCTWigglyBond(MoleculeGraph m, int bond)
          Set wiggly bond to the endpoint of the given double bond.
static double sumDistanceSquare(MoleculeGraph mol, DPoint3 p)
          Calculates the sum of the distance square for each atom from a point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CleanUtil

public CleanUtil()
Method Detail

arrangeComponents

public static boolean arrangeComponents(MoleculeGraph mol)
Arranges molecule components (reactants, agents, products, R-group definitions) nicely. Also arranges attached data, Sgroup brackets.

Parameters:
mol - the molecule
Returns:
true if components have been rearranged, false if no components found

arrangeComponents

public static boolean arrangeComponents(MoleculeGraph mol,
                                        boolean obj)
Arranges molecule components (reactants, agents, products, R-group definitions, data, brackets) nicely.

Parameters:
mol - the molecule
obj - also arrange other object attached to the molecule (like data, brackets)
Returns:
true if components have been rearranged, false if no components found

arrangeComponents

public static boolean arrangeComponents(MoleculeGraph mol,
                                        boolean obj,
                                        boolean frags)
Arranges molecule components (reactants, agents, products, R-group definitions, data, brackets) nicely.

Parameters:
mol - the molecule
obj - also arrange other object attached to the molecule (like data, brackets)
frags - also arrange fragments in root / main molecule
Returns:
true if components have been rearranged, false if no components found
Since:
Marvin 5.4.1

arrangeReaction

public static void arrangeReaction(RxnMolecule m)
Arranges reaction components nicely

Parameters:
m - the reaction molecule

arrangeMolecules

public static void arrangeMolecules(MoleculeGraph[] mo,
                                    int dist,
                                    int col)
Arrange molecules nicely If we have more molecules try to arrange them in a 2D square lattice. Also arrange the DataSgroup values close to the atoms if relative arrangement needed.

Parameters:
mo - molecules
dist - use CCLENGTH distance for the molecules
col - number of colums (if -1 calculate it)

arrangeDataSgroupData

public static void arrangeDataSgroupData(MoleculeGraph m)
Arrange data attached to DataSgroup. Set it to the right down corner.


arrangeRelativeDataSgroupData

public static void arrangeRelativeDataSgroupData(MoleculeGraph m)
Arrange data attached to DataSgroup. Keeps the position of the data label if it is relative.

Parameters:
m - molecule

arrangeSgBrackets

public static void arrangeSgBrackets(MoleculeGraph m)
Arrange sgroup brackets in the molecule.

Parameters:
m - molecule

sumDistanceSquare

public static double sumDistanceSquare(MoleculeGraph mol,
                                       DPoint3 p)
Calculates the sum of the distance square for each atom from a point.

Parameters:
mol - the molecule
p - the point

calcBadness

public static double calcBadness(MoleculeGraph mol1,
                                 MoleculeGraph mol2,
                                 MolAtom sa,
                                 MolBond[] xbonds)
Calculates a "badness" value for the atomic coordinates.

Parameters:
mol1 - the original molecule
mol2 - the transformed substructure
sa - additional transformed atom or null
xbonds - additional bonds between mol1 and mol2, or null
Returns:
the badness

createSavedCoordsArray

public static double[] createSavedCoordsArray(MoleculeGraph g)
Creates an empty array for the atomic coordinates of a structure.

Parameters:
g - the structure

saveCoords

public static void saveCoords(MoleculeGraph g,
                              double[] coords)
Saves atomic coordinates. This method can be called before trying a coordinate transformation.

Parameters:
g - the structure
coords - array for the coordinates

restoreCoords

public static void restoreCoords(MoleculeGraph g,
                                 double[] coords)
Restores atomic coordinates. This method can be called after trying a coordinate transformation.

Parameters:
g - the structure
coords - array containing the coordinates

createRotationAboutBond

public static CTransform3D createRotationAboutBond(MolBond b,
                                                   double phi)
Creates a rotation transformation about a bond.

Parameters:
b - the bond
phi - rotation angle

setCTWigglyBond

public static boolean setCTWigglyBond(MoleculeGraph m)
Convert crossed double bonds to wiggly type.

Parameters:
m - molecule

setCTWigglyBond

public static boolean setCTWigglyBond(MoleculeGraph m,
                                      int bond)
Set wiggly bond to the endpoint of the given double bond.

Parameters:
m - a molecule that contains a double bond to convert it to a wiggly represented up-o-down stereo double bond
bond - the index of the double bond to
Returns:
true if the wiggly representation could be set successfully
Since:
Marvin 5.2

hasWiggly

public static boolean hasWiggly(MolAtom a)
Check if at least one wiggly bond starts from this atom. (The which first atom of the bond should be the given atom.)

Parameters:
a - atom
Returns:
true if has wiggly bond starting from this atom

setCTCrossedBond

public static void setCTCrossedBond(MoleculeGraph m)
Convert wiggly type double bonds to crossed.

Parameters:
m - molecule

isNonPreferredStereoAtom

public static boolean[] isNonPreferredStereoAtom(MoleculeGraph m)
Check if the atoms in the molecule is in SP2 hybridization state and has wedge whose getAtom1 is the specified atom, but wiggly bonds next to double bonds are allowed.

Parameters:
m - molecule
Returns:
true for SP2 atom which has wedge with narrow end else false.
Since:
Marvin 5.0

removeCTflagFromSmallRings

public static boolean removeCTflagFromSmallRings(MoleculeGraph m)
Remove CIS|TRANS flag from bonds in rings smaller than size 8. Remove TRANS flag from bonds in rings smaller than size 8, but give warning. Suppose that the stereo info stored already in the flags.

Parameters:
m - molecule
Returns:
false if TRANS stereoinformation is removed, otherwise true.

setBestLigandPosition

public static void setBestLigandPosition(MolAtom atom,
                                         MolAtom ligand)
Calculates and sets an optimal position for a ligand atom.

Parameters:
atom - the atom whose ligand atom's position is calculated
ligand - the ligand atom whoose optimal position is calculated
Since:
Marvin 5.4

setBestLigandPosition

public static void setBestLigandPosition(MolAtom atom,
                                         MolAtom ligand,
                                         double bondlength)
Calculates and sets an optimal position for a ligand atom.

Parameters:
atom - the atom whose ligand atom's position is calculated
ligand - the ligand atom whoose optimal position is calculated
bondlength - the requested bond length between the atom and its ligand, use -1 for automatic bond length determination according atom types.
Since:
Marvin 5.4

calcBracketEndPoints

public static DPoint3[] calcBracketEndPoints(DPoint3[] q,
                                             DPoint3 p1,
                                             double c)
Calculates the bracket endpoints from the base line of the bracket. Another point is neccessary to calculate in the plane where the end points will be.

Parameters:
q - endpoints of the base line in the bracket.
p1 - point to fix the plane in which the bracket endpoints will be.
c - expected length of the bracket internal segment
Returns:
bracket endpoints.

calcDividingPoint

public static DPoint3 calcDividingPoint(DPoint3 p1,
                                        DPoint3 p2,
                                        double k)
Calculates the division point of a segment with a given ratio.

Parameters:
p1 - the first endpoint of the segment
p2 - the second endpoint of the segment
k - the ratio
Returns:
the division point

calcSimplePolymerBracket

public static DPoint3[] calcSimplePolymerBracket(DPoint3 p1,
                                                 DPoint3 p2,
                                                 double ratio)
Calculates the points of a simple polymer bracket that belongs to a bond.

Parameters:
p1 - endpoint of the bond that belongs to the sgroup
p2 - the other endpoint of the bond
Returns:
bracket points
See Also:
RepeatingUnitSgroup

createBracket

public static void createBracket(Sgroup sg,
                                 DPoint3[] q,
                                 int btype)

generateBracketCoords

public static void generateBracketCoords(Sgroup sg,
                                         int btype)
Generates brackets with coordinates for a specified S-group.

Parameters:
sg - the S-group to generate the brackets and coordinates for
btype - the type of the brackets to generate
See Also:
MBracket.T_ROUND, MBracket.T_SQUARE

generateBracketCoords

public static void generateBracketCoords(Sgroup sg,
                                         int btype,
                                         boolean extraSpace)
Generates brackets with coordinates for a specified S-group.

Parameters:
sg - the S-group to generate the brackets and coordinates for
btype - the type of the brackets to generate
extraSpace - calculate with extra space at atom labels
See Also:
MBracket.T_ROUND, MBracket.T_SQUARE