From 18b0114e25eb30399403eb6d5eaea4cb1ea8b15f Mon Sep 17 00:00:00 2001 From: aaron Date: Mon, 19 Jul 2010 17:27:23 +0000 Subject: [PATCH] remove FixBAMSortOrder walker. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3830 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/walkers/FixBAMSortOrderTag.java | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100644 java/src/org/broadinstitute/sting/gatk/walkers/FixBAMSortOrderTag.java diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/FixBAMSortOrderTag.java b/java/src/org/broadinstitute/sting/gatk/walkers/FixBAMSortOrderTag.java deleted file mode 100644 index bdcf20dd0..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/FixBAMSortOrderTag.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2010 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -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.GenomeAnalysisEngine; -import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; -import org.broadinstitute.sting.commandline.Argument; -import net.sf.samtools.SAMFileWriter; -import net.sf.samtools.SAMRecord; -import net.sf.samtools.SAMFileHeader; -import net.sf.samtools.SAMFileWriterFactory; - -import java.io.File; - -/** - * Fixes slightly corrupted BAM files by rewriting the input BAM file, altering - * the header by changing the sort order tag (SO) to coordinate sort order. Will NOT - * verify the contents of the file to ensure that the data is actually in coordinate sorted - * order. - */ -public class FixBAMSortOrderTag extends ReadWalker { - - @Argument(required=true, shortName="out_bam", doc="The samfile to output to") - public File SAM_FILE_OUTPUT_LOCATION; - - @Argument(required=false, shortName="sortorder", doc="the sort order to emit in") - public SAMFileHeader.SortOrder SORT_ORDER=SAMFileHeader.SortOrder.coordinate; - - @Override - public SAMRecord map(ReferenceContext ref, SAMRecord read, ReadMetaDataTracker metaDataTracker) { - return read; - } - - @Override - public SAMFileWriter reduceInit() { - SAMFileHeader header = GenomeAnalysisEngine.instance.getSAMFileHeader(); - header.setSortOrder(SORT_ORDER); - SAMFileWriterFactory factory = new SAMFileWriterFactory(); - return factory.makeBAMWriter(header,false,SAM_FILE_OUTPUT_LOCATION); - } - - @Override - public SAMFileWriter reduce(SAMRecord value, SAMFileWriter sum) { - sum.addAlignment(value); - return sum; - } - - public void onTraversalDone(SAMFileWriter result) { - result.close(); - } -}