Package moss

Class BondTypeMgr

java.lang.Object
moss.TypeMgr
moss.BondTypeMgr
All Implemented Interfaces:
Serializable

public class BondTypeMgr extends TypeMgr
Class for a bond type manager.
Since:
2007.06.20
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    bond type: aromatic
    static final int
    a mask for the type of a bond
    static final int
    bond type: double
    static final int
    a mask, to be anded (bitwise &) with a bond type in order to downgrade an aromatic bond to a single bond
    protected static String[]
    the table of bond names; using the bond type as an index for this table yields a printable bond description
    static final int
    bond type: null bond, that is, a bond that does not actually connect two atoms
    static final int
    a mask, to be anded (bitwise &) with a bond type in order to remove any distinction of bond types
    static final int
    bond type: single
    static final int
    bond type: triple
    static final int
    bond type: unknown
    static final int
    a mask, to be anded (bitwise &) with a bond type in order to upgrade an aromatic bond to a double bond

    Fields inherited from class moss.TypeMgr

    BASEMASK, FLAGMASK, SPECIAL, WILDCARD
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a bond type manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    add(String name)
    Add a bond type.
    static int
    Convert Kekulé representations to true aromatic rings.
    static int
    getBond(int type)
    Extract the raw bond type from a bond type.
    static String
    getBondName(int type)
    Get the name of the bond type.
    int
    Map a bond name to the corresponding code.
    getName(int code)
    Map a code to the corresponding bond name.
    int
    Get the number of managed types.
    static boolean
    isAromatic(int type)
    Check whether a bond type is aromatic.
    static boolean
    isDouble(int type)
    Check whether a bond type is double.
    boolean
    Check whether a type manager is fixed (is not extendable).
    static boolean
    isRing(int type)
    Check whether a bond type specifies a ring bond.
    static boolean
    isSingle(int type)
    Check whether a bond type is single.
    static boolean
    isTriple(int type)
    Check whether a bond type is triple.
    static void
    main(String[] args)
    Main function for testing some basic functionality.

    Methods inherited from class moss.TypeMgr

    getBase, isSpecial, isWildcard

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNKNOWN

      public static final int UNKNOWN
      bond type: unknown
      See Also:
    • NULL

      public static final int NULL
      bond type: null bond, that is, a bond that does not actually connect two atoms
      See Also:
    • SINGLE

      public static final int SINGLE
      bond type: single
      See Also:
    • AROMATIC

      public static final int AROMATIC
      bond type: aromatic
      See Also:
    • DOUBLE

      public static final int DOUBLE
      bond type: double
      See Also:
    • TRIPLE

      public static final int TRIPLE
      bond type: triple
      See Also:
    • BONDMASK

      public static final int BONDMASK
      a mask for the type of a bond
      See Also:
    • SAMETYPE

      public static final int SAMETYPE
      a mask, to be anded (bitwise &) with a bond type in order to remove any distinction of bond types
      See Also:
    • DOWNGRADE

      public static final int DOWNGRADE
      a mask, to be anded (bitwise &) with a bond type in order to downgrade an aromatic bond to a single bond
      See Also:
    • UPGRADE

      public static final int UPGRADE
      a mask, to be anded (bitwise &) with a bond type in order to upgrade an aromatic bond to a double bond
      See Also:
    • names

      protected static String[] names
      the table of bond names; using the bond type as an index for this table yields a printable bond description
  • Constructor Details

    • BondTypeMgr

      public BondTypeMgr()
      Create a bond type manager.
      Since:
      2007.06.21 (Christian Borgelt)
  • Method Details

    • isFixed

      public boolean isFixed()
      Check whether a type manager is fixed (is not extendable).
      Specified by:
      isFixed in class TypeMgr
      Returns:
      true, because the bond types are fixed
      Since:
      2009.08.13 (Christian Borgelt)
    • getTypeCount

      public int getTypeCount()
      Get the number of managed types.
      Specified by:
      getTypeCount in class TypeMgr
      Returns:
      the number of types in this type manager
      Since:
      2020.10.16 (Christian Borgelt)
    • add

      public int add(String name)
      Add a bond type.

      The set of bond types is fixed and cannot be extended. Therefore this function behaves exactly like the function getCode() and returns -1 for an unknown name.

      Specified by:
      add in class TypeMgr
      Parameters:
      name - the name of the bond
      Returns:
      the code of the bond or -1 if the name is no bond
      Since:
      2007.06.21 (Christian Borgelt)
      See Also:
    • getCode

      public int getCode(String name)
      Map a bond name to the corresponding code.
      Specified by:
      getCode in class TypeMgr
      Parameters:
      name - the name of the bond
      Returns:
      the code of the bond or -1 if the name is not a bond description
      Since:
      2007.06.20 (Christian Borgelt)
    • getName

      public String getName(int code)
      Map a code to the corresponding bond name.
      Specified by:
      getName in class TypeMgr
      Parameters:
      code - the code of the bond
      Returns:
      the name of the bond or -1 if the name is not a bond description
      Since:
      2007.06.20 (Christian Borgelt)
    • getBond

      public static int getBond(int type)
      Extract the raw bond type from a bond type.

      The raw bond type is only part of the type of a bond. The full type of a bond also includes a ring flag.

      Parameters:
      type - the type from which to extract the bond type
      Returns:
      the bond type without a possible ring flag
      Since:
      2006.10.31/2007.06.20 (Christian Borgelt)
    • getBondName

      public static String getBondName(int type)
      Get the name of the bond type.
      Parameters:
      type - the bond type for which to get the name
      Returns:
      the name of the bond type
      Since:
      2006.30.31/2007.06.20 (Christian Borgelt)
    • isSingle

      public static boolean isSingle(int type)
      Check whether a bond type is single.
      Parameters:
      type - the type to check
      Returns:
      whether the bond type is single
      Since:
      2009.08.13 (Christian Borgelt)
    • isAromatic

      public static boolean isAromatic(int type)
      Check whether a bond type is aromatic.
      Parameters:
      type - the type to check
      Returns:
      whether the bond type is aromatic
      Since:
      2009.08.13 (Christian Borgelt)
    • isDouble

      public static boolean isDouble(int type)
      Check whether a bond type is double.
      Parameters:
      type - the type to check
      Returns:
      whether the bond type is double
      Since:
      2009.08.13 (Christian Borgelt)
    • isTriple

      public static boolean isTriple(int type)
      Check whether a bond type is triple.
      Parameters:
      type - the type to check
      Returns:
      whether the bond type is triple
      Since:
      2009.08.13 (Christian Borgelt)
    • isRing

      public static boolean isRing(int type)
      Check whether a bond type specifies a ring bond.
      Parameters:
      type - the bond type to check
      Returns:
      whether the bond type specifies a ring
      Since:
      2009.08.13 (Christian Borgelt)
    • aromatize

      public static int aromatize(Graph mol)
      Convert Kekulé representations to true aromatic rings.

      In a Kekulé representation an aromatic ring with 6 edges is coded with alternating single and double edges. In this function such Kekulé representations are found and turned into true aromatic rings (actual aromatic bonds).

      Parameters:
      mol - the molecule in which to convert aromatic rings
      Returns:
      the number of converted rings
      Since:
      2003.07.11 (Christian Borgelt)
    • main

      public static void main(String[] args)
      Main function for testing some basic functionality.

      It is tried to parse the first command line argument as a bond description and the resulting code is reported.

      Parameters:
      args - the command line arguments
      Since:
      2007.06.21 (Christian Borgelt)