Class IDCodeParserWithoutCoordinateInvention

  • Direct Known Subclasses:
    IDCodeParser

    public class IDCodeParserWithoutCoordinateInvention
    extends java.lang.Object
    Typically you should use IDCodeParser instead of this class. You may instantiate this class if you need to avoid a dependency to the CoordinateInventor and if you pass encoded coordinates together with any idcode for parsing. We needed to introduce this class to avoid a cyclic dependency between the IDCodeParser and the CoordinateInventor: If encoded atom coords are not given, then the IDcodeParser needs to invent then in order to assign proper up-/down-bonds. The CoordinateInventor needs the IDCodeParser to unpack its default template list.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean coordinatesAre3D​(byte[] idcode, byte[] coordinates)  
      boolean coordinatesAre3D​(byte[] idcode, byte[] coordinates, int idcodeStart, int coordsStart)  
      boolean coordinatesAre3D​(java.lang.String idcode, java.lang.String coordinates)  
      boolean coordinatesAreAbsolute​(byte[] coordinates)  
      boolean coordinatesAreAbsolute​(byte[] coordinates, int coordStart)  
      boolean coordinatesAreAbsolute​(java.lang.String coordinates)  
      protected boolean ensure2DCoordinates()  
      int[] getAtomAndBondCounts​(byte[] idcode, int offset, int[] count)
      Determines atom and bond counts of the given idcode
      int[] getAtomAndBondCounts​(java.lang.String idcode, int[] count)
      Determines atom and bond counts of the given idcode
      int getAtomCount​(byte[] idcode, int offset)  
      int getAtomCount​(java.lang.String idcode)  
      StereoMolecule getCompactMolecule​(byte[] idcode)
      Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule.
      StereoMolecule getCompactMolecule​(byte[] idcode, byte[] coordinates)
      Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule.
      StereoMolecule getCompactMolecule​(byte[] idcode, byte[] coordinates, int idcodeStart, int coordsStart)  
      StereoMolecule getCompactMolecule​(byte[] idcode, int idcodeStart)  
      StereoMolecule getCompactMolecule​(java.lang.String idcode)
      Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule.
      StereoMolecule getCompactMolecule​(java.lang.String idcode, java.lang.String coordinates)
      Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule.
      int getIDCodeVersion​(byte[] idcode)  
      int getIDCodeVersion​(java.lang.String idcode)  
      protected void inventCoordinates​(StereoMolecule mol)  
      void neglectSpaceDelimitedCoordinates()
      IDCodeParsers allow passing idcode and coordinates as one String with a space as separator in between.
      void parse​(StereoMolecule mol, byte[] idcode)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parse​(StereoMolecule mol, byte[] idcode, byte[] coordinates)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parse​(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idcodeStart, int coordsStart)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parse​(StereoMolecule mol, byte[] idcode, int idcodeStart)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parse​(StereoMolecule mol, java.lang.String idcode)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parse​(StereoMolecule mol, java.lang.String idcode, java.lang.String coordinates)
      Parses the idcode and populates the given molecule to represent the passed idcode.
      void parseCoordinates​(byte[] encodedCoords, int coordsStart, StereoMolecule mol, Coordinates[] coords)
      This method parses an id-coordinate string (new format only) and writes the coordinates into a Coordinates array.
      void parseMapping​(byte[] mapping)  
      void parseMapping​(byte[] mapping, int mappingStart)  
      void printContent​(byte[] idcode, byte[] coordinates)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IDCodeParserWithoutCoordinateInvention

        public IDCodeParserWithoutCoordinateInvention()
    • Method Detail

      • ensure2DCoordinates

        protected boolean ensure2DCoordinates()
      • neglectSpaceDelimitedCoordinates

        public void neglectSpaceDelimitedCoordinates()
        IDCodeParsers allow passing idcode and coordinates as one String with a space as separator in between. If an idcode is followed by a space and more, and if the following shall not be interpreted as encoded coordinates, then call this method after instantiation.
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(java.lang.String idcode)
        Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule. Use this to conserve memory if no atoms or bonds are added to the molecule afterwards. This version of the method allows to pass idcode and atom coordinates in one String object.
        Parameters:
        idcode - null or idcode, which may contain coordinates separated by a space character
        Returns:
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(byte[] idcode)
        Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule. Use this to conserve memory if no atoms or bonds are added to the molecule afterwards.
        Parameters:
        idcode - may be null
        Returns:
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(java.lang.String idcode,
                                                 java.lang.String coordinates)
        Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule. Use this to conserve memory if no atoms or bonds are added to the molecule afterwards.
        Parameters:
        idcode - may be null
        coordinates - may be null
        Returns:
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(byte[] idcode,
                                                 byte[] coordinates)
        Creates and returns a molecule from the idcode with its atom and bond arrays being just as large as needed to hold the molecule. Use this to conserve memory if no atoms or bonds are added to the molecule afterwards.
        Parameters:
        idcode - may be null
        coordinates - may be null
        Returns:
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(byte[] idcode,
                                                 int idcodeStart)
      • getCompactMolecule

        public StereoMolecule getCompactMolecule​(byte[] idcode,
                                                 byte[] coordinates,
                                                 int idcodeStart,
                                                 int coordsStart)
      • parse

        public void parse​(StereoMolecule mol,
                          java.lang.String idcode)
        Parses the idcode and populates the given molecule to represent the passed idcode. This version of the method allows to pass idcode and atom coordinates in one String object.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - null or idcode, which may contain coordinates separated by a space character
      • parse

        public void parse​(StereoMolecule mol,
                          byte[] idcode)
        Parses the idcode and populates the given molecule to represent the passed idcode.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - null or valid idcode optionally concatenates with SPACE and encoded coordinates
      • parse

        public void parse​(StereoMolecule mol,
                          java.lang.String idcode,
                          java.lang.String coordinates)
        Parses the idcode and populates the given molecule to represent the passed idcode.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - may be null
        coordinates - may be null
      • parse

        public void parse​(StereoMolecule mol,
                          byte[] idcode,
                          byte[] coordinates)
        Parses the idcode and populates the given molecule to represent the passed idcode.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - may be null
        coordinates - may be null
      • parse

        public void parse​(StereoMolecule mol,
                          byte[] idcode,
                          int idcodeStart)
        Parses the idcode and populates the given molecule to represent the passed idcode.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - may be null
        idcodeStart - first byte index of idcode
      • parse

        public void parse​(StereoMolecule mol,
                          byte[] idcode,
                          byte[] coordinates,
                          int idcodeStart,
                          int coordsStart)
        Parses the idcode and populates the given molecule to represent the passed idcode.
        Parameters:
        mol - molecule object to be filled with the idcode content
        idcode - may be null
        coordinates - may be null
        idcodeStart - first byte index of idcode
        coordsStart - first byte indexif coordinates
      • inventCoordinates

        protected void inventCoordinates​(StereoMolecule mol)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • parseCoordinates

        public void parseCoordinates​(byte[] encodedCoords,
                                     int coordsStart,
                                     StereoMolecule mol,
                                     Coordinates[] coords)
                              throws java.lang.Exception
        This method parses an id-coordinate string (new format only) and writes the coordinates into a Coordinates array. If the id-coordinates contain implicit hydrogen coordinates, then this method does not(!!!) add these hydrogen atoms to the Molecule. Thus, for 3D-coordinates with implicit hydrogen coordinates, you need to make sure that all of the Molecule's hydrogen atoms are explicit and that the Coordinates array's size covers all hydrogens atoms. For instance, if parsing idcodes and coordinates of a conformer set, you may parse the first conformer with one of the getCompactMolecule() or parse() methods. This adds all implicit hydrogens as explicit ones to the Molecule and conformer object. All subsequent conformers may be generated by instantiating a new Conformer from the molecule and using this method to populate its coordinates.
        Parameters:
        encodedCoords - id-coordinates string in new format
        coordsStart - offset
        mol - Molecule with all hydrogens being explicit
        coords - Coordinates array to be populated by coordinates taken from encoded string
        Throws:
        java.lang.Exception
      • parseMapping

        public void parseMapping​(byte[] mapping)
      • parseMapping

        public void parseMapping​(byte[] mapping,
                                 int mappingStart)
      • coordinatesAre3D

        public boolean coordinatesAre3D​(java.lang.String idcode,
                                        java.lang.String coordinates)
      • coordinatesAre3D

        public boolean coordinatesAre3D​(byte[] idcode,
                                        byte[] coordinates)
      • coordinatesAre3D

        public boolean coordinatesAre3D​(byte[] idcode,
                                        byte[] coordinates,
                                        int idcodeStart,
                                        int coordsStart)
      • coordinatesAreAbsolute

        public boolean coordinatesAreAbsolute​(java.lang.String coordinates)
      • coordinatesAreAbsolute

        public boolean coordinatesAreAbsolute​(byte[] coordinates)
      • coordinatesAreAbsolute

        public boolean coordinatesAreAbsolute​(byte[] coordinates,
                                              int coordStart)
      • getIDCodeVersion

        public int getIDCodeVersion​(java.lang.String idcode)
      • getIDCodeVersion

        public int getIDCodeVersion​(byte[] idcode)
      • getAtomCount

        public int getAtomCount​(java.lang.String idcode)
      • getAtomCount

        public int getAtomCount​(byte[] idcode,
                                int offset)
      • getAtomAndBondCounts

        public int[] getAtomAndBondCounts​(java.lang.String idcode,
                                          int[] count)
        Determines atom and bond counts of the given idcode
        Parameters:
        idcode -
        count - null or int[2], which is filled and returned
        Returns:
        int[] with atom and bond count as first and second values
      • getAtomAndBondCounts

        public int[] getAtomAndBondCounts​(byte[] idcode,
                                          int offset,
                                          int[] count)
        Determines atom and bond counts of the given idcode
        Parameters:
        idcode -
        offset -
        count - null or int[2], which is filled and returned
        Returns:
        int[] with atom and bond count as first and second values
      • printContent

        public void printContent​(byte[] idcode,
                                 byte[] coordinates)