From d7f3102c3f31a2550b5a74a18a902af158c7fec2 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 16 Jun 2010 19:14:37 +0000 Subject: [PATCH] Fixed read group blacklist filter to look only at readgroups (and not the read's themselves). Otherwise, it fails when attribute tags with different meanings show up in both places (e.g. SM). Added performance improvement. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3567 348d0f76-0448-11de-a6fe-93d51630548a --- .../filters/ReadGroupBlackListFilter.java | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilter.java b/java/src/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilter.java index 59e6147a6..70b8ed687 100644 --- a/java/src/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilter.java +++ b/java/src/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilter.java @@ -37,13 +37,9 @@ import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.text.XReadLines; /** - * Removes records matching the read group tag and match string. - * For example each of the filter values: + * Removes records matching the read group tag and exact match string. + * For example, this filter value: * PU:1000G-mpimg-080821-1_1 - * PU:1000G-mpimg-080821 - * PU:mpimg-080821-1_1 - * PU:mpimg-080821 - * * would filter out a read with the read group PU:1000G-mpimg-080821-1_1 */ public class ReadGroupBlackListFilter implements SamRecordFilter { @@ -60,18 +56,12 @@ public class ReadGroupBlackListFilter implements SamRecordFilter { for (Entry> filterEntry : filterEntries) { String attributeType = filterEntry.getKey(); - Object attribute = samRecord.getAttribute(attributeType); - if (attribute == null) { - SAMReadGroupRecord samReadGroupRecord = samRecord.getReadGroup(); - if (samReadGroupRecord != null) { - attribute = samReadGroupRecord.getAttribute(attributeType); - } + SAMReadGroupRecord samReadGroupRecord = samRecord.getReadGroup(); + if (samReadGroupRecord != null) { + Object attribute = samReadGroupRecord.getAttribute(attributeType); + if (attribute != null && filterEntry.getValue().contains(attribute)) + return true; } - - if (attribute != null) - for (String filterValue : filterEntry.getValue()) - if (attribute.toString().contains(filterValue)) - return true; } return false;