private bool ReadIsDuplicate(BamAlignment alignment) { if (_dupIdentifier.IsDuplicate(alignment)) { _statusCounter.AddStatusCount("Duplicates"); return(_skipDuplicates); } return(false); }
public List <BamAlignment> ExtractReads(ReadPair pair) { const char Forward = 'F'; const char Reverse = 'R'; var reads = new List <BamAlignment>(); var chrom1 = _refIdMapping[pair.Read1.RefID]; var chrom2 = _refIdMapping[pair.Read2.RefID]; var alignmentSet = new AlignmentSet( new Read(chrom1, pair.Read1), new Read(chrom2, pair.Read2), false); var read1dir = pair.Read1.IsReverseStrand() ? Reverse : Forward; var read2dir = pair.Read2.IsReverseStrand() ? Reverse : Forward; if (pair.Read1.IsSecondMate()) { read1dir = pair.Read2.IsReverseStrand() ? Reverse : Forward; read2dir = pair.Read1.IsReverseStrand() ? Reverse : Forward; } bool stitched = false; if (_tryStitch) { stitched = _stitcher.TryStitch(alignmentSet); } if (stitched) { //_statusCounter.AddStatusCount("Stitched"); if (alignmentSet.ReadsForProcessing.Count > 1) { throw new InvalidDataException("AlignmentSets for stitched reads should only have one ReadsForProcessing."); } foreach (var read in alignmentSet.ReadsForProcessing) { var alignment = StitcherHelpers.StitchifyBamAlignment(pair, read, read1dir, read2dir); reads.Add(alignment); } } else { if (!_filterUnstitchablePairs) { //_statusCounter.AddStatusCount("Unstitchable Pairs Kept"); reads.Add(new BamAlignment(alignmentSet.PartnerRead1.BamAlignment)); reads.Add(new BamAlignment(alignmentSet.PartnerRead2.BamAlignment)); } else { _statusCounter.AddStatusCount("Unstitchable Pairs Filtered"); } } return(reads); }
private void AddStatus(string status) { _readStatuses.AddStatusCount(status); }
public void AddStatusCount(string status) { _statusCounter.AddStatusCount(status); }
public List <BamAlignment> ExtractReads(ReadPair pair) { var reads = new List <BamAlignment>(); var chrom1 = _refIdMapping[pair.Read1.RefID]; var chrom2 = _refIdMapping[pair.Read2.RefID]; var alignmentSet = new AlignmentSet( new Read(chrom1, pair.Read1), new Read(chrom2, pair.Read2), false); var stitched = _stitcher.TryStitch(alignmentSet); if (stitched) { if (alignmentSet.ReadsForProcessing.Count > 1) { throw new Exception("AlignmentSets for stitched reads should only have one ReadsForProcessing."); } foreach (var read in alignmentSet.ReadsForProcessing) { var alignment = new BamAlignment(read.BamAlignment); alignment.SetIsFirstMate(false); alignment.SetIsProperPair(false); var tagUtils = new TagUtils(); if (read.StitchedCigar != null) { alignment.CigarData = read.StitchedCigar; } if (read.CigarDirections != null) { tagUtils.AddStringTag("XD", read.CigarDirections.ToString()); } var tagData = tagUtils.ToBytes(); var existingTags = alignment.TagData; if (existingTags == null) { alignment.TagData = tagData; } else { alignment.AppendTagData(tagData); } reads.Add(alignment); } } else { if (!_filterUnstitchablePairs) { _statusCounter.AddStatusCount("Unstitchable Pairs Kept"); reads.Add(new BamAlignment(alignmentSet.PartnerRead1.BamAlignment)); reads.Add(new BamAlignment(alignmentSet.PartnerRead2.BamAlignment)); } else { _statusCounter.AddStatusCount("Unstitchable Pairs Filtered"); } } return(reads); }