Skip to content

Instantly share code, notes, and snippets.

@lindenb
Created July 18, 2016 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lindenb/580c675e52d47fc043fb4c265337701d to your computer and use it in GitHub Desktop.
Save lindenb/580c675e52d47fc043fb4c265337701d to your computer and use it in GitHub Desktop.
patch for gatk genstrip and BAM files missing a LB library in the SAM Header. htsjdk is hacked to use the Sample name instead of the Library
diff --git a/src/java/htsjdk/samtools/SAMReadGroupRecord.java b/src/java/htsjdk/samtools/SAMReadGroupRecord.java
index fd81852..ed92ac4 100644
--- a/src/java/htsjdk/samtools/SAMReadGroupRecord.java
+++ b/src/java/htsjdk/samtools/SAMReadGroupRecord.java
@@ -80,7 +80,7 @@ public class SAMReadGroupRecord extends AbstractSAMHeaderRecord
public String getSample() { return getAttribute(READ_GROUP_SAMPLE_TAG); }
public void setSample(final String value) { setAttribute(READ_GROUP_SAMPLE_TAG, value); }
- public String getLibrary() { return getAttribute(LIBRARY_TAG); }
+ public String getLibrary() { final String s= getAttribute(LIBRARY_TAG); return s==null?getSample():s; }
public void setLibrary(final String value) { setAttribute(LIBRARY_TAG, value); }
public String getPlatformUnit() { return getAttribute(PLATFORM_UNIT_TAG); }

patch for gatk genstrip and BAM files missing a LB library in the SAM Header. htsjdk is hacked to use the Sample name instead of the Library This should fix the following issue: http://gatkforums.broadinstitute.org/wdl/discussion/6339/

SVPreprocess.qError: Cannot determine library identifier for read xxxx

clone and checkout the current tag for svtoolkit (currently 2.1.0)

$ git clone "https://github.com/samtools/htsjdk"
$ git checkout tags/2.1.0
$ cd htsjdk

apply the patch

$ patch -p1 < lb.patch        
patching file src/java/htsjdk/samtools/SAMReadGroupRecord.java

compile

ant

replace the old library with the new one:

Q: The old library was named htsjdk-2.1.0.gs. What is that "gs" ? is there any difference with the official htsjdk 2.1.0 release ?

mv dist/htsjdk-2.1.0.jar /svtoolkit/lib/gatk/htsjdk-2.1.0.gs.jar

It seems to work so far, but it seems very slow ?...

INFO 22:10:59,230 18-Jul-2016 ProgressMeter - Starting 0.0 20.0 m 1984.4 w 100.0% 20.0 m 0.0 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment