Class Molecule

All Implemented Interfaces:
MoleculeWithValence<MolAtom>, chemaxon.core.structure.MoleculeForBuilder, chemaxon.struc.MObjectContainer, MTransformable, StereoConstants, Serializable
Direct Known Subclasses:
RgMolecule, RxnMolecule

@PublicApi public class Molecule extends MoleculeGraph implements chemaxon.struc.MObjectContainer
Molecule class. A MoleculeGraph that may also contain S-groups.
See Also:
  • Field Details

    • RMCLEANUP_SGROUPATOMS

      public static final int RMCLEANUP_SGROUPATOMS
      Remove S-groups of removed superatoms.
      Since:
      Marvin 4.1, 07/27/2006
      See Also:
    • RMCLEANUP_FROMSGROUPS

      public static final int RMCLEANUP_FROMSGROUPS
      Remove atoms from S-groups. The S-groups, which contain the atoms, are not removed from the molecule. The S-group removal is performed automatically only when all represented atoms were deleted from the S-group graph and the S-group graph is empty.
      Since:
      Marvin 4.1, 07/27/2006
      See Also:
    • RMSG_DEFAULT

      protected static final int RMSG_DEFAULT
      Remove S-group's children and remove S-group from its parent.
      Since:
      Marvin 5.0, 03/27/2007
      See Also:
    • RMSG_KEEP_CHILDREN

      protected static final int RMSG_KEEP_CHILDREN
      Do not remove S-group's children.
      Since:
      Marvin 5.0, 03/27/2007
      See Also:
    • RMSG_KEEP_PARENT

      protected static final int RMSG_KEEP_PARENT
      Do not remove S-group from its parent.
      Since:
      Marvin 5.0, 03/27/2007
      See Also:
    • RMSG_KEEP_MULTICENTER

      protected static final int RMSG_KEEP_MULTICENTER
      Do not remove central atom of multicenter S-groups.
      Since:
      Marvin 5.0, 10/22/2007
      See Also:
    • RECURSIVE_UNGROUP

      public static final int RECURSIVE_UNGROUP
      Ungroup and expand (if possible) the child S-groups.
      Since:
      Marvin 5.1, 06/05/2008
      See Also:
    • DEFAULT_UNGROUP

      public static final int DEFAULT_UNGROUP
      Do not ungroup and do not expand S-group's children.
      Since:
      Marvin 5.1, 06/05/2008
      See Also:
  • Constructor Details

    • Molecule

      public Molecule(Molecule p, int na, int nb)
      Construct a molecule or fragment with the specified number of atoms and bonds.
      Parameters:
      p - the molecule that contains the created fragment
      na - no reallocation needed until the number of atoms is less than this value
      nb - no reallocation needed until the number of bonds is less than this value
    • Molecule

      public Molecule(Molecule p, MolAtom a)
      Construct a molecule consisting of a single atom (node).
      Parameters:
      p - the parent structure
      a - the atom
    • Molecule

      public Molecule(Molecule p, MolBond b)
      Construct a molecule consisting of a single bond (edge).
      Parameters:
      p - the parent structure
      b - the bond
    • Molecule

      public Molecule()
      Construct a 2 dimensional molecule.
  • Method Details

    • setDim

      public void setDim(int d)
      Sets the dimension.
      Overrides:
      setDim in class MoleculeGraph
      Parameters:
      d - 0, 2, or 3
      See Also:
    • clear

      public void clear()
      Clears the molecule.
      Overrides:
      clear in class MoleculeGraph
      See Also:
    • clearForImport

      public void clearForImport(String format)
      Initializes molecule for import.
      Overrides:
      clearForImport in class MoleculeGraph
      Parameters:
      format - input file format
      Since:
      Marvin 2.7
      See Also:
    • getStartPosition

      public long getStartPosition()
      Gets the starting position of this molecule in the input file.
      Returns:
      the starting position
    • setStartPosition

      public void setStartPosition(long off)
      Sets the starting position of this molecule in the input file.
      Parameters:
      off - the starting position
    • getEndPosition

      public long getEndPosition()
      Gets the end position of this molecule in the input file.
      Returns:
      the end position
    • setEndPosition

      public void setEndPosition(long off)
      Sets the end position of this molecule in the input file.
      Parameters:
      off - the end position
    • getName

      public String getName()
      Gets the molecule name/title that was set by setName(String).
      Overrides:
      getName in class MoleculeGraph
      Returns:
      the molecule name or an empty string
      Since:
      Marvin 2.7
    • setName

      public void setName(String s)
      Sets the molecule name/title.
      Parameters:
      s - the molecule name, empty string or null (null is equivalent to empty string)
      Since:
      Marvin 2.7
    • getComment

      public String getComment()
      Gets the comment.
      Returns:
      the comment or empty string
      Since:
      Marvin 2.9
    • setComment

      public void setComment(String s)
      Sets the comment.
      Parameters:
      s - the comment, empty string or null (null is equivalent to empty string)
      Since:
      Marvin 2.9
    • getId

      public String getId()
    • setId

      public void setId(String id)
    • hasId

      public boolean hasId(String id)
    • getInputFormat

      public final String getInputFormat()
      Gets the input file format. Set by the import module if the molecule is from a file.
      Returns:
      "mrv", "mol", "mol:V3", "csmol", "sdf", "cssdf", "rdf", "csrdf", "smiles", "sybyl", "mol2", "pdb", "xyz" or "cube" or "inchi" or null if not imported from any format
      Since:
      Marvin 2.7
    • setInputFormat

      public void setInputFormat(String format)
      Sets the input file format.
      Parameters:
      format - the input format
      Since:
      Marvin 2.7
      See Also:
    • clearProperties

      public void clearProperties()
      Clears RDfile/SDfile properties.
    • getPropertyCount

      public int getPropertyCount()
      Gets the total number of RDfile/SDfile properties.
      Returns:
      number of properties
      Since:
      Marvin 2.7
    • getPropertyKeys

      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 4.1, replaced by properties().getKeys() and properties().getKeyEnumeration().
      One-to-one replacement is method getKeyEnumeration() but method getKeys() is simpler to use.
    • getPropertyKey

      public String getPropertyKey(int i)
      Gets an RDfile/SDfile property key.
      Parameters:
      i - property index
      Returns:
      the property name
      Since:
      Marvin 2.7
    • getProperty

      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.7, this method is deprecated. Replaced by MPropHandler.getPropertyString(MoleculeGraph, String).
      Usage:
      String property = MPropHandler.getPropertyString(mol, key);
      Gets an RDfile/SDfile property.
      Parameters:
      key - property name
      Returns:
      the value of the property, or null if the key is not found
    • getPropertyObject

      public Object getPropertyObject(String key)
      Gets an RDfile/SDfile property object.
      Parameters:
      key - property name
      Returns:
      the value of the property, or null if the key is not found
      Since:
      Marvin 3.1.2
    • setProperty

      public void setProperty(String key, String value)
      Sets an RDfile/SDfile property. Setting null value removes the property.
      Parameters:
      key - the property name
      value - the value or null
    • setPropertyObject

      public void setPropertyObject(String key, Object value)
      Sets an RDfile/SDfile property object. Setting null value removes the property.
      Parameters:
      key - the property name
      value - the value or null
      Since:
      Marvin 3.1.2
    • residueTypeOf

      public static int residueTypeOf(String name)
      Gets the residue identifier for a residue name.
      Parameters:
      name - residue name
      Returns:
      the residue type
    • residueSymbolOf

      public static String residueSymbolOf(int id)
      Gets the name of a residue.
      Parameters:
      id - the residue identifier
      Returns:
      the residue symbol
    • setAtom0

      protected void setAtom0(int i, MolAtom newAtom)
      Sets the atom at the specified index. Overridden because Sgroups must be set correctly in RgMolecule.clone() and RxnMolecule.clone().
      Overrides:
      setAtom0 in class MoleculeGraph
      Parameters:
      i - the atom index
      newAtom - the atom
    • removeAtom

      public void removeAtom(MolAtom atom, int cleanupFlags)
      Removes an atom and its bonds by reference. This method is for internal use only. Use MoleculeGraph.removeAtom(MolAtom) instead unless you are sure what you are doing.
      Overrides:
      removeAtom in class MoleculeGraph
      Parameters:
      atom - the atom
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeAtom

      public void removeAtom(int i, int cleanupFlags)
      Removes an atom and its bonds by index. This method is for internal use only. Use MoleculeGraph.removeAtom(MolAtom) instead unless you are sure what you are doing.
      Overrides:
      removeAtom in class MoleculeGraph
      Parameters:
      i - the atom index
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeBond

      protected void removeBond(MolBond bond, int cleanupFlags)
      Removes a bond by reference.
      Overrides:
      removeBond in class MoleculeGraph
      Parameters:
      bond - the bond
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeBond

      protected void removeBond(int i, int cleanupFlags)
      Removes a bond by index.
      Overrides:
      removeBond in class MoleculeGraph
      Parameters:
      i - the bond index
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeAllBonds

      public void removeAllBonds()
      Removes all bonds.
      Overrides:
      removeAllBonds in class MoleculeGraph
    • removeAll

      public void removeAll()
      Removes all the atoms and bonds.
      Overrides:
      removeAll in class MoleculeGraph
    • isEmpty

      public boolean isEmpty()
      Tests whether the molecule is empty.
      Overrides:
      isEmpty in class MoleculeGraph
      Returns:
      true if the molecule graph does not contain any atoms, bonds or non-empty S-groups, false otherwise
      Since:
      Marvin 4.1.1, 09/06/2006
    • aromatize

      public void aromatize(int method)
      Aromatizes molecule.
      Overrides:
      aromatize in class MoleculeGraph
      Parameters:
      method - Specifies the algorithm for aromatization.
      Throws:
      SecurityException - cannot load module because of a security problem (firewall)
      See Also:
    • aromatize

      public void aromatize(int method, boolean checkAmbiguity)
      Aromatizes molecule.
      Overrides:
      aromatize in class MoleculeGraph
      Parameters:
      method - Specifies the algorithm for aromatization.
      checkAmbiguity - Specifies whether ANY bonds should be considered during aromatization.
      Throws:
      SecurityException - cannot load module because of a security problem (firewall)
      See Also:
    • dearomatize

      public boolean dearomatize()
      Dearomatize molecule.
      Overrides:
      dearomatize in class MoleculeGraph
      Returns:
      true if success, else false.
      Throws:
      SecurityException - cannot load module because of a security problem (firewall)
    • clonecopy

      public void clonecopy(MoleculeGraph g)
      Makes another molecule identical to this one.
      Overrides:
      clonecopy in class MoleculeGraph
      Parameters:
      g - the target molecule
    • fixSelfReferringProperty

      protected boolean fixSelfReferringProperty(MProp prop)
      Fix a property containing reference to the molecule. Called from clonelesscopy().
      Overrides:
      fixSelfReferringProperty in class MoleculeGraph
      Parameters:
      prop - the property
      Since:
      Marvin 4.1.6, 02/14/2007
      See Also:
    • addSgroupClones

      protected final void addSgroupClones(Molecule originalParent, Molecule originalChild, Molecule newChild)
      Adds the S-groups of a child molecule clone to the new parent molecule clone.
      Parameters:
      originalParent - the original parent molecule
      originalChild - the original child molecule
      newChild - the new child molecule (clone of the original)
      Since:
      Marvin 3.4
    • clonecopy

      public void clonecopy(int[] iatoms, MoleculeGraph g)
      Copies the specified atoms and bonds of this molecule to another one.
      Overrides:
      clonecopy in class MoleculeGraph
      Parameters:
      iatoms - array of atom indices to copy or null
      g - the target molecule graph
      Since:
      Marvin 5.0.2, 03/11/2008
    • clonecopyWithoutSgroups

      protected void clonecopyWithoutSgroups(Molecule m)
      Copies the all the contents except the S-groups into another molecule object.
      Parameters:
      m - the target molecule
      Since:
      Marvin 3.4
    • cloneAtoms

      protected int cloneAtoms(int[] cnodes, MoleculeGraph graph)
      Copies the specified atoms.
      Overrides:
      cloneAtoms in class MoleculeGraph
      Parameters:
      cnodes - array of atom indices to copy or null
      graph - the target molecule graph
      Returns:
      the atom count
      Since:
      Marvin 6.0, 2013.02.25.
    • clonelesscopy

      @Deprecated public void clonelesscopy(MoleculeGraph g)
      Deprecated.
      as of Marvin 6.3.
      Not supported feature.
      Copies to selection. Makes another molecule identical to this one, but does not clone atoms, bonds, and the properties.
      Overrides:
      clonelesscopy in class MoleculeGraph
      Parameters:
      g - the target molecule object (the selection)
    • cloneMoleculeWithDocument

      public Molecule cloneMoleculeWithDocument()
      Makes an identical copy of the molecule and its document. If the molecule does not have a parent, then copies non-molecular data: graphics objects, electron flows, text boxes, atom and bond sets (color, font and thickness). Otherwise (root, rgroup, component molecule) creates a new document.
      Returns:
      the copy
      Since:
      Marvin 4.1, 01/16/2006
    • cloneMolecule

      Deprecated, for removal: This API element is subject to removal in a future version.
      as of Marvin 2014.09.01.0 use clone() instead
      Makes an identical copy of the molecule. It also clones the atoms and bonds of the Molecule. Note that it does not clone the corresponding MDocument, hence the atom and bond formatting (color, font, thickness) is lost.
      Returns:
      the copy
      Since:
      Marvin 3.5.1, 11/20/2004
    • clone

      public Molecule clone()
      Makes an identical copy of the molecule. It also clones the atoms and bonds of the Molecule. Note, that it does not clone the corresponding MDocument, hence the atom and bond formatting (color, font, thickness) is lost.
      Overrides:
      clone in class MoleculeGraph
      Returns:
      the copy
    • toFormat

      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a string representation of the molecule. The format descriptor string can also contain export options. Format and options are separated by a colon, multiple options can be separated by commas. See the text formats and their options on the File Formats in Marvin page. Examples:
       s1 = mol.toFormat("mol");
       s2 = mol.toFormat("smiles:a-H"); // aromatize and remove Hydrogens
       
      Parameters:
      fmt - the format descriptor string
      Returns:
      string representation of the molecule in the specified format
      Throws:
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
    • exportToFormat

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final String exportToFormat(String fmt) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.7, replaced by MolExporter.exportToFormat(Molecule, String).
      Creates a string representation of the molecule. Similar to toFormat(String), the only difference is that export exceptions are not converted to IllegalArgumentException.
      Parameters:
      fmt - the format descriptor string
      Returns:
      string representation of the molecule in the specified format
      Throws:
      IOException
      MolExportException - Export error
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
      Since:
      Marvin 4.0, 07/01/2005
    • toBinFormat

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final byte[] toBinFormat(String fmt)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a binary representation of the molecule. Works with all the text formats that are supported by the toFormat method, and also with the binary image formats (jpeg, msbmp, png). When creating an image, display options can also be specified in the format descriptor string. Format and options are separated by a colon, multiple options can be separated by commas. See the possible formats and their options on the File Formats in Marvin page. Examples:
       byte[] d1 = mol.toBinFormat("mol");
       byte[] d2 = mol.toBinFormat("smiles:a-H"); // aromatize and remove H
       byte[] d3 = mol.toBinFormat("png:w300,h300,b32,#00ffff00");
       byte[] d4 = mol.toBinFormat("jpeg:w300,h300,Q95,#ffff00,spacefill");
       
      Parameters:
      fmt - the format descriptor string
      Returns:
      a binary representation of the molecule in the specified format
      Throws:
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
      Since:
      Marvin 2.7.11
    • exportToBinFormat

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final byte[] exportToBinFormat(String fmt) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a binary representation of the molecule. Similar to toBinFormat(String), the only difference is that export exceptions are not converted to IllegalArgumentException.
      Parameters:
      fmt - the format descriptor string
      Returns:
      a binary representation of the molecule in the specified format
      Throws:
      MolExportException - Export error
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
      IOException
      Since:
      Marvin 4.0, 07/01/2005
    • toObject

      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a String, byte[] array or Image representation of the molecule. When creating an image, display options can also be specified in the format descriptor string. Format and options are separated by a colon, multiple options can be separated by commas. See the possible formats and their options on the File Formats in Marvin page. Examples:
       import java.awt.Image;
       ...
       String s1 = (String)mol.toObject("mol");
       String s2 = (String)mol.toObject("smiles:a-H"); // aromatize, remove H
       Image img = (Image)mol.toObject("image:w300,h300,#ffff00");
       byte[] d3 = (byte[])mol.toObject("png:w300,h300,b32,#00ffff00");
       byte[] d4 = (byte[])mol.toObject("jpeg:w300,h300,Q95,#ffff00,spacefill");
       
      Parameters:
      fmt - the format descriptor string
      Returns:
      a String, a byte[] array or an Image
      Throws:
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
      Since:
      Marvin 2.8.1
    • exportToObject

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Object exportToObject(String fmt) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.7, replaced by MolExporter.exportToObject(Molecule, String).
      Creates a String, byte[] array or Image representation of the molecule. Similar to toObject(String), the only difference is that export exceptions are not converted to IllegalArgumentException.
      Parameters:
      fmt - the format descriptor string
      Returns:
      a String, a byte[] array or an Image
      Throws:
      MolExportException - Export error
      IllegalArgumentException - Invalid format string.
      SecurityException - Export module cannot be loaded because of security reasons (firewall).
      IOException
      Since:
      Marvin 4.0, 07/01/2005
    • reuseAtom

      public MolAtom reuseAtom(int z, int i)
      Reuse an atom or create a new one. If an atom is reused, all its properties except the corners are initialized.
      Parameters:
      z - the atomic number
      i - the atom index
      Returns:
      the atom reference
      Since:
      Marvin 2.6
    • endReuse

      public void endReuse(int n)
      End reusing atoms.
      Parameters:
      n - number of atoms
      Since:
      Marvin 2.6
    • newInstance

      public MoleculeGraph newInstance()
      Creates a new Molecule object. The dimension and the origin coordinates will be the same as in the original molecule.
      Overrides:
      newInstance in class MoleculeGraph
      Returns:
      a Molecule object
    • newSelectionMolecule

      public SelectionMolecule newSelectionMolecule()
      Creates a new SelectionMolecule object appropriate for storing selection from this molecule.
      Returns:
      an empty selection molecule
      Since:
      Marvin 4.1, 11/24/2005
    • makeItSimilar

      protected void makeItSimilar(MoleculeGraph g)
      Copies some properties of this molecule to the other one specified as argument. Copies the input format.
      Overrides:
      makeItSimilar in class MoleculeGraph
      Parameters:
      g - the molecule to change
    • getSimplifiedMolecule

      public final Molecule getSimplifiedMolecule()
      Gets the simplified molecule object. It returns this usually. In case of RgMolecule, it returns the simply modified root structure if there are no R-groups present. In this case the RgMolecule will be inconsistent. It can simplify the molecule only if there is no parent document containing other objects.
      Returns:
      the simplified molecule
      Since:
      Marvin 3.0.1
    • getMostSimplifiedMolecule

      protected Molecule getMostSimplifiedMolecule()
      Gets the simplified molecule object even if there is a parent document with other objects. It returns this usually. In case of RgMolecule, it returns the root structure if there are no R-groups present.
      Returns:
      this in the default implementation
      Since:
      Marvin 4.1.13, 09/20/2007
    • isReaction

      public boolean isReaction()
      Checks if the structure represents a reaction or not.
      Returns:
      false
      Since:
      Marvin 3.0
    • canBeReactionComponent

      public boolean canBeReactionComponent()
      Tests whether an object of this class can be a reaction component. This implementation returns true
      Returns:
      true if it can be a reactant, product or agent, false if adding it to an RxnMolecule is not supported
      Since:
      Marvin 4.1.13, 09/19/2007
    • isSgroup

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public boolean isSgroup()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 14.7.7, no replacement.
      Not supported feature.
      Checks if the structure represents an S-group or not.
      Returns:
      true if the structure is an S-group, false otherwise
      Since:
      Marvin 3.0
    • getSgroupLigands

      public MolAtom[] getSgroupLigands()
      Gets the S-group's ligands if the structure represents an S-group.
      Returns:
      the array of ligands if the structure is an S-group with ligands, null otherwise
      Since:
      Marvin 3.0
    • findExpandableSgroup

      public final Sgroup findExpandableSgroup()
      Finds a contracted residue.
      Returns:
      the S-group if found, null if all S-groups are expanded
      Since:
      Marvin 3.0
    • findContractableSgroup

      public final Sgroup findContractableSgroup()
      Finds an expanded residue.
      Returns:
      the S-group if found, null if all S-groups are contracted
      Since:
      Marvin 3.0
    • getSgroupArray

      public final Sgroup[] getSgroupArray()
      Gets the array of S-groups.

      Warning! Expansion or contraction of an S-group in this array may invalidate other array elements. Examples:

      • contracting a MultipleSgroup removes any embedded SuperatomSgroup except those inside the repeating unit,
      • expanding a MultipleSgroup adds n-1 new clones for each embedded SuperatomSgroup in the repeating unit.
      Returns:
      an array containing all the S-groups
      Since:
      Marvin 3.0
    • getSgroupCount

      public final int getSgroupCount()
      Gets the number of S-groups.
      Returns:
      the number of S-groups
      Since:
      Marvin 3.0
    • countExpandableContractableSgroups

      public final int countExpandableContractableSgroups()
      Counts the expandable and contractable S-groups.
      Returns:
      the number of expandable/contractable S-groups
      Since:
      Marvin 5.0, 02/28/2007
    • countOrderedComponentSgroups

      public final int countOrderedComponentSgroups()
      Counts the ordered component S-groups.
      Returns:
      the number of ordered component S-groups.
      Since:
      Marvin 4.1.6, 02/28/2007
    • getSgroup

      public final Sgroup getSgroup(int i)
      Gets an S-group.
      Parameters:
      i - S-group index
      Since:
      Marvin 3.0
    • getSortedSgroups

      public final Sgroup[] getSortedSgroups()
      Gets the sorted S-groups in parent-child order.

      Warning! Expansion or contraction of an S-group in this array may invalidate other array elements. Examples:

      • contracting a MultipleSgroup removes any embedded SuperatomSgroup except those inside the repeating unit,
      • expanding a MultipleSgroup adds n-1 new clones for each embedded SuperatomSgroup in the repeating unit.
      Returns:
      array containing the S-groups
      Since:
      Marvin 3.4, 05/04/2004
    • getRootSgroups

      public final Sgroup[] getRootSgroups()
      Gets root s-groups (groups that are not embedded into another s-group).
      Returns:
      array containing the root s-groups (empty array if there are no s-groups)
      Since:
      Marvin 5.3.3, 31/03/2010
    • sortSgroupXBonds

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public void sortSgroupXBonds()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.12, no replacement.
      Crossing bonds of a SuperatomSgroup do not need to be sorted any more. It is not advised to sort them anyway because then the indexes of bonds change in the parent molecule.
      Sorts superatom S-group crossing bonds in attachment point number order.
      Since:
      Marvin 5.0, 12/07/2007
    • indexOf

      public final int indexOf(Sgroup sg)
      Gets the array index of an S-group.
      Parameters:
      sg - the S-group
      Since:
      Marvin 3.0
    • findSgroupOf

      public final Sgroup findSgroupOf(MolAtom a)
      Finds the smallest S-group related to the specified atom.
      Parameters:
      a - the atom
      Returns:
      the S-group or null if not found
      Since:
      Marvin 3.0
    • findSgroupContaining

      public final Sgroup findSgroupContaining(MolAtom a)
      Finds the largest S-group that contains the specified atom.
      Parameters:
      a - the atom
      Returns:
      the S-group or null if not found
      Since:
      Marvin 3.0
    • findSmallestSgroupContaining

      public final Sgroup findSmallestSgroupContaining(MolAtom a)
      Finds the smallest S-group that contains the specified atom.
      Parameters:
      a - the atom
      Returns:
      the S-group or null if not found
      Since:
      Marvin 3.4
    • findAllSgroupContaining

      public Sgroup[] findAllSgroupContaining(MolAtom a)
      Finds all smallest S-groups containing the specified atom. There can be more groups containing the same atom and not embedding each other because of the data S-groups: they are not in the embedding hierarchy.
      Parameters:
      a - the atom
      Returns:
      the array of S-groups
      Since:
      Marvin 5.0.1
    • contains

      public boolean contains(MolAtom atom)
      Checks if the molecule graph contains the specified atom. If the atom is not found in the graph, looks in the sgroupgraphs of contracted Expandable-Sgroups.
      Overrides:
      contains in class MoleculeGraph
      Parameters:
      atom - the atom
      Returns:
      true if the graph or an sgroupgraph contains the object, false otherwise
    • setSgroupParent

      public void setSgroupParent(MolAtom a, Sgroup sg, boolean set)
      Sets or unsets an S-group as a parent of an atom.
      Parameters:
      a - the atom
      sg - the S-group
      set - set (true) or unset (false)
      Throws:
      IllegalArgumentException - molecule does not contain the atom
      Since:
      Marvin 3.0
    • reparentSgroups

      protected final void reparentSgroups(Molecule p)
      Change parents of all S-groups in this molecule.
      Parameters:
      p - the new parent
      Throws:
      IllegalArgumentException - molecule does not contain the atom
      Since:
      Marvin 3.0
    • mergeAtoms

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public void mergeAtoms(MolAtom that, MolAtom node)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 6.2, use MergeUtil.mergeAtoms(MolAtom, MolAtom, boolean) instead.
      Merges bonds of an atom with another atom, then adds the atom to the molecule.
      Overrides:
      mergeAtoms in class MoleculeGraph
      Parameters:
      that - the atom
      node - the other atom
    • addAtom0

      protected void addAtom0(MolAtom node)
      Adds an atom.
      Overrides:
      addAtom0 in class MoleculeGraph
      Parameters:
      node - the atom reference
    • addAtomToFragment

      protected void addAtomToFragment(MolAtom atom)
      Adds an atom to a fragment. S-groups are added only if all atoms are already in the molecule.
      Overrides:
      addAtomToFragment in class MoleculeGraph
      Parameters:
      atom - the atom reference
    • addBond0

      protected void addBond0(MolBond bond)
      Adds a bond.
      Overrides:
      addBond0 in class MoleculeGraph
      Parameters:
      bond - the bond reference
    • fuse0

      protected void fuse0(MoleculeGraph graph, boolean check)
      Adds those atoms and bonds of a molecule graph to this one that are not already elements.
      Overrides:
      fuse0 in class MoleculeGraph
      Parameters:
      graph - the molecule graph
      check - true if a containment check should be performed to ensure that only those atoms and bonds are added that are not already elements - false if the moleclue graph is known to be disjoint from this one and this check can be safely skipped
      Since:
      Marvin 5.0
    • contractSgroups

      public final boolean contractSgroups()
      Contracts all S-groups.
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.0
    • contractSgroups

      public final boolean contractSgroups(int opts)
      Contracts all S-groups.
      Parameters:
      opts - contraction options
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.4
      See Also:
    • expandSgroups

      public final boolean expandSgroups()
      Expands all S-groups.
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.0
      See Also:
    • expandSgroups

      public final boolean expandSgroups(int opts)
      Expands all S-groups.
      Parameters:
      opts - expansion options
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.3
      See Also:
    • isExpandable

      public final boolean isExpandable(int opts)
      Tests if the molecule is expandable with the specified options.
      Parameters:
      opts - expansion options
      Returns:
      true if an S-group is GUI-contractable, false otherwise
      Since:
      Marvin 4.0.2, 10/26/2005
      See Also:
    • setGUIContracted

      @Deprecated public final void setGUIContracted(boolean contract)
      Deprecated.
      as of Marvin 6.2, use expandSgroups(int) or contractSgroups(int) instead with option parameter Expandable.LEAVE_COORDS_UNCHANGED
      S-group expansion or contraction is performed depending on the parameter contract.
      If contract is set to:
      • false, then expansion happens to the contracted groups with no coordinate generation.
      • true, then contraction is performed for those s-groups that were expanded the way that was explained in the previous point.
      Parameters:
      contract - true for contraction, false for expansion
      Since:
      Marvin 3.4, 05/04/2004
    • setGUIContracted

      @Deprecated public final void setGUIContracted(boolean contract, int opts)
      Deprecated.
      as of Marvin 6.2, use expandSgroups(int) or contractSgroups(int) instead with option parameter Expandable.LEAVE_COORDS_UNCHANGED
      S-group expansion or contraction is performed depending on the parameter contract.
      If contract is set to:
      • false, then expansion happens to the contracted groups with no coordinate generation.
      • true, then contraction is performed for those s-groups that were expanded the way that was explained in the previous point.
      Parameters:
      contract - true for contraction, false for expansion
      opts - for further expand options
      Since:
      Marvin 3.4, 05/04/2004
    • isGUIContracted

      @Deprecated public final boolean isGUIContracted()
      Deprecated.
      as of Marvin 6.2 replaced by hasContractedSgroup()
      Tests if the molecule has contracted S-groups or not.
      Returns:
      true there is at least one contracted S-group, false otherwise
      Since:
      Marvin 3.4.1, 07/26/2004
    • hasContractedSgroup

      public boolean hasContractedSgroup()
      Tests if the molecule has contracted S-groups or not.
      Returns:
      true there is at least one contracted S-group, false otherwise
      Since:
      Marvin 6.2, 2013/09/25
    • ungroupSgroup

      public final boolean ungroupSgroup(Sgroup sg)
      Ungroups the specified S-group and expands it if it is an Expandable S-group. Ungroups and expands the child S-groups also if they are Expandable S-groups. Calls a recursive ungroup.
      Parameters:
      sg - the S-group
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.4
      See Also:
    • ungroupSgroup

      public final boolean ungroupSgroup(Sgroup sg, int opts)
      Expand and ungroup the specified S-group.
      Parameters:
      sg - the S-group
      opts - option to specify the ungroup type
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 5.1.2
      See Also:
    • ungroupSgroup

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final boolean ungroupSgroup(int i)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of Marvin 6.3. use ungroupSgroup(Sgroup) instead.
      Ungroups the specified S-group and expands it if it is an Expandable S-group. Ungroups and expands the child S-groups also if they are Expandable S-groups.
      Parameters:
      i - the S-group index
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.4
      See Also:
    • ungroupSgroups

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final boolean ungroupSgroups(int type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of Marvin 6.3. use ungroupSgroups(EnumSet) instead.
      Ungroups all S-groups of a specified type in this molecule. Performs expand before ungroup if the type is an expandable S-group type.
      Parameters:
      type - the S-group type that specifies which S-groups to ungroup.
      Returns:
      true if the operation was successful, false if nothing changed.
      Since:
      Marvin 5.2
      See Also:
    • ungroupSgroups

      public final boolean ungroupSgroups(EnumSet<SgroupType> types)
      Ungroups all S-groups of the specified types in this molecule. Performs expand before ungroup if a type is an expandable S-group type. NOTE that giving SgroupType.SUPERATOM as parameter will leave the SgroupType.AMINOACID typed S-groups in unchanged state while the former method (ungroupSgroups(int)) ungrouped the AminoAcidSgroups as well.
      Parameters:
      types - the S-group types that specifies which S-group types to ungroup.
      Returns:
      true if the operation was successful, false if nothing changed.
      Since:
      Marvin 6.3
      See Also:
    • ungroupSgroup

      @Deprecated public final boolean ungroupSgroup(int i, int opts)
      Deprecated.
      as of Marvin 6.3. use ungroupSgroup(Sgroup) instead.
      Ungroups the specified S-group and expands it if it is an Expandable S-group. Ungroups and expands the child S-groups also if they are Expandable S-groups according to the specified option.
      Parameters:
      i - the S-group index
      opts - option to specify the ungroup type
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 5.1
      See Also:
    • ungroupSgroups

      public final boolean ungroupSgroups()
      Expands and ungroups all S-groups.
      Returns:
      true if the operation was successful, false if nothing changed
      Since:
      Marvin 3.0
    • addSgroupsOf

      protected final void addSgroupsOf(Molecule m)
      Adds S-groups to this object and its parent.
    • removeSgroupsOf

      protected final void removeSgroupsOf(Molecule m, int rmflags)
      Removes S-groups that are contained in a given molecule but not contained in another molecule.
      Parameters:
      m - the molecule whose S-groups are to remove
      rmflags - removal flags
      Since:
      Marvin 4.1.7
      See Also:
    • removeSgroupsOf

      protected final void removeSgroupsOf(Molecule m)
      Removes S-groups from this object and its parent.
    • removeAllSgroups

      protected void removeAllSgroups()
      Removes all S-groups.
    • removeSgroupFromList

      protected void removeSgroupFromList(Sgroup sg)
      Removes an S-group from the sgroupVector.
      Since:
      Marvin 4.1, 07/28/2006
    • rearrangeSgroups

      public void rearrangeSgroups(int[] newIndexes)
      Orders S-groups in the vector of S-groups in the given order corresponding to the given new indexes.
      Parameters:
      newIndexes - array of new S-group indexes, ith element of the array contains the new index of the ith s-group in the s-group vector
      Throws:
      IllegalArgumentException - if newIndexes are not in the range [0..getSgroupCount()] or not all values in this range are contained.
      Since:
      Marvin 5.12, 2012.11.12.
    • addSgroup

      public void addSgroup(Sgroup sg, boolean setparent)
      Adds an S-group to this object.
      Parameters:
      sg - the S-group to add.
      setparent - if true then the parent of the S-group is set to this molecule and the S-group is removed from the old parent molecule.
      Since:
      Marvin 5.2
    • removeAtomFromChildren

      protected void removeAtomFromChildren(Sgroup sgroup, MolAtom atom)
      Removes the parameter atom from the parameter S-group and it's descendants.
    • getGraphUnionAsSelection

      protected final SelectionMolecule getGraphUnionAsSelection()
      Gets a selection molecule containing all the atoms and bonds. Returns the same object until the unified structure is (or might be) changed, then recreates it.
      Returns:
      a selection molecule object containing the unified structure
      Since:
      Marvin 3.0, 11/05/2002
      See Also:
    • bondlength

      public double bondlength()
      Calculate the regular bond length for the unified structure.
      Overrides:
      bondlength in class MoleculeGraph
      Returns:
      the regular bond length
    • convertToFrags

      public final Molecule[] convertToFrags()
      Converts this molecule to its disconnected fragments, expanding all S-groups and keeping disconnected Multicenter S-groups in the same fragment, but ungroupping and separating fragments in all other types of S-groups.

      Warning: Atoms are removed from the original molecule object to the created fragments, therefore the original molecule becomes inconsistent.

      The original atom order is preserved in the returned fragments. Fragment order is also determined by the original atom order. The first fragment is the one containing atom 0, the second fragment is the one containing the smallest indexed atom not in the first fragment, etc.

      Returns:
      array of fragments
      Since:
      Marvin 3.1
      See Also:
    • findFrags

      public <C extends MoleculeGraph> C[] findFrags(Class<C> cl, int fragmentationType)
      Determines the disconnected fragments and puts them into an array. Atoms are removed from the original molecule object unless the fragment class is SelectionMolecule.class.

      The original atom order is preserved in the returned fragments. Fragment order is also determined by the original atom order. The first fragment is the one containing atom 0, the second fragment is the one containing the smallest indexed atom not in the first fragment, etc.

      If not using the FRAG_KEEPING_SGROUPS option and an S-group would contain more fragments, then it won't be added to any of them, and its parent-child relations with other S-groups will be removed.

      Fragmentation is performed depending on fragmentation type:

      Overrides:
      findFrags in class MoleculeGraph
      Type Parameters:
      C - the class of the fragments
      Parameters:
      cl - create fragment objects of this class
      fragmentationType - determines the type of fragmentation
      Returns:
      array of fragments
      Since:
      Marvin 5.6
      See Also:
    • findFrags

      public final SelectionMolecule[] findFrags()
      Determines the disconnected fragments and puts them into an array. Multicenter S-groups are kept in one fragment.

      The original atom order is preserved in the returned fragments. Fragment order is also determined by the original atom order. The first fragment is the one containing atom 0, the second fragment is the one containing the smallest indexed atom not in the first fragment, etc.

      Returns:
      array of fragments
      Since:
      Marvin 3.0
    • fillSelectionMolecule

      protected void fillSelectionMolecule(SelectionMolecule s)
      Adds all atoms and bonds to the specified molecule.
      Parameters:
      s - the selection molecule
      Since:
      Marvin 3.0, 11/05/2002
    • clearExtraLabels

      public void clearExtraLabels()
      Clears extra atom labels.
    • checkConsistency

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public void checkConsistency()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.7, no replacement.
      Not intended for public use, it was intended only for internal debugging.
      Checks the internal consistency of the structure. Use this method for debugging.
      Overrides:
      checkConsistency in class MoleculeGraph
      Throws:
      RuntimeException - if inconsistency found
      Since:
      Marvin 5.0, 11/06/2007
    • checkSgroupConsistency

      protected void checkSgroupConsistency()
      Checks the internal consisitency of S-groups.
      Throws:
      RuntimeException - if inconsistency found
      Since:
      Marvin 5.0, 11/06/2007
    • getVisibleCoords

      public double[] getVisibleCoords(MolAtom ma)
      Returns the coordinates of the given atom (contained in the molecule). If the atom is part of a contracted superatom sgroup, its coordinates may be false, so this method returns the coordinates of the corresponding sgroup atom instead.
      Overrides:
      getVisibleCoords in class MoleculeGraph
      Parameters:
      ma - The atom to be queried.
      Returns:
      The real coordinates of ma.
      Since:
      Marvin 4.0 8/07/2005
    • transform

      public void transform(CTransform3D t, boolean incg)
      Apply a transformation matrix to the atomic coordinates and Data Sgroup coordinates.
      Overrides:
      transform in class MoleculeGraph
      Parameters:
      t - the transformation matrix
      incg - graph invariants are changed (true) or not (false)
      Since:
      Marvin 4.0 2/09/2005
    • findContainingMulticenterSgroup

      public MulticenterSgroup findContainingMulticenterSgroup(MolAtom atom)
      Gets the containing multicenter S-group of a multicenter atom.
      Parameters:
      atom - the multicenter atom.
      Returns:
      the containing multicenter S-group, null if none of the multicenter sgroups contains the multicenter atom.
      Since:
      Marvin 5.0 04/20/2007
      See Also:
    • createGearch

      protected chemaxon.struc.gearch.MoleculeGraphGearch createGearch()
      Overrides:
      createGearch in class MoleculeGraph
    • clearObjects

      public void clearObjects()
      Specified by:
      clearObjects in interface chemaxon.struc.MObjectContainer
    • getObjectCount

      public int getObjectCount()
      Specified by:
      getObjectCount in interface chemaxon.struc.MObjectContainer
    • removeObject

      public void removeObject(MObject mo)
      Specified by:
      removeObject in interface chemaxon.struc.MObjectContainer
    • selectAllObjects

      public void selectAllObjects(boolean s)
      Specified by:
      selectAllObjects in interface chemaxon.struc.MObjectContainer
    • getAllObjects

      public List<MObject> getAllObjects()
      Specified by:
      getAllObjects in interface chemaxon.struc.MObjectContainer
    • replaceSgroup

      public void replaceSgroup(Sgroup sgroup, Sgroup newSgroup)
      Replaces an S-group with a new sgroup in the molecule. Sets parent - child relations of the new sgroup according to the parent - child relations of the old sgroup.
      Parameters:
      sgroup - the sgroup to replace
      newSgroup - the sgroup to replace with
    • implicitizeHydrogens0

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) protected boolean implicitizeHydrogens0(int f, MolAtom[] atoms, boolean check)
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of Marvin 5.7, replaced by Hydrogenize.convertExplicitHToImplicit(MoleculeGraph, MolAtom[], int, boolean).
      Usage:
                   Hydrogenize.convertExplicitHToImplicit(mol, atoms, f, check);
                   
      Overrides:
      implicitizeHydrogens0 in class MoleculeGraph
      Returns:
      true if success else false
    • add

      public void add(MolBond bond)
      Description copied from class: MoleculeGraph
      Adds a bond to the molecule. If the molecule graph is a superGraph, the bond is also added to its endpoints (two MolAtom objects).
      Overrides:
      add in class MoleculeGraph
      Parameters:
      bond - the bond object
    • replaceAtom

      public void replaceAtom(int i, MolAtom newAtom)
      Replaces the atom on the given index with the parameter atom and removes the parameter atom from its original parent molecule if needed. Sets the sgroup hierarchy.
      Overrides:
      replaceAtom in class MoleculeGraph
      Parameters:
      i - the index of the original atom
      newAtom - the atom which will replace the original
    • getBonds

      protected MolBond[] getBonds(MolAtom atom)
      Returns the bonds attached to the given atom.
      Overrides:
      getBonds in class MoleculeGraph
      Parameters:
      atom - the atom
      Returns:
      the bonds attached to the given atom in this molecule
      Since:
      Marvin 6.2
    • getSgroupIterator

      public IteratorFactory.SgroupIterator getSgroupIterator()
      Returns an iterator over the s-groups in this molecule in proper sequence.
      Returns:
      an iterator over the s-groups in this molecule in proper sequence
      Since:
      Marvin 6.2, 2013.09.09.
    • connectOriginalBondsToNewAtom

      protected void connectOriginalBondsToNewAtom(MolAtom newAtom, MolAtom orig, MolBond[] bonds)
      Description copied from class: MoleculeGraph
      Sets the original connections to the new atom.
      Overrides:
      connectOriginalBondsToNewAtom in class MoleculeGraph
      Parameters:
      newAtom - the atom which replace the original
      orig - the original atom
      bonds - the original atoms bonds (before any modification)
    • hasAtomSet

      public boolean hasAtomSet()
      Description copied from class: MoleculeGraph
      Tests whether the molecule graph has atom sets.
      Overrides:
      hasAtomSet in class MoleculeGraph
      Returns:
      true if there are atom sets, false otherwise