Moving some useful and stable walkers to core:

- ClipReads
- PrintRODs (generalized to print all RODs that are Variations)
- FixBAMSortOrderTag (added documentation to walker so that people know what it does and why)



git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2238 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-12-03 03:00:45 +00:00
parent 2460f2a789
commit d7e4cd4c82
3 changed files with 29 additions and 16 deletions

View File

@ -1,4 +1,4 @@
package org.broadinstitute.sting.playground.gatk.walkers;
package org.broadinstitute.sting.gatk.walkers;
import net.sf.samtools.*;
import net.sf.picard.reference.ReferenceSequenceFileFactory;
@ -8,9 +8,6 @@ import org.broadinstitute.sting.utils.cmdLine.Argument;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.Pair;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import java.util.*;
import java.util.regex.Pattern;

View File

@ -1,6 +1,17 @@
package org.broadinstitute.sting.playground.gatk.walkers;
package org.broadinstitute.sting.gatk.walkers;
/* Motivation: BAM files created by samtools which are sorted often don't
* have the sort order set to 'coordinate' in the BAM header (instead it's
* marked as 'unsorted'. Because BAMs are binary files, there's no way to
* easily change the tag.
*
* This walker rewrites a BAM file so that the output is identical to the input
* except that the sort order tag is set to 'coordinate'.
*
* Important note: to run properly in the GATK, the '-U' flag must be used so that
* the input BAM file not be rejected by the system.
*/
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.cmdLine.Argument;
import net.sf.samtools.SAMFileWriter;
@ -16,7 +27,7 @@ import java.io.File;
* Date: Oct 9, 2009
* Time: 2:21:08 PM
*/
public class UpdateSAMSortOrderWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
public class FixBAMSortOrderTag extends ReadWalker<SAMRecord, SAMFileWriter> {
@Argument(required=true, shortName="out_bam", doc="The samfile to output to")
public File SAM_FILE_OUTPUT_LOCATION;

View File

@ -23,18 +23,18 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.playground.gatk.walkers;
package org.broadinstitute.sting.gatk.walkers;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.*;
import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.genotype.Variation;
import java.util.Iterator;
/**
* PrintRODsWalker prints out all of the RODs that it sees (using the ROD's toString method)
*/
@Requires(value={DataSource.REFERENCE},referenceMetaData=@RMD(name="variant",type=ReferenceOrderedDatum.class))
public class PrintRODsWalker extends RefWalker<Integer, Integer> {
public class PrintRODsWalker extends RodWalker<Integer, Integer> {
/**
* Initialize the number of loci processed to zero.
@ -52,10 +52,15 @@ public class PrintRODsWalker extends RefWalker<Integer, Integer> {
* @return 1 if the locus was successfully processed, 0 if otherwise
*/
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
ReferenceOrderedDatum variant = tracker.lookup("variant", null);
if ( tracker == null )
return 0;
if (variant != null )
out.println(variant);
Iterator<ReferenceOrderedDatum> rods = tracker.getAllRods().iterator();
while ( rods.hasNext() ) {
ReferenceOrderedDatum rod = rods.next();
if ( rod instanceof Variation )
out.println(rod.toString());
}
return 1;
}