Class CompoundFileHelper

  • Direct Known Subclasses:
    FileHelper

    public abstract class CompoundFileHelper
    extends java.lang.Object
    • Constructor Detail

      • CompoundFileHelper

        public CompoundFileHelper()
    • Method Detail

      • selectOption

        public abstract java.lang.String selectOption​(java.lang.String message,
                                                      java.lang.String title,
                                                      java.lang.String[] option)
      • selectFileToOpen

        public abstract java.io.File selectFileToOpen​(java.lang.String title,
                                                      int filetypes)
      • selectFileToSave

        public abstract java.lang.String selectFileToSave​(java.lang.String title,
                                                          int filetype,
                                                          java.lang.String newFileName)
      • showMessage

        public abstract void showMessage​(java.lang.String message)
      • getCurrentDirectory

        public static java.io.File getCurrentDirectory()
      • setCurrentDirectory

        public static void setCurrentDirectory​(java.io.File d)
      • readStructuresFromFile

        public java.util.ArrayList<StereoMolecule> readStructuresFromFile​(boolean readIdentifier)
      • readIDCodesFromFile

        public java.util.ArrayList<java.lang.String> readIDCodesFromFile()
      • readStructuresFromFile

        public java.util.ArrayList<StereoMolecule> readStructuresFromFile​(java.io.File file,
                                                                          boolean readIdentifier)
      • readIDCodesFromFile

        public java.util.ArrayList<java.lang.String> readIDCodesFromFile​(java.io.File file)
        Reads all compounds as idcode list from the given file.
        Parameters:
        file - SD- or DataWarrior file
        Returns:
      • readIDCodesWithNamesFromFile

        public java.util.ArrayList<java.lang.String[]> readIDCodesWithNamesFromFile​(java.io.File file,
                                                                                    boolean readIDCoords)
        Reads all compounds as idcode list with identifiers from the given file. Therefore, it asks for an identifier column.
        Parameters:
        file - if null the user is asked for a file
        readIDCoords - if true, then the id-coords are SPACE delimited attached to the idcode
        Returns:
        list of String[2] with idcode (index 0) and molecule name (index 1)
      • getRecordCount

        public int getRecordCount()
      • getErrorCount

        public int getErrorCount()
      • createFileFilter

        public static CompoundFileFilter createFileFilter​(int filetypes,
                                                          boolean isSaving)
      • getExtension

        public static java.lang.String getExtension​(java.io.File file)
        Return the extension portion of the file's name. Known joint extensions (currently only ".sdf.gz") are returned where they exist.
        Returns:
        extension without the dot
      • removePathAndExtension

        public static java.lang.String removePathAndExtension​(java.lang.String filePath)
        Provided that fileName has a leading file path, then path and separator are removed. Provided that fileName has a recognized extension, then the extension is removed.
        Parameters:
        filePath - file name with or without complete path and with or without extension
        Returns:
        naked file name without leading path and extension
      • removeExtension

        public static java.lang.String removeExtension​(java.lang.String filePath)
        Provided that filePath has a recognized extension, then the extension is removed.
        Parameters:
        filePath - file name with or without complete path and with or without extension
        Returns:
        file name or path without extension
      • getFileType

        public static int getFileType​(java.lang.String filename)
      • getExtensionList

        public java.util.ArrayList<java.lang.String> getExtensionList​(int fileTypes)
        Parameters:
        fileTypes -
        Returns:
        list of all extensions that are covered by fileTypes
      • getExtension

        public static java.lang.String getExtension​(int filetype)
        Parameters:
        filetype -
        Returns:
        file extension including the dot
      • saveRXNFile

        public void saveRXNFile​(Reaction rxn)