Esempio n. 1
0
 /// <summary>
 /// Parses a single biological sequence text from a file.
 /// </summary>
 /// <param name="filename">The name of a biological sequence file.</param>
 /// <param name="isReadOnly">
 /// Flag to indicate whether the resulting sequence should be in readonly mode or not.
 /// If this flag is set to true then the resulting sequence's isReadOnly property
 /// will be set to true, otherwise it will be set to false.
 /// </param>
 /// <returns>The parsed ISequence object.</returns>
 public ISequence ParseOne(string filename, bool isReadOnly)
 {
     using (MBFTextReader mbfReader = new MBFTextReader(filename))
     {
         return(ParseOne(mbfReader, isReadOnly));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Parses a list of biological sequence texts from a reader.
 /// </summary>
 /// <param name="reader">A reader for a biological sequence text.</param>
 /// <param name="isReadOnly">
 /// Flag to indicate whether the resulting sequences should be in readonly mode or not.
 /// If this flag is set to true then the resulting sequences's isReadOnly property
 /// will be set to true, otherwise it will be set to false.
 /// </param>
 /// <returns>The list of parsed ISequence objects.</returns>
 public IList <ISequence> Parse(TextReader reader, bool isReadOnly)
 {
     using (MBFTextReader mbfReader = new MBFTextReader(reader))
     {
         return(Parse(mbfReader, isReadOnly));
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Parses a list of biological sequence texts from a reader.
 /// </summary>
 /// <param name="reader">A reader for a biological sequence text.</param>
 /// <param name="isReadOnly">
 /// Flag to indicate whether the resulting sequences should be in readonly mode or not.
 /// If this flag is set to true then the resulting sequences's isReadOnly property
 /// will be set to true, otherwise it will be set to false.
 /// </param>
 /// <returns>The iterator of parsed ISequence objects.</returns>
 public IEnumerable <ISequence> ParseStream(TextReader reader, bool isReadOnly)
 {
     using (MBFTextReader mbfReader = new MBFTextReader(reader))
     {
         return(ParseStream(mbfReader, isReadOnly));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Parses a list of sequences using a MBFTextReader.
        /// </summary>
        /// <remarks>
        /// This method should be overridden by any parsers that need to process file-scope
        /// metadata that applies to all of the sequences in the file.
        /// </remarks>
        /// <param name="mbfReader">A reader for a biological sequence text.</param>
        /// <param name="isReadOnly">
        /// Flag to indicate whether the resulting sequences should be in readonly mode or not.
        /// If this flag is set to true then the resulting sequences's isReadOnly property
        /// will be set to true, otherwise it will be set to false.
        /// </param>
        /// <returns>The list of parsed ISequence objects.</returns>
        protected virtual IList <ISequence> Parse(MBFTextReader mbfReader, bool isReadOnly)
        {
            if (mbfReader == null)
            {
                throw new ArgumentNullException("mbfReader");
            }

            List <ISequence> sequences = new List <ISequence>();

            sequences.AddRange(ParseStream(mbfReader, isReadOnly));
            return(sequences);
        }
Esempio n. 5
0
        /// <summary>
        /// Parses a list of sequences using a MBFTextReader.
        /// </summary>
        /// <remarks>
        /// This method should be overridden by any parsers that need to process file-scope
        /// metadata that applies to all of the sequences in the file.
        /// </remarks>
        /// <param name="mbfReader">A reader for a biological sequence text.</param>
        /// <param name="isReadOnly">
        /// Flag to indicate whether the resulting sequences should be in readonly mode or not.
        /// If this flag is set to true then the resulting sequences's isReadOnly property
        /// will be set to true, otherwise it will be set to false.
        /// </param>
        /// <returns>The iterator of parsed ISequence objects.</returns>
        protected virtual IEnumerable <ISequence> ParseStream(MBFTextReader mbfReader, bool isReadOnly)
        {
            if (mbfReader == null)
            {
                throw new ArgumentNullException("mbfReader");
            }

            // no empty files allowed
            if (!mbfReader.HasLines)
            {
                Trace.Report(Properties.Resource.IONoTextToParse);
                throw new InvalidDataException(Properties.Resource.IONoTextToParse);
            }

            while (mbfReader.HasLines)
            {
                yield return(ParseOne(mbfReader, isReadOnly));
            }
        }
Esempio n. 6
0
        // Parses a single sequences using a MBFTextReader.
        private ISequence ParseOne(MBFTextReader mbfReader, bool isReadOnly)
        {
            if (mbfReader == null)
            {
                throw new ArgumentNullException("mbfReader");
            }

            // no empty files allowed
            if (!mbfReader.HasLines)
            {
                string message = Properties.Resource.IONoTextToParse;
                Trace.Report(message);
                throw new InvalidDataException(message);
            }

            _distinctSymbols = new List <char>();

            // do the actual parsing
            ISequence sequence = ParseOneWithSpecificFormat(mbfReader, isReadOnly);

            _distinctSymbols = null;

            return(sequence);
        }
Esempio n. 7
0
 /// <summary>
 /// Parses a single biological sequence text from a reader into a sequence.
 /// </summary>
 /// <param name="mbfReader">A reader for a biological sequence text.</param>
 /// <param name="isReadOnly">
 /// Flag to indicate whether the resulting sequence should be in readonly mode or not.
 /// If this flag is set to true then the resulting sequence's isReadOnly property
 /// will be set to true, otherwise it will be set to false.
 /// </param>
 /// <returns>Sequence instance.</returns>
 protected abstract ISequence ParseOneWithSpecificFormat(MBFTextReader mbfReader, bool isReadOnly);