Ejemplo n.º 1
0
        private TransformManyBlock <IEnumerable <ReadPair>, PairResult> GetPairClassifierBlock()
        {
            var readPair = new TransformManyBlock <IEnumerable <ReadPair>, PairResult>(
                (data) =>
            {
                var classifier = new ReadPairClassifierAndExtractor(_geminiOptions.TrustSoftclips,
                                                                    (int)_stitcherOptions.FilterMinMapQuality, skipStitch: _geminiOptions.SkipStitching, treatAbnormalOrientationAsImproper: _geminiOptions.TreatAbnormalOrientationAsImproper, messyMapq: _geminiOptions.MessyMapq, numSoftclipsToBeConsideredMessy: _geminiOptions.NumSoftclipsToBeConsideredMessy, numMismatchesToBeConsideredMessy: _geminiOptions.NumMismatchesToBeConsideredMessy, stringTagsToKeepFromR1: _stitcherOptions.StringTagsToKeepFromR1, checkMd: _geminiOptions.SilenceSuspiciousMdReads);
                var pairHandler = GetPairHandler(_refIdMapping);
                // Get batches from groups
                var batches = new List <PairResult>();
                foreach (var pair in data)
                {
                    var pairResult = classifier.GetBamAlignmentsAndClassification(pair, pairHandler);
                    if (pairResult.Classification != PairClassification.Unusable &&
                        pairResult.Classification != PairClassification.UnusableSplit &&
                        (!_geminiOptions.SkipAndRemoveDups || pairResult.Classification != PairClassification.Duplicate))
                    {
                        batches.Add(pairResult);
                    }
                }

                //pairHandler.Finish();
                return(batches);
            }, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = _maxDegreeOfParallelism,
                EnsureOrdered          = true
            }
                );

            return(readPair);
        }
        private void VerifyClassificationAndExtraction(ReadPair readpair, PairClassification expectedClassification,
                                                       int expectedNumReads, bool trustSoftclips, bool deferStitchIndelReads = true, bool shouldTryStitch = true, bool stageStitchSucceed = true, bool treatAbnormalOrientationAsImproper = false,
                                                       int messyMapq = 30, bool checkMd = false)
        {
            var pairHandler = new Mock <IReadPairHandler>();

            pairHandler.Setup(x => x.ExtractReads(It.IsAny <ReadPair>())).Returns(stageStitchSucceed
                ? new List <BamAlignment>()
            {
                readpair.Read1
            }
                : new List <BamAlignment>()
            {
                readpair.Read1, readpair.Read2
            });

            var extractor = new ReadPairClassifierAndExtractor(trustSoftclips,
                                                               messyMapq: messyMapq, treatAbnormalOrientationAsImproper: treatAbnormalOrientationAsImproper, checkMd: checkMd);

            var result = extractor.GetBamAlignmentsAndClassification(readpair, pairHandler.Object);

            var alignments = result.Alignments;

            Assert.Equal(expectedClassification, result.Classification);
            pairHandler.Verify(x => x.ExtractReads(It.IsAny <ReadPair>()), Times.Exactly(shouldTryStitch ? 1 : 0));

            Assert.Equal(expectedNumReads, alignments.ToList().Count);
        }