Class MIFileAnalyzer


  • public class MIFileAnalyzer
    extends Object
    The file source analyzer will recognise what kind of molecular interaction source a given file is from.
    Since:
    01/03/13
    Version:
    $Id$
    Author:
    Marine Dumousseau (marine@ebi.ac.uk)
    • Field Detail

      • XML_EXTENSION

        public static String XML_EXTENSION
        Constant XML_EXTENSION=".xml"
      • TXT_EXTENSION

        public static String TXT_EXTENSION
        Constant TXT_EXTENSION=".txt"
      • CSV_EXTENSION

        public static String CSV_EXTENSION
        Constant CSV_EXTENSION=".csv"
      • TSV_EXTENSION

        public static String TSV_EXTENSION
        Constant TSV_EXTENSION=".tsv"
      • MITAB_25_TITLE

        public static final String MITAB_25_TITLE
        Constant MITAB_25_TITLE="#ID(s) interactor A\tID(s) interactor B"{trunked}
        See Also:
        Constant Field Values
    • Constructor Detail

      • MIFileAnalyzer

        public MIFileAnalyzer()
    • Method Detail

      • identifyMIFileTypeFor

        public MIFileType identifyMIFileTypeFor​(File file)
                                         throws IOException
        Recognize the MIFileDataSource from the file signature and first line. It will recognize psi25-xml and mitab files. If it is neither of them, it will return MIFileType.other
        Parameters:
        file - : the file to analyze
        Returns:
        the MIFileType that matches the file
        Throws:
        IOException - if any.
      • isFileSignature

        public boolean isFileSignature​(File file,
                                       String signature)

        isFileSignature.

        Parameters:
        file - a File object.
        signature - a String object.
        Returns:
        a boolean.
      • extractMIFileTypeFrom

        public OpenedInputStream extractMIFileTypeFrom​(InputStream stream)
                                                throws IOException
        Recognize the MIFileDataSource from the inputStream. Because it needs to open the inputStream to analyze its content, it will return an OpenedInputStream which contains the MIFileType and a PushbackReader which should be used instead of the given 'stream' which have been opened. As for a normal InputStream, it needs to be closed after being used. It will recognize psi25-xml and mitab files. If it is neither of them, it will return an OpenedInputStream MIFileType.other
        Parameters:
        stream - : the stream to recognize
        Returns:
        a OpenedInputStream object.
        Throws:
        IOException - if any.
      • extractMIFileTypeAndCopiedInputStream

        public OpenedInputStream extractMIFileTypeAndCopiedInputStream​(Reader reader)
                                                                throws IOException
        Recognize the MIFileDataSource from the reader. Because it needs to open the reader to analyze its content, it will return an OpenedInputStream which contains the MIFileType and a PushbackReader which should be used instead of the given 'stream' which have been opened.. As for a normal InputStream, it needs to be closed after being used. It will recognize psi25-xml and mitab files. If it is neither of them, it will return an OpenedInputStream MIFileType.other
        Parameters:
        reader - : the reader for the source to recognize
        Returns:
        a OpenedInputStream object.
        Throws:
        IOException - if any.
      • identifyMIFileTypeFor

        public MIFileType identifyMIFileTypeFor​(InputStream stream)
                                         throws IOException
        Recognize the MIFileDataSource from the inputStream. Because it needs to open the inputStream to analyze its content, it will consume the provided stream. It will recognize psi25-xml and mitab files. If it is neither of them, it will return a MIFileType.other
        Parameters:
        stream - : the stream to recognize
        Returns:
        a MIFileType object.
        Throws:
        IOException - if any.
      • identifyMIFileTypeFor

        public MIFileType identifyMIFileTypeFor​(Reader reader)
                                         throws IOException
        Recognize the MIFileDataSource from the reader. Because it needs to read the first line to analyze its content, it will consume the provided reader. It does not need a BufferedReader as it creates a new BufferedReader from this reader It will recognize psi25-xml and mitab files. If it is neither of them, it will return a MIFileType.other
        Parameters:
        reader - : the reader for the source to recognize
        Returns:
        a MIFileType object.
        Throws:
        IOException - if any.