From 2db6225c5364b7d4b81fbcd278c9e4ffa228c1c0 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Tue, 9 Aug 2011 00:04:42 -0400 Subject: [PATCH] A read filter that sets all mapping qualities to a given value Pacbio has decided to assign 255 to the MQ of all their reads since they claim their aligner does not produce a number equivalent to a mapping quality. Despite much back and forth, they are dead set on not using this field, so if we want to use their bams, we will need to override that. This filter does just that. Replacing all values with a given one. Default is 60. --- .../filters/ReassignMappingQualityFilter.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 public/java/src/org/broadinstitute/sting/gatk/filters/ReassignMappingQualityFilter.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/filters/ReassignMappingQualityFilter.java b/public/java/src/org/broadinstitute/sting/gatk/filters/ReassignMappingQualityFilter.java new file mode 100644 index 000000000..50a1384fa --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/gatk/filters/ReassignMappingQualityFilter.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009 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.filters; + +import net.sf.samtools.SAMRecord; +import org.broadinstitute.sting.commandline.Argument; + +/** + * A read filter (transformer) that sets all reads mapping quality to a given value. + * + *

+ * If a BAM file contains erroneous or missing mapping qualities, this 'filter' will set + * all your mapping qualities to a given value. Default being 60. + *

+ * + * + *

Input

+ *

+ * BAM file(s) + *

+ * + * + *

Output

+ *

+ * BAM file(s) with all reads mapping qualities reassigned + *

+ * + *

Examples

+ *
+ *    java
+ *      -jar GenomeAnalysisTK.jar
+ *      -rf ReassignMappingQuality
+ *      -DMQ 35
+ *  
+ * + * @author carneiro + * @since 8/8/11 + */ + +public class ReassignMappingQualityFilter extends ReadFilter { + + @Argument(fullName = "default_mapping_quality", shortName = "DMQ", doc = "Default read mapping quality to assign to all reads", required = false) + public int defaultMappingQuality = 60; + + public boolean filterOut(SAMRecord rec) { + rec.setMappingQuality(defaultMappingQuality); + return false; + } +} +