This commit is for Kiran
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2898 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
87f8fb7282
commit
cfff486338
|
|
@ -39,6 +39,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Useful class for storing different AlignmentContexts
|
* Useful class for storing different AlignmentContexts
|
||||||
* User: ebanks
|
* User: ebanks
|
||||||
|
* Modified: chartl (split by read group)
|
||||||
*/
|
*/
|
||||||
public class StratifiedAlignmentContext {
|
public class StratifiedAlignmentContext {
|
||||||
|
|
||||||
|
|
@ -140,6 +141,40 @@ public class StratifiedAlignmentContext {
|
||||||
myContext.add(read, p.getOffset());
|
myContext.add(read, p.getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits the given AlignmentContext into a StratifiedAlignmentContext per read group.
|
||||||
|
*
|
||||||
|
* @param pileup the original pileup
|
||||||
|
* @return a Map of sample name to StratifiedAlignmentContext
|
||||||
|
* @todo - support for collapsing or assuming read groups if they are missing
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public static Map<String,StratifiedAlignmentContext> splitContextByReadGroup(ReadBackedPileup pileup) {
|
||||||
|
HashMap<String,StratifiedAlignmentContext> contexts = new HashMap<String,StratifiedAlignmentContext>();
|
||||||
|
|
||||||
|
for ( PileupElement p : pileup ) {
|
||||||
|
SAMRecord read = p.getRead();
|
||||||
|
|
||||||
|
SAMReadGroupRecord readGroup = read.getReadGroup();
|
||||||
|
if ( readGroup == null ) {
|
||||||
|
throw new StingException("Missing read group for read " + read.getReadName());
|
||||||
|
}
|
||||||
|
|
||||||
|
String group = readGroup.getReadGroupId();
|
||||||
|
|
||||||
|
StratifiedAlignmentContext myContext = contexts.get(group);
|
||||||
|
|
||||||
|
if ( myContext == null ) {
|
||||||
|
myContext = new StratifiedAlignmentContext(pileup.getLocation());
|
||||||
|
contexts.put(group,myContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
myContext.add(read,p.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,12 +141,17 @@ public class CoverageStatistics extends LocusWalker<Map<String,Integer>, DepthOf
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Integer> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public Map<String,Integer> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
Map<String, StratifiedAlignmentContext> contextsBySample =
|
Map<String,StratifiedAlignmentContext> contexts;
|
||||||
StratifiedAlignmentContext.splitContextBySample(context.getBasePileup());
|
if ( useReadGroup ) {
|
||||||
|
contexts = StratifiedAlignmentContext.splitContextByReadGroup(context.getBasePileup());
|
||||||
|
} else {
|
||||||
|
contexts = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup());
|
||||||
|
}
|
||||||
|
|
||||||
HashMap<String,Integer> depthBySample = new HashMap<String,Integer>();
|
HashMap<String,Integer> depthBySample = new HashMap<String,Integer>();
|
||||||
|
|
||||||
for ( String sample : contextsBySample.keySet() ) {
|
for ( String sample : contexts.keySet() ) {
|
||||||
AlignmentContext sampleContext = contextsBySample.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE);
|
AlignmentContext sampleContext = contexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE);
|
||||||
int properDepth = 0;
|
int properDepth = 0;
|
||||||
for ( PileupElement e : sampleContext.getBasePileup() ) {
|
for ( PileupElement e : sampleContext.getBasePileup() ) {
|
||||||
if ( e.getQual() >= minBaseQuality && e.getMappingQual() >= minMappingQuality ) {
|
if ( e.getQual() >= minBaseQuality && e.getMappingQual() >= minMappingQuality ) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue