Пример #1
0
        /// <summary>
        /// Create a sequence enumerator that filters the reads and adds them to the depth of coverage counter
        /// if necessary.
        /// </summary>
        /// <param name="fileName">Filename to load data from</param>
        /// <returns>Enumerable set of ISequence elements</returns>
        private IEnumerable <CompactSAMSequence> createSequenceProducer(string fileName, DepthOfCoverageGraphMaker coveragePlotter = null, bool alsoGetNuclearHits = false)
        {
            if (!Skip_DepthOfCoveragePlot && !Helper.IsBAM(fileName))
            {
                Skip_DepthOfCoveragePlot = true;
                Output.WriteLine(OutputLevel.Error, "Warning: No coverage plots can be made without an input BAM File");
            }
            IEnumerable <CompactSAMSequence> sequences;

            if (!alsoGetNuclearHits)
            {
                var parser = new BAMSequenceParser(Filename);
                if (ChromosomeName != string.Empty)
                {
                    parser.ChromosomeToGet = ChromosomeName;
                    sequences = parser.Parse();
                }
                else
                {
                    sequences = parser.Parse();
                }
            }
            else
            {
                sequences = BAMNuclearChromosomeReadGenerator.GetNuclearAndMitochondrialReads(fileName);
            }
            //Filter by quality
            return(ReadFilter.FilterReads(sequences, coveragePlotter));
        }
Пример #2
0
        /// <summary>
        /// Helper method to parse the given filename into a set
        /// of ISequence elements.
        /// </summary>
        /// <param name="fileName">Filename to load data from</param>
        /// <returns>Enumerable set of ISequence elements</returns>
        internal IEnumerable <ISequence> ParseFile(string fileName)
        {
            ISequenceParser parser = SequenceParsers.FindParserByFileName(fileName);

            if (parser == null)
            {
                parser = new FastAParser(fileName);
            }
            //else if (parser is Bio.IO.FastQ.FastQZippedParser)
            //{
            //    Console.WriteLine("Filtering FastQ File");
            //    var filter = new Bio.Filters.FastQZippedQualityTrimmedParser(fileName);
            //    return  ReadFilter.FilterReads(filter.Parse());
            //}
            if (parser is Bio.IO.BAM.BAMSequenceParser && ChromosomeName != string.Empty)
            {
                var b = parser as Bio.IO.BAM.BAMSequenceParser;
                b.ChromosomeToGet = ChromosomeName;
            }

            return(ReadFilter.FilterReads(parser.Parse()));
        }