public virtual void MapReadToFeature(List <FeatureLocation> features, Dictionary <string, Dictionary <char, List <SAMAlignedLocation> > > chrStrandReadMap) { if (chrStrandReadMap.Count == 0 || features.Count == 0) { return; } //mapping to genome, considering offset limitation //Progress.SetRange(0, smallRNAs.Count); foreach (var smallRNA in features) { //Progress.Increment(1); Dictionary <char, List <SAMAlignedLocation> > curMatchedMap; if (!chrStrandReadMap.TryGetValue(smallRNA.Seqname, out curMatchedMap)) { continue; } //mapped query must have same oritation with miRNA defined at gff or bed file. var matches = curMatchedMap[smallRNA.Strand]; foreach (var m in matches) { var r = AcceptLocationPair(smallRNA, m); if (r.Accepted) { var fsl = new FeatureSamLocation(smallRNA); fsl.SamLocation = m; fsl.NumberOfMismatch = r.NumberOfMismatch; fsl.NumberOfNoPenaltyMutation = r.NumberOfNoPenaltyMutation; fsl.OverlapPercentage = r.OverlapPercentage; } } } }
private void DoMapReadToSequenceRegionWithOrientation(List <FeatureLocation> mapped, List <SAMAlignedItem> reads) { //build chr/strand/samlist map Progress.SetMessage("building chr/strand/samlist map ..."); var chrStrandMatchedMap = new Dictionary <string, Dictionary <char, List <SAMAlignedLocation> > >(); foreach (var read in reads) { foreach (var loc in read.Locations) { Dictionary <char, List <SAMAlignedLocation> > map; if (!chrStrandMatchedMap.TryGetValue(loc.Seqname, out map)) { map = new Dictionary <char, List <SAMAlignedLocation> >(); map['+'] = new List <SAMAlignedLocation>(); map['-'] = new List <SAMAlignedLocation>(); chrStrandMatchedMap[loc.Seqname] = map; } map[loc.Strand].Add(loc); } } Progress.SetRange(0, mapped.Count); var gmapped = new Dictionary <string, SAMAlignedItem>(); foreach (var curmapped in mapped) { Progress.Increment(1); Dictionary <char, List <SAMAlignedLocation> > curMatchedMap; if (!chrStrandMatchedMap.TryGetValue(curmapped.Seqname, out curMatchedMap)) { continue; } //mapped query must have same oritation with miRNA defined at gff or bed file. var matches = curMatchedMap[curmapped.Strand]; foreach (var m in matches) { if (!curmapped.Overlap(m, 0)) { continue; } var fsl = new FeatureSamLocation(curmapped); fsl.SamLocation = m; } } }
private void DoMapReadToSequenceRegionOrientationFree(List <FeatureLocation> mapped, List <SAMAlignedItem> reads) { //build chr/samlist map Progress.SetMessage("building chr/samlist map ..."); var chrStrandMatchedMap = new Dictionary <string, List <SAMAlignedLocation> >(); foreach (var read in reads) { foreach (var loc in read.Locations) { List <SAMAlignedLocation> map; if (!chrStrandMatchedMap.TryGetValue(loc.Seqname, out map)) { map = new List <SAMAlignedLocation>(); chrStrandMatchedMap[loc.Seqname] = map; } map.Add(loc); } } Progress.SetRange(0, mapped.Count); var gmapped = new Dictionary <string, SAMAlignedItem>(); foreach (var curmapped in mapped) { Progress.Increment(1); List <SAMAlignedLocation> matches; if (!chrStrandMatchedMap.TryGetValue(curmapped.Seqname, out matches)) { continue; } foreach (var m in matches) { var op = curmapped.OverlapPercentage(m); if (op < options.MinimumOverlapPercentage) { continue; } var fsl = new FeatureSamLocation(curmapped); fsl.SamLocation = m; } } }
public override bool AcceptLocus(SAMAlignedLocation loc) { var result = false; if (!loc.Seqname.Equals(lastSeqname)) { if (!featureMap.TryGetValue(loc.Seqname, out lastFeatures)) { return(false); } lastSeqname = loc.Seqname; } foreach (var feature in lastFeatures) { if (feature.End < loc.Start) { continue; } if (feature.Start > loc.End) { break; } if (feature.Overlap(loc, this.minOverlapPercentage)) { result = true; var samloc = new FeatureSamLocation(feature); samloc.SamLocation = loc; feature.SamLocations.Add(samloc); } } return(result); }