Class FileNaming

  • Direct Known Subclasses:
    WorkflowFileNaming

    public class FileNaming
    extends Object
    This class contains methods to create workflow data file names.
    Since:
    2.0
    Author:
    Laurent Jourdren
    • Constructor Detail

      • FileNaming

        protected FileNaming()
        Private constructor.
    • Method Detail

      • getStepId

        public String getStepId()
        Get Step Id.
        Returns:
        the step Id
      • getPortName

        public String getPortName()
        Get the port name.
        Returns:
        the port name
      • getDataName

        public String getDataName()
        Get the data name.
        Returns:
        the data name
      • getSampleNumber

        public int getSampleNumber()
        Get the sample number related to the data. This value is only use when generate compatible filenames.
        Returns:
        the number of the sample related to the file or -1 if not known
      • getFormat

        public DataFormat getFormat()
        Get the format.
        Returns:
        the format
      • getFileIndex

        public int getFileIndex()
        Get the file index.
        Returns:
        the file index
      • getPart

        public int getPart()
        Get the file part.
        Returns:
        the file part
      • getCompression

        public fr.ens.biologie.genomique.kenetre.io.CompressionType getCompression()
        Get the compression.
        Returns:
        the compression
      • setStepId

        public void setStepId​(String stepId)
        Set the step id.
        Parameters:
        stepId - the step id
      • setPortName

        public void setPortName​(String portName)
        Set the port name.
        Parameters:
        portName - the port name
      • setDataName

        public void setDataName​(String dataName)
        Set the data name.
        Parameters:
        dataName - the data name
      • setSampleNumber

        public void setSampleNumber​(int sampleNumber)
        Set the sample number related to the data. This value is only use when generate compatible filenames.
        Parameters:
        sampleNumber - the number of the sample related to the file or -1 if not known
      • setFormat

        public void setFormat​(DataFormat format)
        Set the format.
        Parameters:
        format - the format
      • setFileIndex

        public void setFileIndex​(int fileIndex)
        Set the file index.
        Parameters:
        fileIndex - the file index
      • setPart

        public void setPart​(int part)
        Set the part number.
        Parameters:
        part - the part number
      • setCompression

        public void setCompression​(fr.ens.biologie.genomique.kenetre.io.CompressionType compression)
        Set the compression
        Parameters:
        compression - the compression type
      • set

        protected void set​(Data data)
        Set several field of the object from a Data object.
        Parameters:
        data - the data object
      • filePrefix

        public String filePrefix()
        Return the file prefix.
        Returns:
        a string with the file prefix
      • fileSuffix

        public String fileSuffix()
        Return the file suffix.
        Returns:
        q string with the file suffix
      • fileMiddle

        public String fileMiddle()
        Return the middle string of the filename.
        Returns:
        a string with the middle string of the filename
      • filename

        public String filename()
        Return the filename.
        Returns:
        a string with the filename
      • glob

        public String glob()
        Get a glob for the filename.
        Returns:
        a glob in a string
      • compatibilityFilename

        public String compatibilityFilename()
        Return the filename using Eoulsan 1.x naming.
        Returns:
        a string with the filename using Eoulsan 1.x naming
      • filePrefix

        public static String filePrefix​(String stepId,
                                        String portName,
                                        DataFormat format)
        Create the prefix of a filename.
        Parameters:
        stepId - step id
        portName - port name
        format - format of the file
        Returns:
        a String with the prefix of the file
      • filePrefix

        public static String filePrefix​(String stepId,
                                        String portName,
                                        String formatPrefix)
        Create the prefix of a filename.
        Parameters:
        stepId - step id
        portName - port name
        formatPrefix - format prefix of the file
        Returns:
        a String with the prefix of the file
      • fileMiddle

        public static String fileMiddle​(String dataName,
                                        int fileIndex,
                                        int part)
        Create the middle of a filename.
        Parameters:
        dataName - data name
        fileIndex - file index
        part - file part
        Returns:
        a String with the suffix of a file
      • fileSuffix

        public static String fileSuffix​(DataFormat format,
                                        fr.ens.biologie.genomique.kenetre.io.CompressionType compression)
        Create the suffix of a file.
        Parameters:
        format - format of the file
        compression - file compression
        Returns:
        a String with the suffix of a file
      • fileSuffix

        public static String fileSuffix​(String extension,
                                        String compression)
        Create the suffix of a file.
        Parameters:
        extension - file extension
        compression - file compression
        Returns:
        a String with the suffix of a file
      • filename

        public static String filename​(String stepId,
                                      String portName,
                                      DataFormat format,
                                      String dataName,
                                      int fileIndex,
                                      int part,
                                      fr.ens.biologie.genomique.kenetre.io.CompressionType compression)
        Create the filename from several parameters.
        Parameters:
        stepId - the step id
        portName - the port name
        format - the format
        dataName - the data name
        fileIndex - the file index
        part - the part
        compression - the compression type
        Returns:
        a string with the filename
      • parse

        public static FileNaming parse​(File file)
        Create a FileNaming object from a File object.
        Parameters:
        file - the file
        Returns:
        a new FileNaming object
      • parse

        public static FileNaming parse​(DataFile file)
        Create a FileNaming object from a DataFile object.
        Parameters:
        file - the file
        Returns:
        a new FileNaming object
      • parse

        public static FileNaming parse​(String filename)
        Create a FileNaming object from a filename.
        Parameters:
        filename - the filename
        Returns:
        a new FileNaming object
      • isStepIdValid

        public static boolean isStepIdValid​(String stepId)
        Test if a step id is valid.
        Parameters:
        stepId - the step id to check
        Returns:
        true if the step id is valid
      • isFormatPrefixValid

        public static boolean isFormatPrefixValid​(String formatPrefix)
        Test if a format prefix id is valid.
        Parameters:
        formatPrefix - the format prefix to check
        Returns:
        true if the format prefix is valid
      • isPortNameValid

        public static boolean isPortNameValid​(String portName)
        Test if a port name is valid.
        Parameters:
        portName - port name to check
        Returns:
        true if the port name is valid
      • isDataNameValid

        public static boolean isDataNameValid​(String dataName)
        Test if a data name is valid.
        Parameters:
        dataName - data name to check
        Returns:
        true if the data name is valid
      • isFilenameValid

        public static boolean isFilenameValid​(DataFile file)
        Test if a filename is valid.
        Parameters:
        file - the file to test.
        Returns:
        true if the filename is valid
      • isFilenameValid

        public static boolean isFilenameValid​(File file)
        Test if a filename is valid.
        Parameters:
        file - the file to test.
        Returns:
        true if the filename is valid
      • isFilenameValid

        public static boolean isFilenameValid​(String filename)
        Test if a filename is valid.
        Parameters:
        filename - the file to test.
        Returns:
        true if the filename is valid
      • dataEquals

        public static boolean dataEquals​(File file1,
                                         File file2)
        Test if two files are related to the same data.
        Parameters:
        file1 - the first file
        file2 - the second file
        Returns:
        true if the two files are related to the same data
      • dataEquals

        public static boolean dataEquals​(DataFile file1,
                                         DataFile file2)
        Test if two files are related to the same data.
        Parameters:
        file1 - the first file
        file2 - the second file
        Returns:
        true if the two files are related to the same data
      • dataEquals

        public static boolean dataEquals​(String filename1,
                                         String filename2)
        Test if two filenames are related to the same data.
        Parameters:
        filename1 - the first filename
        filename2 - the second filename
        Returns:
        true if the two files are related to the same data