Parallel FlagStat
This commit is contained in:
parent
af540888f1
commit
5066b14335
|
|
@ -45,12 +45,12 @@ import java.text.NumberFormat;
|
||||||
*/
|
*/
|
||||||
@DocumentedGATKFeature( groupName = "Quality Control and Simple Analysis Tools", extraDocs = {CommandLineGATK.class} )
|
@DocumentedGATKFeature( groupName = "Quality Control and Simple Analysis Tools", extraDocs = {CommandLineGATK.class} )
|
||||||
@Requires({DataSource.READS})
|
@Requires({DataSource.READS})
|
||||||
public class FlagStat extends ReadWalker<Integer, Integer> {
|
public class FlagStat extends ReadWalker<FlagStat.FlagStatus, FlagStat.FlagStatus> implements TreeReducible<FlagStat.FlagStatus> {
|
||||||
@Output
|
@Output
|
||||||
PrintStream out;
|
PrintStream out;
|
||||||
|
|
||||||
// what comes out of the flagstat
|
// what comes out of the flagstat
|
||||||
static class FlagStatus {
|
public final static class FlagStatus {
|
||||||
long readCount = 0L;
|
long readCount = 0L;
|
||||||
long QC_failure = 0L;
|
long QC_failure = 0L;
|
||||||
long duplicates = 0L;
|
long duplicates = 0L;
|
||||||
|
|
@ -117,62 +117,89 @@ public class FlagStat extends ReadWalker<Integer, Integer> {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public FlagStatus add(final FlagStatus other) {
|
||||||
|
readCount += other.readCount;
|
||||||
|
QC_failure += other.QC_failure;
|
||||||
|
duplicates += other.duplicates;
|
||||||
|
mapped += other.mapped;
|
||||||
|
paired_in_sequencing += other.paired_in_sequencing;
|
||||||
|
read1 += other.read1;
|
||||||
|
read2 += other.read2;
|
||||||
|
properly_paired += other.properly_paired;
|
||||||
|
with_itself_and_mate_mapped += other.with_itself_and_mate_mapped;
|
||||||
|
singletons += other.singletons;
|
||||||
|
with_mate_mapped_to_a_different_chr += other.with_mate_mapped_to_a_different_chr;
|
||||||
|
with_mate_mapped_to_a_different_chr_maq_greaterequal_than_5 += other.with_mate_mapped_to_a_different_chr_maq_greaterequal_than_5;
|
||||||
|
|
||||||
|
return this;
|
||||||
private FlagStatus myStat = new FlagStatus();
|
|
||||||
|
|
||||||
public Integer map( ReferenceContext ref, GATKSAMRecord read, ReadMetaDataTracker metaDataTracker ) {
|
|
||||||
myStat.readCount++;
|
|
||||||
if (read.getReadFailsVendorQualityCheckFlag()) {
|
|
||||||
myStat.QC_failure++;
|
|
||||||
}
|
}
|
||||||
if (read.getDuplicateReadFlag()) {
|
|
||||||
myStat.duplicates++;
|
|
||||||
}
|
|
||||||
if (!read.getReadUnmappedFlag()) {
|
|
||||||
myStat.mapped++;
|
|
||||||
}
|
|
||||||
if (read.getReadPairedFlag()) {
|
|
||||||
myStat.paired_in_sequencing++;
|
|
||||||
|
|
||||||
if (read.getSecondOfPairFlag()) {
|
public FlagStatus add(final GATKSAMRecord read) {
|
||||||
myStat.read2++;
|
this.readCount++;
|
||||||
} else if (read.getReadPairedFlag()) {
|
|
||||||
myStat.read1++;
|
if (read.getReadFailsVendorQualityCheckFlag()) {
|
||||||
|
this.QC_failure++;
|
||||||
}
|
}
|
||||||
if (read.getProperPairFlag()) {
|
if (read.getDuplicateReadFlag()) {
|
||||||
myStat.properly_paired++;
|
this.duplicates++;
|
||||||
}
|
}
|
||||||
if (!read.getReadUnmappedFlag() && !read.getMateUnmappedFlag()) {
|
if (!read.getReadUnmappedFlag()) {
|
||||||
myStat.with_itself_and_mate_mapped++;
|
this.mapped++;
|
||||||
|
}
|
||||||
|
if (read.getReadPairedFlag()) {
|
||||||
|
this.paired_in_sequencing++;
|
||||||
|
|
||||||
if (!read.getReferenceIndex().equals(read.getMateReferenceIndex())) {
|
if (read.getSecondOfPairFlag()) {
|
||||||
myStat.with_mate_mapped_to_a_different_chr++;
|
this.read2++;
|
||||||
|
} else if (read.getReadPairedFlag()) {
|
||||||
|
this.read1++;
|
||||||
|
}
|
||||||
|
if (read.getProperPairFlag()) {
|
||||||
|
this.properly_paired++;
|
||||||
|
}
|
||||||
|
if (!read.getReadUnmappedFlag() && !read.getMateUnmappedFlag()) {
|
||||||
|
this.with_itself_and_mate_mapped++;
|
||||||
|
|
||||||
if (read.getMappingQuality() >= 5) {
|
if (!read.getReferenceIndex().equals(read.getMateReferenceIndex())) {
|
||||||
myStat.with_mate_mapped_to_a_different_chr_maq_greaterequal_than_5++;
|
this.with_mate_mapped_to_a_different_chr++;
|
||||||
|
|
||||||
|
if (read.getMappingQuality() >= 5) {
|
||||||
|
this.with_mate_mapped_to_a_different_chr_maq_greaterequal_than_5++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!read.getReadUnmappedFlag() && read.getMateUnmappedFlag()) {
|
||||||
|
this.singletons++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!read.getReadUnmappedFlag() && read.getMateUnmappedFlag()) {
|
|
||||||
myStat.singletons++;
|
return this;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer reduceInit() {
|
|
||||||
return 0;
|
@Override
|
||||||
|
public FlagStatus map( final ReferenceContext ref, final GATKSAMRecord read, final ReadMetaDataTracker metaDataTracker ) {
|
||||||
|
return new FlagStatus().add(read);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagStatus reduceInit() {
|
||||||
|
return new FlagStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer reduce(Integer value, Integer sum) {
|
@Override
|
||||||
return value + sum;
|
public FlagStatus reduce(final FlagStatus value, final FlagStatus sum) {
|
||||||
|
return sum.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTraversalDone(Integer result) {
|
@Override
|
||||||
//out.println("[REDUCE RESULT] Traversal result is: " + result);
|
public FlagStatus treeReduce(final FlagStatus value, final FlagStatus sum) {
|
||||||
out.println(myStat.toString());
|
return sum.add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTraversalDone(final FlagStatus result) {
|
||||||
|
out.println(result.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue