예제 #1
0
        /// <summary>
        /// Parses a list of sequences using a BioTextReader.
        /// </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="bioReader">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(BioTextReader bioReader, bool isReadOnly)
        {
            if (bioReader == null)
            {
                throw new ArgumentNullException("bioReader");
            }

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

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

            while (bioReader.HasLines)
            {
                sequences.Add(ParseOne(bioReader, isReadOnly));
            }

            return(sequences);
        }
예제 #2
0
        // Parses a single sequences using a BioTextReader.
        private ISequence ParseOne(BioTextReader bioReader, bool isReadOnly)
        {
            if (bioReader == null)
            {
                throw new ArgumentNullException("bioReader");
            }

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

            _distinctSymbols = new List <char>();

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

            _distinctSymbols = null;

            return(sequence);
        }
예제 #3
0
 /// <summary>
 /// Parses a single biological sequence text from a reader into a sequence.
 /// </summary>
 /// <param name="bioReader">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(BioTextReader bioReader, bool isReadOnly);