Ejemplo n.º 1
0
        /// <summary>
        /// Returns parser which supports the specified file.
        /// </summary>
        /// <param name="fileName">File name for which the parser is required.</param>
        /// <param name="parserName">Name of the parser to use.</param>
        /// <returns>If found returns the open parser as ISequenceParser else returns null.</returns>
        public static ISequenceParser FindParserByName(string fileName, string parserName)
        {
            ISequenceParser parser = null;

            if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(parserName))
            {
                if (parserName == Properties.Resource.FastAName)
                {
                    parser = fasta;
                }
                else if (parserName == Properties.Resource.FastQName)
                {
                    parser = new SequenceParserDecorator <FastQParser, IQualitativeSequence>(fastq);
                }
                else if (parserName == Properties.Resource.GENBANK_NAME)
                {
                    parser = genBank;
                }
                else if (parserName == Properties.Resource.GFF_NAME)
                {
                    parser = gff;
                }
                else
                {
                    // Do a search through the known parsers to pick up custom parsers added through add-in.
                    parser = All.FirstOrDefault(p => p.Name == parserName);
                }
            }

            return(parser);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds a suitable parser that supports the specified file, opens the file and returns the parser.
        /// </summary>
        /// <param name="fileName">File name for which the parser is required.</param>
        /// <returns>If found returns the open parser as ISequenceParser else returns null.</returns>
        public static ISequenceParser FindParserByFileName(string fileName)
        {
            ISequenceParser parser = null;

            if (!string.IsNullOrEmpty(fileName))
            {
                if (IsFasta(fileName))
                {
                    parser = fasta;
                }
                else if (IsFastQ(fileName))
                {
                    parser = new SequenceParserDecorator <FastQParser, IQualitativeSequence>(fastq);
                }
                else if (IsGenBank(fileName))
                {
                    parser = genBank;
                }
                else if (fileName.EndsWith(Properties.Resource.GFF_FILEEXTENSION, StringComparison.OrdinalIgnoreCase))
                {
                    parser = gff;
                }
                else
                {
                    // Do a search through the known parsers to pick up custom parsers added through add-in.
                    string fileExtension = Path.GetExtension(fileName);
                    if (!string.IsNullOrEmpty(fileExtension))
                    {
                        parser = All.FirstOrDefault(p => p.SupportedFileTypes.Contains(fileExtension));
                    }
                }
            }

            return(parser);
        }