Class RgMolecule

All Implemented Interfaces:
MoleculeWithValence<MolAtom>, chemaxon.core.structure.MarkushStructureForBuilder, chemaxon.core.structure.MoleculeForBuilder, chemaxon.struc.MObjectContainer, MTransformable, chemaxon.struc.RgMoleculeGraphIface, StereoConstants, Serializable

@PublicApi public class RgMolecule extends Molecule implements chemaxon.struc.RgMoleculeGraphIface, chemaxon.struc.MObjectContainer, chemaxon.core.structure.MarkushStructureForBuilder
A molecule or reaction containing R-groups.
Since:
Marvin 2.6
See Also:
  • Field Details

  • Constructor Details

    • RgMolecule

      public RgMolecule()
      Creates a 2 dimensional RgMolecule.
    • RgMolecule

      public RgMolecule(Molecule root)
      Creates an RgMolecule with the given root structure.
  • Method Details

    • setRoot

      public void setRoot(Molecule mol)
      Sets the root structure.
      Parameters:
      mol - the root structure
    • getStereo2

      public int getStereo2(MolBond bond, MolAtom leftAtom, MolAtom rightAtom, boolean performGrinvCheck)
      Description copied from class: MoleculeGraph
      Gets cis/trans stereo information for an A1-A2=A3-A4 atom configuration. Calculates the stereo information if the molecule is 2D or 3D, reports previously set information if it is 0D. Atoms A2 and A3 are atom1 and atom2 of the specified bond. Both (A2, A3) = (atom1, atom2) and (A2, A3) = (atom2, atom1) works. If A1 or A4 is null 0 is returned. Not checking if the bond is in small ring (MoleculeGraph.MIN_RING_SIZE_FOR_TRANS_DB (so chemically the double bond with its ring ligand can be cis only), but due to the perspective depiction in two dimension the double bond ligand arrangement looks trans. In this case the chemically incorrect trans returned.

      See MoleculeGraph.getStereo2(chemaxon.struc.MolAtom, int, int, chemaxon.struc.MolAtom) for detailed examples.

      Overrides:
      getStereo2 in class MoleculeGraph
      Parameters:
      bond - the bond
      leftAtom - atom A1
      rightAtom - atom A4
      performGrinvCheck - true if check atom equivalences using graph invariants
      Returns:
      the stereo flags
      See Also:
    • getRoot

      public Molecule getRoot()
      Gets the root structure.
      Returns:
      the root
    • getRootG

      public final MoleculeGraph getRootG()
      Gets the root structure.
      Specified by:
      getRootG in interface chemaxon.struc.RgMoleculeGraphIface
      Returns:
      the root
    • getRgroupCount

      public int getRgroupCount()
      Gets the number of R-groups.
      Specified by:
      getRgroupCount in interface chemaxon.struc.RgMoleculeGraphIface
      Returns:
      number of R-groups
    • getRgroupMemberCount

      public int getRgroupMemberCount(int i)
      Gets the number of R-group members.
      Specified by:
      getRgroupMemberCount in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      i - R-group index
      Returns:
      number of R-group members
    • getRgroupMember

      public Molecule getRgroupMember(int i, int j)
      Gets an R-group member.
      Parameters:
      i - R-group index
      j - member index
      Returns:
      the R-group member
    • getRgroupMemberG

      public final MoleculeGraph getRgroupMemberG(int i, int j)
      Gets an R-group member.
      Specified by:
      getRgroupMemberG in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      i - R-group index
      j - member index
      Returns:
      the R-group member
    • getRgroupId

      public int getRgroupId(int i)
      Gets the ID of an R-group.
      Specified by:
      getRgroupId in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      i - R-group index
      Returns:
      number between 0 and MolAtom.RGROUP_MAX
    • findRgroupIndex

      public int findRgroupIndex(int rgid)
      Finds the index of an R-group based on the R-group number.
      Specified by:
      findRgroupIndex in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      rgid - number between 0 and MolAtom.RGROUP_MAX
      Returns:
      R-group index, or -1 if not found
    • addSgroup

      public void addSgroup(Sgroup sg, boolean setparent)
      Adds an S-group to this object.
      Overrides:
      addSgroup in class Molecule
      Parameters:
      setparent - if true then the parent of the S-group is set to the root or that R-group member of this molecule which contains the S-group and the S-group is removed from the old parent molecule.
      sg - the S-group to add.
    • addRgroup

      public int addRgroup(int rl, Molecule m)
      Adds an R-group member.
      Parameters:
      rl - R-logic flags or an R-group ID number between 0 and MolAtom.RGROUP_MAX
      m - the R-group
      Returns:
      the Rgroup index
    • getRgroupIndex

      public int getRgroupIndex(RgroupBridgeId bridgeId)
      Returns the index of the ordinary R-group that actually represents the given R-group bridge.
      Parameters:
      bridgeId - R-group bridge ID
      Returns:
      the index of the ordinary R-group that actually represents the given R-group bridge or -1 if the given bridge is not defined in the structure
      Since:
      Marvin 14.10.13
      See Also:
    • getRgroupId

      public int getRgroupId(RgroupBridgeId bridgeId)
      Specified by:
      getRgroupId in interface chemaxon.struc.RgMoleculeGraphIface
    • findRgroupBridgeId

      public RgroupBridgeId findRgroupBridgeId(int index)
      Finds the corresponding RgroupBridgeId for an R-group index.
      Parameters:
      index - the index of an R-group
      Returns:
      the corresponding RgroupBridgeId if the specified R-group is actually representing an R-group bridge, null otherwise
      Since:
      Marvin 14.10.13
      See Also:
    • getRgroupBridgeCount

      public int getRgroupBridgeCount()
      Returns the number of R-group bridges defined in this structure.
      Returns:
      the number of R-group bridges
      Since:
      Marvin 14.10.13
      See Also:
    • getRgroupBridgeIds

      public List<RgroupBridgeId> getRgroupBridgeIds()
      Returns the list of R-group bridge IDs defined in this structure.
      Returns:
      the sorted list of R-group bridge IDs
      Since:
      Marvin 14.10.13
      See Also:
    • getRgroupBridgeMemberCount

      public int getRgroupBridgeMemberCount(RgroupBridgeId bridgeId)
      Returns the number of definition members of the given R-group bridge.
      Parameters:
      bridgeId - R-group bridge ID
      Returns:
      the number of definition members of the given R-group bridge or 0 if the bridge is not defined in this structure
      Since:
      Marvin 14.10.13
      See Also:
    • getRgroupBridgeMember

      public Molecule getRgroupBridgeMember(RgroupBridgeId bridgeId, int memberIndex)
      Returns a definition member of the given R-group bridge.
      Parameters:
      bridgeId - R-group bridge ID
      memberIndex - index of the definition member
      Returns:
      the definition member molecule
      Since:
      Marvin 14.10.13
      See Also:
    • addRgroupBridgeMember

      public void addRgroupBridgeMember(RgroupBridgeId bridgeId, Molecule m)
      Adds a definition member to an R-group bridge.
      Parameters:
      bridgeId - R-group bridge ID
      m - the member molecule
      Since:
      Marvin 14.10.13
      See Also:
    • removeRgroupMember

      public void removeRgroupMember(int rgroupIndex, int memberIndex)
      Removes an R-group definition member. If it is the last member to be removed, then the whole R-group definition will be removed. Note: the R-group members are always indexed continuously starting with 0.
      Parameters:
      rgroupIndex - the index of the R-group definition
      memberIndex - the index of the member
      Throws:
      IndexOutOfBoundsException - If the definition index is not valid or if the member index is not valid
      Since:
      5.10 2012.05.10
    • removeRgroupBridgeMember

      public void removeRgroupBridgeMember(RgroupBridgeId bridgeId, int memberIndex)
      Removes a definition member of an R-group bridge. If it is the last member to be removed, then the whole R-group bridge will be removed. Note: the R-group bridge members are always indexed continuously starting with 0.
      Parameters:
      bridgeId - R-group bridge ID
      memberIndex - the index of the member
      Since:
      Marvin 14.10.13
      See Also:
    • removeRgroupMembers

      public void removeRgroupMembers(int rgroupIndex, int[] memberIndexes)
      Removes R-group members. If the last member is removed then the whole R-group definition will be removed. Note: the R-group members are always indexed continuously starting with 0.
      Parameters:
      rgroupIndex - the index of the R-group definition
      memberIndexes - the array of the member indexes
      Throws:
      IndexOutOfBoundsException - If the definition index is not valid or if a member index is not valid
      Since:
      5.10 2012.05.10
    • removeRgroup

      public void removeRgroup(int rgroupIndex)
      Removes an R-group. Note: the R-group definitions are always indexed continuously starting with 0.
      Parameters:
      rgroupIndex - the index of the R-group definition
      Throws:
      IndexOutOfBoundsException - If the definition index is not valid
      Since:
      5.10 2012.05.10
    • removeRgroupBridge

      public void removeRgroupBridge(RgroupBridgeId bridgeId)
      Removes an R-group bridge.
      Parameters:
      bridgeId - R-group bridge ID
      Since:
      Marvin 14.10.13
      See Also:
    • hasRgroupContainedBy

      public boolean hasRgroupContainedBy(Set<?> set)
      Tests whether the molecule has an R-group that is a subset of the specified set of atoms.
      Parameters:
      set - set of atoms
      Since:
      5.0, 02/24/2007
    • unRgroupAtoms

      public int unRgroupAtoms(Set<?> set)
      Ungroup R-groups consisting of the specified atoms and make them be part of root.
      Parameters:
      set - selected atoms
      Returns:
      the number of ungrouped R-group members
      Since:
      5.0, 02/24/2007
    • replaceAtomsWithNewRgroup

      public void replaceAtomsWithNewRgroup(SelectionMolecule sel, int rgid)
      Replaces selected atoms with a new R-group.
      Parameters:
      sel - selected atoms
      rgid - R-group ID
      Since:
      4.0, 06/30/2005
    • getRlogic

      public int getRlogic(int i)
      Gets R-logic flags.
      Specified by:
      getRlogic in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      i - R-group index
      Returns:
      R-logic flags
      See Also:
    • setRlogic

      public void setRlogic(int i, int f)
      Sets R-logic flags.
      Parameters:
      i - R-group index
      f - R-logic flags
      See Also:
    • getRlogicRange

      public String getRlogicRange(int i)
      Gets R-logic occurrence range.
      Specified by:
      getRlogicRange in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      i - R-group index
      Returns:
      the occurrence range: By default it is an empty string which means "as drawn".
    • setRlogicRange

      public void setRlogicRange(int index, String range) throws IllegalArgumentException
      Sets R-logic occurrence range. If null is given as range, de R-logic range is set to default empty string.
      Parameters:
      index - R-group index
      range - range of occurrance.
      Throws:
      IllegalArgumentException - bad occurrence range
    • checkRlogicRange

      public String checkRlogicRange(int index, String range) throws IllegalArgumentException
      Checks an R-logic occurrence range string for syntax errors and returns a "normalized" string.
      Parameters:
      index - R-group index
      range - range of occurrence
      Returns:
      the normalized occurrence range string
      Throws:
      IllegalArgumentException - bad occurrence range
      Since:
      Marvin 3.4
    • clearForImport

      public void clearForImport(String fmt)
      Clear the edges vector and the properties.
      Overrides:
      clearForImport in class Molecule
      Parameters:
      fmt - input file format. See the text formats on the File Formats in Marvin page.
      See Also:
    • setName

      public void setName(String s)
      Sets the name of the root molecule.
      Overrides:
      setName in class Molecule
      Parameters:
      s - the molecule name, empty string or null (null is equivalent to empty string)
    • getName

      public String getName()
      Gets the name of the root molecule.
      Overrides:
      getName in class Molecule
      Returns:
      the molecule name or an empty string
    • setComment

      public void setComment(String s)
      Sets the comment of the root molecule.
      Overrides:
      setComment in class Molecule
      Parameters:
      s - the comment, empty string or null (null is equivalent to empty string)
    • getComment

      public String getComment()
      Gets the comment of the root molecule.
      Overrides:
      getComment in class Molecule
      Returns:
      the comment or empty string
    • properties

      public MPropertyContainer properties()
      Gets the property container.
      Overrides:
      properties in class MoleculeGraph
      Returns:
      the property container
      Since:
      Marvin 4.0, 06/20/2005
    • revalidateCoordDependentProps

      public void revalidateCoordDependentProps()
      Revalidate coordinate dependent properties. This method should be called at molecule import, after all atomic coordinates and bonds are parsed.
      Overrides:
      revalidateCoordDependentProps in class MoleculeGraph
      Since:
      Marvin 4.1, 08/03/2006
    • setInputFormat

      public void setInputFormat(String format)
      Sets the input file format.
      Overrides:
      setInputFormat in class Molecule
      Parameters:
      format - the input format
      See Also:
    • 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.
      Overrides:
      reuseAtom in class Molecule
      Parameters:
      z - atomic number
      i - atom index
      Returns:
      the new or old atom
    • endReuse

      public void endReuse(int n)
      End reusing atoms.
      Overrides:
      endReuse in class Molecule
      Parameters:
      n - number of atoms
      Since:
      Marvin 2.6
    • getCtab

      public int[][] getCtab()
      Gets the connection table of the root structure. If there is no connection table for the molecule, then create it. ctab[i][j] will be the index of the jth neighbor of the ith atom.
      Overrides:
      getCtab in class MoleculeGraph
      Returns:
      the ctab array
    • getBondTable

      public BondTable getBondTable()
      Gets the bond table of the root structre. If there is no bond table for the molecule, then create it. btab.elementAt(i, j) will be the index of the bond between atoms i and j, or -1 if there is no bond.
      Overrides:
      getBondTable in class MoleculeGraph
      Returns:
      the btab array
      Since:
      Marvin 5.4
    • rgroupIdOf

      public int rgroupIdOf(MolAtom node)
      Finds the ID of the R-group (the number in R#) that contains the specified atom.
      Specified by:
      rgroupIdOf in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      node - the atom
      Returns:
      the R-group ID if found or -1 if not found
    • rgroupIndexOf

      public int rgroupIndexOf(MolAtom node)
      Finds the index of the R-group (the number in R#) that contains the specified atom.
      Specified by:
      rgroupIndexOf in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      node - the atom
      Returns:
      the R-group index if found or -1 if not found
    • getRgroupMemberId

      public long getRgroupMemberId(MolAtom node)
      Gets the unique identifier of the R-group member that contains the specified atom.
      Specified by:
      getRgroupMemberId in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      node - the atom
      Returns:
      the ID or -1
      Since:
      Marvin 4.1, 11/23/2005
    • setDim

      public void setDim(int d)
      Sets the dimension of the root structure and the R-groups.
      Overrides:
      setDim in class Molecule
      Parameters:
      d - 0, 2 or 3
      See Also:
    • getFlags

      public int getFlags()
      Gets the dimension and chiral flags.
      Overrides:
      getFlags in class MoleculeGraph
      Returns:
      the flags
      Since:
      Marvin 5.0.1, 02/10/2008
    • setFlags

      protected void setFlags(int f)
      Sets the dimension and chiral flags.
      Overrides:
      setFlags in class MoleculeGraph
      Parameters:
      f - the flags
      Since:
      Marvin 5.0.1, 02/10/2008
      See Also:
      • MoleculeGraph.flags
    • setFlags

      protected void setFlags(int f, int mask)
      Sets specified bits in the flags.
      Overrides:
      setFlags in class MoleculeGraph
      Parameters:
      f - new value of the specified bits
      mask - bits to set
    • setAbsStereo

      public void setAbsStereo(boolean c)
      Sets the absolute stereoconfiguration flag for the root structure and the R-groups.
      Overrides:
      setAbsStereo in class MoleculeGraph
      Parameters:
      c - the absolute stereoconfiguration flag
      See Also:
    • getAtomCount

      public int getAtomCount()
      Gets the number of nodes in the root structure.
      Overrides:
      getAtomCount in class MoleculeGraph
      Returns:
      number of nodes
    • getAtomCount

      public int getAtomCount(int atomicNumber)
      Gets the number of atoms with the given atomic number in the root structure. When atomicNumber is 1, sum includes only explicit Hydrogen atoms (but also D and T isotopes).
      Overrides:
      getAtomCount in class MoleculeGraph
      Parameters:
      atomicNumber - atomic number of atoms looked for
      Returns:
      number of atoms with the given atomic number
      Since:
      Marvin 5.5, 27/01/2011
    • getAtom

      public MolAtom getAtom(int i)
      Gets a node in the graph union.
      Overrides:
      getAtom in class MoleculeGraph
      Parameters:
      i - node index
      Returns:
      the node object
    • setAtom

      @Deprecated public void setAtom(int iu, MolAtom node)
      Deprecated.
      as of Marvin 6.2, may constructs inconsistent MoleculeGraph. Use MoleculeGraph.removeAtom(MolAtom) and add(MolAtom) to modify the structure.
      Sets the node at the specified index in the graph union.
      Overrides:
      setAtom in class MoleculeGraph
      Parameters:
      iu - the atom index
      node - the atom
    • clone

      public RgMolecule clone()
      Clone the markush structure. Document is not cloned!
      Overrides:
      clone in class Molecule
      Returns:
      deep clone of the markush structure
    • cloneMoleculeWithDocument

      public RgMolecule cloneMoleculeWithDocument()
      Description copied from class: Molecule
      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.
      Overrides:
      cloneMoleculeWithDocument in class Molecule
      Returns:
      the copy
    • add

      public void add(MolAtom node)
      Adds an atom to the root structure.
      Overrides:
      add in class MoleculeGraph
      Parameters:
      node - the atom
    • addAtomToFragment

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

      protected void insertNullAtoms(int i, int count)
      Insert nulls into the atom array.
      Overrides:
      insertNullAtoms in class MoleculeGraph
      Parameters:
      i - starting index
      count - number of new entries
      Since:
      Marvin 3.4
    • insertNullBonds

      protected void insertNullBonds(int i, int count)
      Insert nulls into the bond array.
      Overrides:
      insertNullBonds in class MoleculeGraph
      Parameters:
      i - starting index
      count - number of new entries
      Since:
      Marvin 3.5.5
    • getBondCount

      public int getBondCount()
      Gets the number of edges in the root structure.
      Overrides:
      getBondCount in class MoleculeGraph
      Returns:
      number of edges
    • getBond

      public MolBond getBond(int i)
      Gets an edge in the graph union.
      Overrides:
      getBond in class MoleculeGraph
      Parameters:
      i - edge index
      Returns:
      the edge object
    • setBond

      @Deprecated public void setBond(int iu, MolBond edge)
      Deprecated.
      as of Marvin 6.2, may constructs inconsistent MoleculeGraph. Use MoleculeGraph.removeBond(MolBond) for bond removal and add(MolBond) for adding a new bond to the molecule.
      Sets the edge at the specified index in the graph union.
      Overrides:
      setBond in class MoleculeGraph
      Parameters:
      iu - the bond index
      edge - the bond
    • replaceBond

      @Deprecated public void replaceBond(MolBond olde, MolBond newe)
      Deprecated.
      as of Marvin 6.2, may constructs inconsistent MoleculeGraph. Use MoleculeGraph.removeBond(MolBond) for bond removal and add(MolBond) for adding a new bond to the molecule.
      Replaces an edge by another one.
      Overrides:
      replaceBond in class MoleculeGraph
      Parameters:
      olde - the old edge
      newe - the new edge
      Since:
      Marvin 4.1, 11/24/2005
    • add

      public void add(MolBond bond)
      Adds a bond to the root structure.
      Overrides:
      add in class Molecule
      Parameters:
      bond - the bond to add
    • indexOf

      public int indexOf(MolAtom node)
      Gets the index of the specified node in the graph union.
      Overrides:
      indexOf in class MoleculeGraph
      Parameters:
      node - the node
      Returns:
      the index, or -1 if not found
    • indexOf

      public int indexOf(MolBond edge)
      Gets the index of the specified edge in the graph union.
      Overrides:
      indexOf in class MoleculeGraph
      Parameters:
      edge - the edge
      Returns:
      the index, or -1 if not found
      See Also:
    • contains

      public boolean contains(MolAtom node)
      Checks if the root structure or an R-group contains the specified node.
      Overrides:
      contains in class Molecule
      Parameters:
      node - the node object
      Returns:
      true if the graph contains the object, false otherwise
    • contains

      public boolean contains(MolBond edge)
      Checks if the root structure or an R-group contains the specified edge.
      Overrides:
      contains in class MoleculeGraph
      Parameters:
      edge - the edge object
      Returns:
      true if the graph contains the object, false otherwise
      See Also:
    • isEmpty

      public boolean isEmpty()
      Ask if the molecule is empty or not.
      Overrides:
      isEmpty in class Molecule
      Returns:
      true if the graph does not contain any nodes or edges.
    • isQuery

      public boolean isQuery()
      Indicates if the molecule has query features.
      Overrides:
      isQuery in class MoleculeGraph
      Returns:
      true if there are R-definitions for this molecule or the root has query features.
      Since:
      Marvin 4.1.2 08/30/2006
      See Also:
    • isAtom

      @Deprecated @SubjectToRemoval(date=JUL_01_2025) public boolean isAtom()
      Deprecated.
      As of Marvin 14.7.7, no replacement.
      Not supported feature.
      Determines whether the structure represents only one atom and an arbitrary number of bonds.
      Overrides:
      isAtom in class MoleculeGraph
      Returns:
      true the root structure represents an atom and there are no R-groups, false otherwise
    • isBond

      @Deprecated @SubjectToRemoval(date=JUL_01_2025) public boolean isBond()
      Deprecated.
      As of Marvin 14.7.7, no replacement.
      Not supported feature.
      Determines whether the structure represents only one bond and zero or two atoms. Determines whether the structure represents only one atom and an arbitrary number of bonds.
      Overrides:
      isBond in class MoleculeGraph
      Returns:
      true if the root structure represents a bond and there are no R-groups, false otherwise
    • isReaction

      public boolean isReaction()
      Checks if the structure represents a reaction or not.
      Overrides:
      isReaction in class Molecule
      Returns:
      true if the root structure is a reaction
      Since:
      Marvin 3.0
    • canBeReactionComponent

      public boolean canBeReactionComponent()
      Tests whether an object of this class can be a reaction component. This implementation returns false, an RgMolecule cannot be a reaction component.
      Overrides:
      canBeReactionComponent in class Molecule
      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
    • hasAtomSet

      public boolean hasAtomSet()
      Tests whether the molecule graph has atom sets.
      Overrides:
      hasAtomSet in class Molecule
      Returns:
      true if there are atom sets, false otherwise
      Since:
      Marvin 4.0, 03/02/2005
    • hasBondSet

      public boolean hasBondSet()
      Tests whether the molecule graph has atom sets.
      Overrides:
      hasBondSet in class MoleculeGraph
      Returns:
      true if there are atom sets, false otherwise
      Since:
      Marvin 4.0, 03/02/2005
    • getMostSimplifiedMolecule

      protected Molecule getMostSimplifiedMolecule()
      Gets the simplified molecule object even if there is a parent document with other objects.
      Overrides:
      getMostSimplifiedMolecule in class Molecule
      Returns:
      the root structure if there are no R-groups present, this otherwise
      Since:
      Marvin 4.1.13, 09/20/2007
    • addRgroupsTo

      public RgMolecule addRgroupsTo(Molecule m)
      Creates an RgMolecule containing R-groups of this object from the 'simplified molecule' object made of 'm'.
      Parameters:
      m - the simple molecule object
      Returns:
      RgMolecule and the specified molecule as root
      Since:
      Marvin 3.1
    • removeAtom

      public void removeAtom(MolAtom node, int cleanupFlags)
      Removes an atom and its bonds from the root structure and from all the R-groups. This method is for internal use only. Use MoleculeGraph.removeAtom(MolAtom) instead unless you are sure what you are doing.
      Overrides:
      removeAtom in class Molecule
      Parameters:
      node - 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 from the root structure. This method is for internal use only. Use MoleculeGraph.removeAtom(MolAtom) instead unless you are sure what you are doing.
      Overrides:
      removeAtom in class Molecule
      Parameters:
      i - the atom index
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • cleanupRemovedRgroupMember

      public void cleanupRemovedRgroupMember(MoleculeGraph m, int f)
      Clean-up after R-group removal.
      Specified by:
      cleanupRemovedRgroupMember in interface chemaxon.struc.RgMoleculeGraphIface
      Parameters:
      m - the removed R-group member
      f - clean-up flags
      Since:
      Marvin 4.1, 11/25/2005
    • removeBond

      protected void removeBond(MolBond edge, int cleanupFlags)
      Remove a bond from the root structure, and from all the R-groups.
      Overrides:
      removeBond in class Molecule
      Parameters:
      edge - the bond
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeBond

      protected void removeBond(int i, int cleanupFlags)
      Remove a bond from the root structure.
      Overrides:
      removeBond in class Molecule
      Parameters:
      i - the bond index
      cleanupFlags - extra clean-up methods
      Since:
      Marvin 3.1
      See Also:
    • removeAllBonds

      public void removeAllBonds()
      Remove all bonds from the root structure, and from all the R-groups.
      Overrides:
      removeAllBonds in class Molecule
    • removeAll

      public void removeAll()
      Remove all the atoms and bonds from the root structure, and from all the R-groups.
      Overrides:
      removeAll in class Molecule
    • isRealAtomParent

      protected boolean isRealAtomParent()
      R-group molecule objects cannot be real node parents.
      Overrides:
      isRealAtomParent in class MoleculeGraph
      Returns:
      false
      Since:
      Marvin 3.0
    • regenBonds

      public void regenBonds()
      Regenerate the edge vectors: remove their elements, then put the edge objects from the nodes into it.
      Overrides:
      regenBonds in class MoleculeGraph
    • sortBondsAccordingTo

      public void sortBondsAccordingTo(MolBond[] order)
      Sort edges in the same order as they appear in the specified array.
      Overrides:
      sortBondsAccordingTo in class MoleculeGraph
      Parameters:
      order - the array
      Since:
      Marvin 3.5, 09/02/2004
    • setLocation

      public void setLocation(DPoint3 p)
      Set the origin of the molecule. The MolAtom coordinates are relative to this origin.
      Overrides:
      setLocation in class MoleculeGraph
      Parameters:
      p - the location
      See Also:
    • fuse

      public void fuse(MoleculeGraph g, boolean check)
      Add the atoms and bonds of another molecule.
      Overrides:
      fuse in class MoleculeGraph
      Parameters:
      g - the other molecule
      check - true if a containment check should be performed to ensure that only those nodes and edges are added that are not already elements - false if the graph is known to be disjoint from this graph and this check can be safely skipped
      Since:
      Marvin 5.0
    • 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 Molecule
      Throws:
      RuntimeException - if inconsistency found
      Since:
      Marvin 5.0, 11/06/2007
    • fuse0

      protected void fuse0(MoleculeGraph graph, boolean check)
      Add those nodes and edges of a graph that are not already elements. If the graph is a reaction and the root structure is not a reaction then the root structure will become a reaction determined by the reaction arrow corresponding to the graph. For each connected component of the graph checks if it contains an atom connected to an R-group in this RgMolecule; if yes then also adds the component to that R-group, otherwise adds it to the root structure.
      Overrides:
      fuse0 in class Molecule
      Parameters:
      graph - the graph that will be fused into this molecule
      check - true if a containment check should be performed to ensure that only those nodes and edges are added that are not already elements - false if the graph is known to be disjoint from this graph and this check can be safely skipped
      Since:
      Marvin 5.0
    • mergeAtoms

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public void mergeAtoms(MolAtom that, MolAtom a)
      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 add the atom to the molecule.
      Overrides:
      mergeAtoms in class Molecule
      Parameters:
      that - the atom
      a - the other atom
    • setSgroupParent

      public void setSgroupParent(MolAtom a, Sgroup sg, boolean set)
      Sets or unsets an S-group as a parent of an atom in the root structure or an R-group.
      Overrides:
      setSgroupParent in class Molecule
      Parameters:
      a - the atom
      sg - the S-group
      set - set (true) or unset (false)
      Throws:
      IllegalArgumentException - if neither root, nor any R-group contains the atom
      Since:
      Marvin 3.0
    • clonecopy

      public void clonecopy(MoleculeGraph g)
      Make another molecule identical to this one. If the target molecule is not an RgMolecule, then only the root structure will be cloned.
      Overrides:
      clonecopy in class Molecule
      Parameters:
      g - the target molecule
    • clonecopy

      public void clonecopy(int[] iatoms, MoleculeGraph g)
      Copies the specified atoms of this graph to another one. The RgMolecule implementation of this method is incomplete, R-groups are not handled.
      Overrides:
      clonecopy in class Molecule
      Parameters:
      iatoms - array of atom indices to copy
      g - the target graph
      Since:
      Marvin 5.0.2, 03/11/2008
    • isSelfReference

      public boolean isSelfReference(MProp p)
      Tests whether the specified property is a self reference to the molecule.
      Overrides:
      isSelfReference in class MoleculeGraph
      Parameters:
      p - the property
      Since:
      Marvin 4.1.6, 02/11/2007
    • fixSelfReferringProperty

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

      @Deprecated public void clonelesscopy(MoleculeGraph g)
      Deprecated.
      as of Marvin 6.3.
      Not supported feature.
      Copy to selection. Make another molecule identical to this one, but do not clone atoms, bonds, and the props.
      Overrides:
      clonelesscopy in class Molecule
      Parameters:
      g - the target molecule
    • getFormula

      public String getFormula()
      Gets the molecular formula in Hill order.
      Overrides:
      getFormula in class MoleculeGraph
      Returns:
      the formula
    • getMass

      public double getMass()
      Calculates the molecular weight of the molecule. Returns 0 if the molecule contains R-group or reaction
      Overrides:
      getMass in class MoleculeGraph
      Returns:
      the molecular weight
    • newInstance

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

      public SelectionMolecule newSelectionMolecule()
      Creates a new SelectionMolecule object appropriate for storing selection from this molecule.
      Overrides:
      newSelectionMolecule in class 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 properties in the root structures.
      Overrides:
      makeItSimilar in class Molecule
      Parameters:
      g - the molecule to change
    • isIncompleteReaction

      public boolean isIncompleteReaction()
      Check whether the reaction is incomplete or not.
      Returns:
      true if something is missing, false if it seems to be okay
      Since:
      Marvin 2.9
    • transform

      public void transform(CTransform3D t, boolean incg)
      Apply a transformation matrix to the atomic coordinates.
      Overrides:
      transform in class Molecule
      Parameters:
      t - the transformation matrix
      incg - increase grinvCC or not
    • getGraphUnion

      public MoleculeGraph getGraphUnion()
      Gets a graph containing all the atoms and bonds.
      Overrides:
      getGraphUnion in class MoleculeGraph
      Returns:
      root.getGraphUnion() if there are no R-groups, getGraphUnionAsSelection() otherwise
      Since:
      Marvin 3.0, 11/11/2002
      See Also:
    • getSubGraphCount

      protected final int getSubGraphCount()
      Gets the number of all "submolecules".
      Overrides:
      getSubGraphCount in class MoleculeGraph
      Returns:
      the number of submolecules
      Since:
      Marvin 4.1.2
      See Also:
    • getSubGraphs

      protected final void getSubGraphs(MoleculeGraph[] arr, int off)
      Gets all "submolecules".
      Overrides:
      getSubGraphs in class MoleculeGraph
      Parameters:
      arr - the output array
      off - offset
      Since:
      Marvin 4.1.2
      See Also:
    • fillSelectionMolecule

      protected void fillSelectionMolecule(SelectionMolecule s)
      Adds all atoms and bonds of the root structure and the R-groups to the specified molecule.
      Overrides:
      fillSelectionMolecule in class Molecule
      Parameters:
      s - the selection molecule
      Since:
      Marvin 3.0, 11/05/2002
    • getLonePairCount

      public int getLonePairCount(int i)
      Gets the number of lone pairs.
      Overrides:
      getLonePairCount in class MoleculeGraph
      Parameters:
      i - atom index
      Returns:
      the number of lone pairs
    • aromatize

      public void aromatize(int method)
      Aromatizes molecule. Changes the bonds.
      Overrides:
      aromatize in class Molecule
      Parameters:
      method - Specifies the algorithm for aromatization. Possible values:
      • AROM_BASIC - Basic aromatization
      • AROM_GENERAL - General (Daylight compatible) aromatization
      Limits:
      • AROM_BASIC: only up to 18 membered rings are checked
      • AROM_GENERAL: no ring system limit
      Throws:
      SecurityException - cannot load module because of a security problem (firewall)
      Since:
      Marvin 3.4, Marvin 4.1
      See Also:
    • aromatize

      public void aromatize(int method, boolean checkAmbiguity)
      Aromatizes molecule. Changes the bonds.
      Overrides:
      aromatize in class Molecule
      Parameters:
      method - Specifies the algorithm for aromatization. Possible values:
      • AROM_BASIC - Basic aromatization
      • AROM_GENERAL - General (Daylight compatible) aromatization
      Limits:
      • AROM_BASIC: only up to 18 membered rings are checked
      • AROM_GENERAL: no ring system limit
      checkAmbiguity - Specifies whether ANY bonds should be considered during aromatization.
      Throws:
      SecurityException - cannot load module because of a security problem (firewall)
      Since:
      Marvin 3.4, Marvin 4.1
      See Also:
    • checkSgroupConsistency

      protected void checkSgroupConsistency()
      Checks the consistency of S-groups.
      Overrides:
      checkSgroupConsistency in class Molecule
      Throws:
      RuntimeException - if inconsistency found
      Since:
      Marvin 5.0, 11/06/2007
    • toString

      public String toString()
      Overrides Object.toString() to ease debugging.
      Overrides:
      toString in class MoleculeGraph
      Returns:
      a string representation of the object
      Since:
      4.1, 11/28/2005
    • sumConservedQuantities

      protected void sumConservedQuantities(MolAtom a, int[] atoms, int sign)
      For internal use only.
      Overrides:
      sumConservedQuantities in class MoleculeGraph
      Since:
      Marvin 4.1.13, 09/19/2007
      See Also:
    • createGearch

      protected chemaxon.struc.gearch.MoleculeGraphGearch createGearch()
      Overrides:
      createGearch in class Molecule
    • getMaxAttachmentPointOrder

      public int getMaxAttachmentPointOrder(int rgroupID)
      Gets the maximal attachment point order of R-group definition molecules specified by an R-group ID. The attachment point order of an R-gruop definition molecule is the maximal attachment point order of its atoms.
      Parameters:
      rgroupID - the rgroup identifier to specify the R-group definition molecules.
      Returns:
      the maximal attachment point order of the definition molecules.
      Since:
      Marvin 5.4
    • clearObjects

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

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

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

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

      public List<MObject> getAllObjects()
      Specified by:
      getAllObjects in interface chemaxon.struc.MObjectContainer
      Overrides:
      getAllObjects in class Molecule
    • getParity

      public int getParity(int i)
      Computes the parity of an atom of the RgMolecule instance based on both the coordinates of the neighboring atoms and the stereo information of the bonds to those. Leaves the imported parity unchanged.
      Overrides:
      getParity in class MoleculeGraph
      Parameters:
      i - the index of the atom whose parity is to be determined
      Returns:
      0 for nonchiral, PARITY_ODD or PARITY_EVEN for atoms of odd or even parity, PARITY_ODD|PARITY_EVEN for atoms whose parity is unspecified or cannot be assigned -as they are defined in MolAtom
      Throws:
      SecurityException - the Parity module cannot be loaded because of security reasons (firewall)
      See Also:
    • getLocalParity

      public int getLocalParity(int i)
      Computes the local parity of an atom of the RgMolecule instance based on both the coordinates of the neighboring atoms and the stereo information of the bonds to those. The molecule symmetry is not checked, so even an atom with same ligands can have parity. Leaves the imported parity unchanged. Contracted sgroups must be expanded to achieve consistent result.
      Overrides:
      getLocalParity in class MoleculeGraph
      Parameters:
      i - the index of the atom whose parity is to be determined
      Returns:
      PARITY_ODD or PARITY_EVEN for atoms of odd or even parity, PARITY_EITHER for atoms with wiggly bond 0 for atoms whose parity is unspecified or not known.
      Throws:
      SecurityException - the Parity module cannot be loaded because of security reasons (firewall)
      See Also:
    • stereoClean

      public boolean stereoClean()
      Reset the wedges of the molecule, based on the actual parity information in 2D remove wedges in 3D. Take care of expanding the molecule if neccessary.
      Overrides:
      stereoClean in class MoleculeGraph
      Returns:
      true if succesful
      See Also:
    • setValenceCheckOptions

      public void setValenceCheckOptions(ValenceCheckOptions options)
      Description copied from class: MoleculeGraph
      Sets the options for valence checking. To just enable/disable valence check in the molecule use MoleculeGraph.setValenceCheckEnabled(boolean). Calling this function with a not null parameter automatically enables the valence check.
      Overrides:
      setValenceCheckOptions in class MoleculeGraph
      Parameters:
      options - the new valence check options
      See Also:
    • getValenceCheckOptions

      public ValenceCheckOptions getValenceCheckOptions()
      Description copied from class: MoleculeGraph
      Returns the options for valence checking. To see if the valence check is enabled on the molecule use MoleculeGraph.isValenceCheckEnabled()
      Overrides:
      getValenceCheckOptions in class MoleculeGraph
      Returns:
      the valence check options
      See Also:
    • canBeCT

      public boolean canBeCT(int i2, int i3, boolean grcheck)
      Determines whether the bond between the specified atoms can be a CIS/TRANS or not. In case of ring bonds the ring sizes of the ring for the existence of CIS/TRANS specific bond should be checked before calling this method as ring sizes are not checked in this method.
      Overrides:
      canBeCT in class MoleculeGraph
      Parameters:
      i2 - index of the first atom
      i3 - index of the second atom
      grcheck - true if check atom equivalences using graph invariants
      Returns:
      true if this is a double bond that can be either CIS, TRANS or EITHER, false otherwise.
      Since:
      Marvin 4.0 1/23/2005
    • getAtomIterator

      public IteratorFactory.AtomIterator getAtomIterator()
      Returns an iterator over the atoms in this molecule in proper sequence.
      Overrides:
      getAtomIterator in class MoleculeGraph
      Returns:
      an iterator over the atoms in this molecule in proper sequencer
      Since:
      Marvin 6.2, 2013.09.09.
    • getBondIterator

      public IteratorFactory.BondIterator getBondIterator()
      Returns an iterator over the bonds in this molecule in proper sequence.
      Overrides:
      getBondIterator in class MoleculeGraph
      Returns:
      an iterator over the bonds in this molecule in proper sequence
      Since:
      Marvin 6.2, 2013.09.09.
    • setRestH

      public void setRestH(int rgroupIndex)
      Sets the restH condition on an R-group definition.
      Parameters:
      rgroupIndex - the index of the R-group definition
    • removeRestH

      public void removeRestH(int rgroupIndex)
      Removes the restH condition from an R-group definition.
      Parameters:
      rgroupIndex - the index of the R-group definition
    • isRestH

      public boolean isRestH(int rgroupIndex)
      Informs whether the restH condition is set to the referenced R-group definition.
      Parameters:
      rgroupIndex - the index of the R-group definition
      Returns:
      true if the restH condition is set false otherwise
    • setDependentRgroupDefinition

      public void setDependentRgroupDefinition(int rgroupIndexIf, int rgroupIndexThen)
      Sets the dependent R-group definition (rgroupIndexThen) for the referenced R-group definition (rgroupIndexIf).
      Parameters:
      rgroupIndexIf - the R-group definition on which the other one depends
      rgroupIndexThen - the R-group definition which depends on the other one
    • getDependentRgroupDefinition

      public int getDependentRgroupDefinition(int rgroupIndex)
      Gets the R-group definition's index which depends on the referenced R-group definition.
      Parameters:
      rgroupIndex - the R-group definition index
      Returns:
      the index of the dependent R-group definition or -1 if none exists
    • removeDependentRgroupDefinition

      public void removeDependentRgroupDefinition(int rgroupIndex)
      Removes the dependent R-group definition of the referenced R-group definition.
      Parameters:
      rgroupIndex - the R-group definition ID
    • getRgroupDisplayLabel

      public String getRgroupDisplayLabel(int rgroupIndex)
      Specified by:
      getRgroupDisplayLabel in interface chemaxon.struc.RgMoleculeGraphIface