diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java index fd2d53827..e20e96dee 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java @@ -51,8 +51,9 @@ public class PrintReadsWalker extends ReadWalker { @Argument(fullName = "readGroup", shortName = "readGroup", doc="Discard reads not belonging to the specified read group", required = false) String readGroup = null; @Argument(fullName = "platform", shortName = "platform", doc="Discard reads not generated by the specified platform", required = false) - String platform = null; - // E.g. ILLUMINA, 454 + String platform = null; // E.g. ILLUMINA, 454 + @Argument(fullName = "number", shortName = "n", doc="Outputs only the first n reads, discarding the rest", required = false) + int nReadsToPrint = -1; /** * The initialize function. @@ -87,6 +88,14 @@ public class PrintReadsWalker extends ReadWalker { return false; } + // check if we've reached the output limit + if ( nReadsToPrint == 0 ) { + return false; // n == 0 means we've printed all we needed. + } + else if (nReadsToPrint > 0) { + nReadsToPrint--; // n > 0 means there are still reads to be printed. + } + return true; }