Class MolBond

java.lang.Object
chemaxon.struc.MolBond
All Implemented Interfaces:
StereoConstants, Serializable
Direct Known Subclasses:
QueryBond

@PublicAPI public class MolBond extends Object implements StereoConstants, Serializable
Chemical bond.
See Also:
  • Field Details

  • Constructor Details

    • MolBond

      public MolBond(MolAtom a1, MolAtom a2, int f)
      Construct a bond between two atoms.
      Parameters:
      a1 - the first atom
      a2 - the second atom
      f - bond type and other flags
    • MolBond

      protected MolBond(MolBond b)
      Copy constructor.
      Parameters:
      b - the original bond
      Since:
      3.5.2, 12/15/2004
    • MolBond

      public MolBond(MolAtom a1, MolAtom a2)
      Construct a single bond between two atoms.
      Parameters:
      a1 - the first atom
      a2 - the second atom
  • Method Details

    • getParent

      public final MoleculeGraph getParent()
      Gets the parent graph.
      Returns:
      the parent graph
    • swap

      public void swap()
      Change orientation.
    • getAtom1

      public MolAtom getAtom1()
      Gets the first endpoint.
      Returns:
      the first endpoint
    • getAtom2

      public MolAtom getAtom2()
      Gets the second endpoint.
      Returns:
      the second endpoint
    • getOtherAtom

      public final MolAtom getOtherAtom(MolAtom atom)
      Gets the other end of the bond.
      Parameters:
      atom - one of the bond endpoints
      Returns:
      the other endpoint, or null if the given atom is not an endpoint for this bond
      Since:
      Marvin 3.0
    • contains

      public boolean contains(MolAtom atom)
    • getLength

      public final double getLength()
      Gets the actual length of the bond.
      Returns:
      the distance between the two atoms
    • getFlags

      public final int getFlags()
      Gets bond type (4 bits), stereo (2+2+1 bits), topology (2 bits), bond set (5 bits) and reacting center (7 bits) information.
      Returns:
      the flags
      See Also:
    • setFlags

      public void setFlags(int f)
      Sets bond type (4 bit), stereo (2+2+1 bit), topology (2 bit) bond set (5 bit) and reacting center (7 bits) information. Bond type can be set by calling
       b.setFlags((b.getFlags() & ~MolBond.TYPE_MASK) | type);
       
      Valence checking is omitted if you set the bond type this way, without setType.
      Parameters:
      f - the flags
      Since:
      Marvin 2.5
      See Also:
    • setFlags

      public void setFlags(int f, int mask)
      Sets bond type (3 bit), stereo (2+2+1 bit), and topology (2 bit) information. Bond type can be set by calling
       b.setFlags(type, MolBond.TYPE_MASK);
       
      Valence checking is omitted if you set the bond type this way, without setType.
      Parameters:
      f - new value of the specified bits
      mask - bits to set
      See Also:
    • getType

      public final int getType()
      Gets the bond type. Possible values: 1 (single), 2 (double), 3 (triple), aromatic, coordinate, conjugated and query bond types.
      Returns:
      the bond type
      See Also:
    • getBondType

      public final chemaxon.struc.BondType getBondType()
      Gets the type of the bond.
      Returns:
      the bond type of the bond
    • setType

      public void setType(int t)
      Sets bond type and does valence checking for the endpoints.
      Parameters:
      t - the new bond type
      See Also:
    • getSetSeq

      public final int getSetSeq()
      Gets the bond set.
      Returns:
      a number between 0 and SETSEQ_MAX
      Since:
      Marvin 3.3
    • setSetSeq

      public final void setSetSeq(int g)
      Sets the bond set.
      Parameters:
      g - a number between 0 and SETSEQ_MAX
      Since:
      Marvin 3.3
    • isConjugated

      public final boolean isConjugated()
      Gets the conjugation state of the bond set by the conjugation modul.
      Returns:
      true if the bond is a member of a conjugated system, false otherwise
      Since:
      Marvin 4.1, 06/13/2006
    • isCoordinate

      public final boolean isCoordinate()
      Tests whether the bond is coordinate.
      Returns:
      true if it is coordinate bond, false otherwise
      Since:
      Marvin 5.0, 12/04/2007
    • isPositionVariation

      public final boolean isPositionVariation()
      Decides whether this bond is a position variation bond.
      Returns:
      true if this is a position variation bond, false otherwise
      Since:
      Marvin 5.3, 01/05/2010
    • isBold

      public final boolean isBold()
      Decides whether this bond is bold or not.
      Returns:
      true if this bond is bold, false otherwise
      Since:
      Marvin 5.3, 09/24/2009
      See Also:
    • isHashed

      public final boolean isHashed()
      Decides whether this bond is hashed or not.
      Returns:
      true if this bond is hashed, false otherwise
      Since:
      Marvin 5.7
      See Also:
    • calcOrderFromLength

      public int calcOrderFromLength()
      Calculate the bond order from the atomic distances. The returned value should only be considered as an approximation.
      Returns:
      the bond order
    • calcOrderFromValence

      public final int calcOrderFromValence()
      Calculate bond order from the types and charges of the two atoms.
      Returns:
      the bond order
    • cloneBond

      public MolBond cloneBond(MolAtom a1, MolAtom a2)
      Clones this bond. The parent molecule and the end atoms are not cloned.
      Parameters:
      a1 - new end atom 1
      a2 - new end atom 2
      Returns:
      the clone
      Since:
      Marvin 4.1, 09/22/2005
    • clone

      public Object clone()
      Make a copy of this object. These are not cloned:
      • End Atoms;
      • Parent molecule;
      • MDocument: Although the bondset information is cloned, when the cloned bond is taken to another MDocument, the format (color, font type) will be lost.
      Overrides:
      clone in class Object
      Returns:
      the clone
    • getDesiredLength

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public double getDesiredLength()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.11, replaced by desiredLength(int, int, int, int).
      Desired length of a bond between two atoms in Angstroms. Works only for bonds in a molecule.
      Returns:
      the desired length
    • getDesiredLength

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public double getDesiredLength(boolean shortenHbonds)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.11, replaced by desiredLength(int, int, int, int).
      Desired length of a bond between two atoms in Angstroms. Works only for bonds in a molecule.
      Parameters:
      shortenHbonds - use 1.0 as bond length for explicit H bonds in 2D.
      Returns:
      the desired length
    • desiredLength

      public static double desiredLength(int atno1, int atno2, int type, int dim)
      Desired length of a bond between two atoms in Angstroms.
      Parameters:
      atno1 - atomic number of the first atom
      atno2 - atomic number of the second atom
      type - bond order
      dim - space dimension, 2 or 3
      Returns:
      the desired length
    • getStereo1

      public final int getStereo1(MolAtom o)
      Gets wedge bond type relative to the specified chiral atom.
      Parameters:
      o - the chiral atom
      Returns:
      the wedge bond type or zero
      See Also:
    • getCTAtom1

      public final MolAtom getCTAtom1()
      Gets the first atom for cis/trans stereo calculation.
      Returns:
      atom a1 from a1-a2=a3-a4, or null in other configurations
      See Also:
    • getCTAtom4

      public final MolAtom getCTAtom4()
      Gets the fourth atom for cis/trans stereo calculation.
      Returns:
      atom a4 from a1-a2=a3-a4, or null in other configurations
      See Also:
    • setStereo2Flags

      public void setStereo2Flags(MolAtom a1, MolAtom a4, int stereo2)
      Sets double bond stereo information. Normally invoked by the SMILES import process.
      Parameters:
      a1 - atom number 1 in scheme a1-a2=a3-a4
      a4 - atom number 4
      stereo2 - CIS/TRANS information
      See Also:
    • transformCT

      public int transformCT(MolAtom a1, MolAtom a4, int f)
      Transform cis/trans stereo information into the `reference frame' of this bond. a1 == null and/or a4 == null is also accepted, null corresponds to any neighbor of a2 or a4 that is different than the reference atoms (the first ligands).
      Parameters:
      a1 - atom connected to atom1
      a4 - atom connected to atom2
      f - original flags
      Returns:
      the transformed flags
    • calcStereo2

      public int calcStereo2()
      Computes the stereochemistry of the bond based on the atomic coordinates. Note that this member function does not change the stereo flags. Bond type is not checked.
      Returns:
      0, CIS, TRANS, or CIS|TRANS
      See Also:
    • calcStereo2

      public int calcStereo2(MolAtom atom1, MolAtom atom4)
      Computes the stereochemistry of the bond based on the atomic coordinates. Note that this member function does not change the stereo flags. Bond type and connectivity are not checked (thus being bound to this bond is not a requirement for atoms a1 and a4).
      Parameters:
      atom1 - atom number 1 in scheme a1-a2=a3-a4
      atom4 - atom number 4
      Returns:
      0, CIS, TRANS, or CIS|TRANS
      See Also:
    • calcStereo2

      public static int calcStereo2(MolAtom atom1, MolAtom atom2, MolAtom atom3, MolAtom atom4)
      Computes the stereochemistry of the atom sequence (scheme a1-a2=a3-a4) based on the atomic coordinates. Note that this member function does not change any stereo flags. Connectivity are not checked.
      Parameters:
      atom1 - atom number 1 in scheme a1-a2=a3-a4
      atom2 - atom number 2 in scheme a1-a2=a3-a4
      atom3 - atom number 3 in scheme a1-a2=a3-a4
      atom4 - atom number 4 in scheme a1-a2=a3-a4
      Returns:
      0, CIS, TRANS, or CIS|TRANS
      See Also:
    • stepWedge

      public boolean stepWedge()
      Set the bond from 0 to UP or UP to DOWN.
      Returns:
      true if the initial state was 0 or UP, false after DOWN.
    • getQuerystr

      public String getQuerystr()
      Gets the query properties.
      Returns:
      the query string
      Since:
      Marvin 3.4
    • haveEqualProperties

      public boolean haveEqualProperties(MolBond b)
      Tests whether two bonds have the same properties. Two bonds have equal properties if their flags are equal.
      Returns:
      true if they have the same properties, false otherwise
      Since:
      Marvin 3.4.1, 07/06/2004
    • overridesAtMerge

      protected boolean overridesAtMerge(MolBond e)
      Checks if this bond should override another one when two structures are merged. Aromatic bonds override non-aromatic bonds, higher order bonds override lower order bonds.
      Parameters:
      e - the other bond
      Returns:
      true if it overrides e, false otherwise
      Since:
      Marvin 3.5, 09/30/2004
    • isQuery

      public final boolean isQuery()
      Tests whether it is query bond or has query property:
      • any
      • single or double
      • single or aromatic
      • double or aromatic
      • smarts bond
      • ring or chain topology
      For more information on smarts bond and query bonds, see The JChem Query Guide
      Returns:
      true if the bond has a query bond type or property, false otherwise
      Since:
      Marvin 3.4
      See Also:
    • isCollinear

      public boolean isCollinear(MolAtom atom)
      Returns whether atom is collinear with the bond or not. (Calculates from coordinates.)
      Parameters:
      atom - Atom to decide about.
      Returns:
      true if atom and the atoms of the bond lie on the same line
      Since:
      Marvin 4.0 12/16/2004
    • getLock

      protected final Object getLock()
      Gets lock object for synchronization.
      Returns:
      reference to the top parent graph
    • toString

      public String toString()
      Overrides Object.toString() to ease debugging.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object
      Since:
      Marvin 5.0 12/10/2007
    • propertySet

      public Set<Map.Entry<String,Object>> propertySet()
      Returns a set view of the properties (property key - property value mappings) of this bond. Each element in the returned set is a Map.Entry. Changes to the properties are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding property from this, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
      Returns:
      set view of the properties of this bond.
      Since:
      Marvin 5.10
    • propertyKeySet

      public Set<String> propertyKeySet()
      Returns a set view of the property keys of this bond. Changes to the properties of this bond are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding property from this atom, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
      Returns:
      set view of the property keys of this bond.
      Since:
      Marvin 5.10
    • containsPropertyKey

      public boolean containsPropertyKey(String key)
      Returns true if this bond has a mapping for the specified property key.
      Parameters:
      key - the property key which is to be searched for.
      Returns:
      true if this map contains a mapping for the specified property key.
      Since:
      Marvin 5.10
    • removeProperty

      public Object removeProperty(String key)
      Removes the mapping for this property key from this bond if present.
      Parameters:
      key - property key whose mapping is to be removed from the bond.
      Returns:
      previous poperty value associated with specified property key, or null if there was no mapping for property key. A null return can also indicate that the property mapping previously associated null with the specified property key.
      Since:
      Marvin 5.10
    • propertyCount

      public int propertyCount()
      Returns the number of property (property key - property value) mappings of this bond.
      Returns:
      the number of property mappings of this bond.
      Since:
      Marvin 5.10
    • getProperty

      public Object getProperty(String key)
      Returns the property value to which the specified property key is mapped at this bond, or null if this bond has no mapping for this property key. A return value of null does not necessarily indicate that the bond has no mapping for the property key; it is also possible that the bond explicitly maps the property key to null. The containsKey method may be used to distinguish these two cases.
      Parameters:
      key - the property key whose associated property value is to be returned.
      Returns:
      the property value to which this bond maps the specified property key, or null if the bond has no mapping for this property key.
      Since:
      Marvin 5.10
    • putProperty

      public void putProperty(String key, Object value)
      Associates the specified value with the specified key at this bond. If this bond previously had a mapping for this property key, the old property value is replaced.
      Parameters:
      key - property key with which the specified value is to be associated.
      value - property value to be associated with the specified property key.
      Since:
      Marvin 5.10
    • clearProperties

      public void clearProperties()
      Removes all properties from this bond.
      Since:
      Marvin 5.10