chemaxon.struc.sgroup
Class SuperatomSgroup

java.lang.Object
  extended by chemaxon.struc.Sgroup
      extended by chemaxon.struc.sgroup.SuperatomSgroup
All Implemented Interfaces:
chemaxon.struc.AbbreviationForBuilder<java.lang.Integer>, chemaxon.struc.MoleculeForBuilder, Expandable, java.io.Serializable

public class SuperatomSgroup
extends Sgroup
implements Expandable, chemaxon.struc.AbbreviationForBuilder<java.lang.Integer>

Superatom S-group.

Since:
Marvin 3.0, 11/05/2002
Version:
5.3, 09/13/2009
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
 
Fields inherited from class chemaxon.struc.Sgroup
brackets, CHARGE_ON_ATOMS, CHARGE_ON_GROUP, parentSgroup, PR_ATSYMS, RA_IN_EXPAND, RA_REMOVE_EXCEPT_RU, SCN_EITHER_UNKNOWN, SCN_HEAD_TO_HEAD, SCN_HEAD_TO_TAIL, SGROUP_TYPE_COUNT, sgroupGraph, sgroupType, SORT_CHILD_PARENT, SORT_PARENT_CHILD, SST_ALTERNATING, SST_BLOCK, SST_RANDOM, ST_ANY, ST_COMPONENT, ST_COPOLYMER, ST_CROSSLINK, ST_DATA, ST_FORMULATION, ST_GENERIC, ST_GRAFT, ST_MER, ST_MIXTURE, ST_MODIFICATION, ST_MONOMER, ST_MULTICENTER, ST_MULTIPLE, ST_SRU, ST_SUPERATOM, XSTATE_C, XSTATE_NONE, XSTATE_X, XSTATE_XC
 
Fields inherited from interface chemaxon.struc.sgroup.Expandable
COORDS_UPDATE, DEFAULT_OPTIONS, FAST_COORDS, MDL_EXPAND, NONRECURSIVE_EXPAND, REVERSIBLE_EXPAND
 
Constructor Summary
  SuperatomSgroup(Molecule parent)
          Constructs a superatom S-group in expanded state.
  SuperatomSgroup(Molecule parent, boolean expanded)
          Constructs a superatom S-group.
protected SuperatomSgroup(SuperatomSgroup sg, Molecule m, Sgroup psg, int[] atomIndexMap)
          Copy constructor.
 
Method Summary
protected  void addAttachAtom(MolAtom a)
          Adds an atom to the list of attachments.
 boolean areChildSgroupsVisible()
          Checks whether the child S-groups are visible.
 void calculateAttachmentPoints()
          Sets the attachment points on an S-group where the S-group has crossing bonds.
protected  Sgroup cloneSgroup(Molecule m, Sgroup psg, int[] atomIndexMap)
          Gets a new Sgroup instance.
 boolean contract(int opts)
          Contracts this S-group.
 Molecule createMolecule()
          Creates a molecule object that contains only this group.
 boolean expand(int opts)
          Expands this S-group.
 boolean expandOther(int opts, Molecule moltoexpand)
          Expands sgtoexpand S-group the same way as it would be this.
 MolAtom findAttachAtom()
          Gets the most likely attachment point.
 MolBond[] findCrossingBonds()
          Finds the crossing bonds.
 MolAtom[] getAttachAtoms()
          Gets the attachment points.
 java.lang.Integer getConnectionAtom(int connectionIndex)
           
 MolAtom[] getCrossingAtoms(MolBond[] xbonds)
          Gets the atoms from the S-group that have crossing bonds.
 int getExternalConnections(MolAtom a)
          Gets the number of bonds of a specified atom where the neighbor doesn't belong to the S-group.
 MolAtom[] getFreeLegalAttachAtoms()
          Gets the unused legal attachment points.
 MolAtom[] getLegalAttachAtoms()
          Gets the legal attachment points.
 SelectionMolecule getParentSgroupGraph()
          Gets the parent exact sgroupgraph.
 SelectionMolecule getSgroupGraph()
          Gets the molecule graph as a selection.
 SgroupAtom getSuperAtom()
          Gets the superatom.
 boolean hasAtom(MolAtom a)
          Is the specified atom an element of this group?
 boolean hasBrackets()
          Checks if brackets should be painted or not.
 boolean isBracketVisible()
          Tests whether the bracket is visible.
 boolean isContracted()
          Decides whether this S-group is contracted or not.
 boolean isExpanded()
          Is this S-group expanded?
 boolean isFreeLegalAttachAtom(MolAtom a)
          Tests whether the specified atom is a legal attachment point with a free valence.
 boolean isLegalAttachment(MolAtom a)
          Tests whether the specified atom is attached to a legal attachment point.
 boolean isTotalSelected(MoleculeGraph sel)
          Decides if the whole superatom sgroup is selected or not.
protected  void removeAtom(MolAtom a, int opts)
          Removes an atom from the S-group.
 void removeBond(MolBond b)
          Removes a bond from the S-group.
 void replaceAtom(MolAtom olda, MolAtom newa, int opts)
          Replace an existing atom by a new one.
 void setAtom(int i, MolAtom a)
          Sets the specified atom in the S-group graph.
 boolean setGUIStateRecursively(boolean v)
          Sets the expanded/contracted state recursively.
 void setNextConnectionAtom(int atomIndex)
           
 void setSgroupGraph(SelectionMolecule smol)
          Sets the molecule graph.
 void sortXBonds()
          Sorts the crossing bonds in the parent molecule in attachment point number order.
 java.lang.String toString(int opts)
          Returns a string representation of the group.
protected  void transformByParent(CTransform3D t, boolean incg)
          Applies a transformation matrix to the Sgroup coordinates.
 void updateAttachmentPoints()
          Adjusts attachment point information to current bonding.
 MolBond[] updateSgroupCrossings()
          Deprecated. as of Marvin 3.3, replaced by Sgroup.findCrossingBonds()
 
Methods inherited from class chemaxon.struc.Sgroup
add, add, addBracket, addChildSgroup, clearObjects, cloneSgroup, cloneStructure, containsAllAtomsOf, countAllAtoms, createMolecule, findSmallestSgroupContaining, findSmallestSgroupOf, getAtom, getAtomArray, getAtomCount, getAtomSymbolListAsString, getBracketCount, getBrackets, getChargeLocation, getChildSgroup, getChildSgroupCount, getConnectivity, getParentMolecule, getParentSgroup, getSubscript, getSubType, getSuperscript, getTotalCharge, getType, getXState, indexOf, indexOf, initBrackets, isBracketCrossingBond, isDescendantOf, isEmpty, isOrderedComponentSgroup, isPartSelected, isRemovable, isSelected, isVisible, removeAtom, removeAtom, removeBonds, removeChildSgroup, removeGroupedAtom, removeObject, replaceAtom, selectAllObjects, setChargeLocation, setConnectivity, setGUIStateRecursively, setParentMolecule, setSubscript, setSubType, setXState, setXState, setXState0, sort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SuperatomSgroup

public SuperatomSgroup(Molecule parent)
Constructs a superatom S-group in expanded state. Its superatom is automatically created.

Parameters:
parent - the parent molecule
Since:
Marvin 3.5.3, 01/18/2005
See Also:
Sgroup.ST_SUPERATOM, MolAtom.SGROUP, getSuperAtom()

SuperatomSgroup

public SuperatomSgroup(Molecule parent,
                       boolean expanded)
Constructs a superatom S-group. Its superatom is automatically created.

Parameters:
parent - the parent molecule
expanded - whether the S-group is created in expanded state or not
See Also:
Sgroup.ST_SUPERATOM, MolAtom.SGROUP, getSuperAtom()

SuperatomSgroup

protected SuperatomSgroup(SuperatomSgroup sg,
                          Molecule m,
                          Sgroup psg,
                          int[] atomIndexMap)
Copy constructor.

Parameters:
sg - the S-group to copy
m - the new parent molecule
psg - the new parent S-group or null
atomIndexMap - indices of cloned atoms in the original molecule or null
Since:
Marvin 5.0.2, 03/07/2008
Method Detail

getSuperAtom

public final SgroupAtom getSuperAtom()
Gets the superatom.

Returns:
the superatom

getAttachAtoms

public final MolAtom[] getAttachAtoms()
Gets the attachment points. This method should only be called when the residue is in contracted state.

Returns:
the attachment atoms
Since:
Marvin 4.0.4, 01/09/2006

updateAttachmentPoints

public void updateAttachmentPoints()
Adjusts attachment point information to current bonding.


getSgroupGraph

public SelectionMolecule getSgroupGraph()
Gets the molecule graph as a selection. The nodes are ordered, the first n are the attachment atoms.

Overrides:
getSgroupGraph in class Sgroup
Returns:
the molecule graph
Since:
Marvin 3.3, 11/04/2003

getParentSgroupGraph

public SelectionMolecule getParentSgroupGraph()
Gets the parent exact sgroupgraph. Internal use only.

Returns:
the sgroupGraph

setSgroupGraph

public void setSgroupGraph(SelectionMolecule smol)
Sets the molecule graph. If the S-group is in contracted state then:

Overrides:
setSgroupGraph in class Sgroup
Parameters:
smol - the molecule graph
Since:
Marvin 3.3, 11/04/2003

cloneSgroup

protected Sgroup cloneSgroup(Molecule m,
                             Sgroup psg,
                             int[] atomIndexMap)
Gets a new Sgroup instance.

Overrides:
cloneSgroup in class Sgroup
Parameters:
m - the new parent molecule
psg - the new parent S-group
atomIndexMap - indices of cloned atoms in the original molecule or null
Returns:
the new object
Since:
5.0.2, 03/07/2008

setAtom

public final void setAtom(int i,
                          MolAtom a)
Sets the specified atom in the S-group graph.

Overrides:
setAtom in class Sgroup
Parameters:
i - the index
a - the atom

removeAtom

protected final void removeAtom(MolAtom a,
                                int opts)
Removes an atom from the S-group.

Overrides:
removeAtom in class Sgroup
Parameters:
a - the atom
opts - unused argument

removeBond

public final void removeBond(MolBond b)
Removes a bond from the S-group.

Overrides:
removeBond in class Sgroup
Parameters:
b - the bond

findCrossingBonds

public MolBond[] findCrossingBonds()
Finds the crossing bonds. Use only when the S-group is expanded.

Overrides:
findCrossingBonds in class Sgroup
Returns:
the attachment bonds
Since:
Marvin 3.3

getCrossingAtoms

public MolAtom[] getCrossingAtoms(MolBond[] xbonds)
Gets the atoms from the S-group that have crossing bonds.

Overrides:
getCrossingAtoms in class Sgroup
Parameters:
xbonds - the crossing bonds
Returns:
the attachment atoms
Since:
Marvin 3.3
See Also:
findCrossingBonds()

findAttachAtom

public MolAtom findAttachAtom()
Gets the most likely attachment point.

Returns:
the most likely attachment point
Since:
Marvin 4.1, 03/08/2006

transformByParent

protected void transformByParent(CTransform3D t,
                                 boolean incg)
Applies a transformation matrix to the Sgroup coordinates. (Only absolute placement.) This method is called by the parent molecule's Molecule.transform(CTransform3D, boolean) method, thus only those atom coordinates are transformed here that are not handled in MoleculeGraph.transform(CTransform3D, boolean).

Overrides:
transformByParent in class Sgroup
Parameters:
t - the transformation matrix
incg - graph invariants are changed (true) or not (false)
Since:
Marvin 5.0, 08/18/2007

hasBrackets

public boolean hasBrackets()
Checks if brackets should be painted or not.

Overrides:
hasBrackets in class Sgroup
Returns:
true if the group is in expanded state
Since:
Marvin 3.3

hasAtom

public boolean hasAtom(MolAtom a)
Is the specified atom an element of this group?

Overrides:
hasAtom in class Sgroup
Parameters:
a - the atom
Returns:
true if it contains the atom, false otherwise
Since:
Marvin 3.4

expand

public final boolean expand(int opts)
                     throws java.lang.IllegalArgumentException
Expands this S-group. Atom indexes are preserved during expansion.

Specified by:
expand in interface Expandable
Overrides:
expand in class Sgroup
Parameters:
opts - expansion options
Returns:
true if the operation was successful, false if already expanded
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)
See Also:
Expandable.DEFAULT_OPTIONS, Expandable.COORDS_UPDATE, Expandable.REVERSIBLE_EXPAND, Expandable.MDL_EXPAND, Expandable.FAST_COORDS, Expandable.NONRECURSIVE_EXPAND

expandOther

public final boolean expandOther(int opts,
                                 Molecule moltoexpand)
                          throws java.lang.IllegalArgumentException
Expands sgtoexpand S-group the same way as it would be this. Atom indexes are preserved during expansion.

Parameters:
opts - expansion options
moltoexpand - molecule containing an Sgroup that has to be expanded
Returns:
true if the operation was successful, false if already expanded
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)

isExpanded

public final boolean isExpanded()
Is this S-group expanded?

Specified by:
isExpanded in interface Expandable
Returns:
true if expanded, false if contracted

contract

public final boolean contract(int opts)
                       throws java.lang.IllegalArgumentException
Contracts this S-group.

Specified by:
contract in interface Expandable
Overrides:
contract in class Sgroup
Parameters:
opts - contraction options
Returns:
true if the operation was successful, false if already contracted
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)
See Also:
Expandable.NONRECURSIVE_EXPAND, Sgroup.RA_REMOVE_EXCEPT_RU, Expandable.REVERSIBLE_EXPAND

isContracted

public final boolean isContracted()
Decides whether this S-group is contracted or not.

Returns:
true if contracted false otherwise

isBracketVisible

public boolean isBracketVisible()
Tests whether the bracket is visible.

Overrides:
isBracketVisible in class Sgroup
Returns:
false, superatom S-group brackets are not visible
Since:
Marvin 3.5.1, 11/12/2004

isTotalSelected

public boolean isTotalSelected(MoleculeGraph sel)
Decides if the whole superatom sgroup is selected or not. Overrides method in parent class.

Overrides:
isTotalSelected in class Sgroup
Parameters:
sel - molecule graph that contains the selection
Returns:
true if the whole superatom group is selected

areChildSgroupsVisible

public boolean areChildSgroupsVisible()
Checks whether the child S-groups are visible.

Overrides:
areChildSgroupsVisible in class Sgroup
Returns:
true if children are visible, false otherwise
Since:
Marvin 3.4

getLegalAttachAtoms

public final MolAtom[] getLegalAttachAtoms()
Gets the legal attachment points.

Returns:
array of attachment points

sortXBonds

public void sortXBonds()
Sorts the crossing bonds in the parent molecule in attachment point number order.

Since:
Marvin 5.0, 12/07/2007

isLegalAttachment

public final boolean isLegalAttachment(MolAtom a)
Tests whether the specified atom is attached to a legal attachment point.

Parameters:
a - the atom
Returns:
true if it is attached to a legal attachment point, false otherwise
Since:
3.5, 11/04/2004

isFreeLegalAttachAtom

public final boolean isFreeLegalAttachAtom(MolAtom a)
Tests whether the specified atom is a legal attachment point with a free valence.

Parameters:
a - the atom
Returns:
true if there is a free valence, false otherwise
Since:
5.0, 09/23/2007

getExternalConnections

public int getExternalConnections(MolAtom a)
Gets the number of bonds of a specified atom where the neighbor doesn't belong to the S-group.

Parameters:
a - the atom whose connections to be checked
Returns:
the number of external connection or 0 if the specified atom doesn't belong to the S-group.

getFreeLegalAttachAtoms

public final MolAtom[] getFreeLegalAttachAtoms()
Gets the unused legal attachment points.

Returns:
array of attachment points

createMolecule

public Molecule createMolecule()
Creates a molecule object that contains only this group.

Overrides:
createMolecule in class Sgroup
Returns:
the molecule
Since:
Marvin 3.4

addAttachAtom

protected void addAttachAtom(MolAtom a)
Adds an atom to the list of attachments.

Parameters:
a - the atom

replaceAtom

public final void replaceAtom(MolAtom olda,
                              MolAtom newa,
                              int opts)
Replace an existing atom by a new one.

Overrides:
replaceAtom in class Sgroup
Parameters:
olda - the original atom
newa - the new atom
opts - options
Since:
4.1, 07/25/2006
See Also:
Sgroup.RA_REMOVE_EXCEPT_RU

updateSgroupCrossings

public final MolBond[] updateSgroupCrossings()
Deprecated. as of Marvin 3.3, replaced by Sgroup.findCrossingBonds()

Generates the attachment atoms. Use only when the S-group is expanded.

Returns:
the attachment bonds

toString

public java.lang.String toString(int opts)
Returns a string representation of the group.

Overrides:
toString in class Sgroup
Parameters:
opts - options or 0
Returns:
the string representation
Since:
Marvin 4.1, 07/26/2006
See Also:
Sgroup.PR_ATSYMS

setGUIStateRecursively

public final boolean setGUIStateRecursively(boolean v)
                                     throws java.lang.IllegalArgumentException
Sets the expanded/contracted state recursively.

Overrides:
setGUIStateRecursively in class Sgroup
Parameters:
v - true sets Sgroup.XSTATE_C if previous state was Sgroup.XSTATE_XC, false sets Sgroup.XSTATE_XC if previous state was Sgroup.XSTATE_C, no operation in other cases
Returns:
true if at least one S-group's state was changed, false otherwise
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)
Since:
Marvin 5.1
See Also:
Sgroup.setXState(int)

calculateAttachmentPoints

public void calculateAttachmentPoints()
Sets the attachment points on an S-group where the S-group has crossing bonds.

Throws:
java.lang.UnsupportedOperationException - for S-groups with more than 2 crossing bonds

setNextConnectionAtom

public void setNextConnectionAtom(int atomIndex)

getConnectionAtom

public java.lang.Integer getConnectionAtom(int connectionIndex)
Specified by:
getConnectionAtom in interface chemaxon.struc.AbbreviationForBuilder<java.lang.Integer>