# HG changeset patch # User pjbriggs # Date 1490196292 14400 # Node ID 4e85d68a2347b660dad20a4eb077d2e715e4e221 # Parent f346287fe52c28e083a924b7fe4492f812d8c34f Version 2.1.0-6: add sorting step in bigWig generation, and explicitly terminate tool on error from MACS2. diff -r f346287fe52c -r 4e85d68a2347 README.rst --- a/README.rst Tue Jul 26 09:54:21 2016 -0400 +++ b/README.rst Wed Mar 22 11:24:52 2017 -0400 @@ -59,6 +59,8 @@ ========== ====================================================================== Version Changes ---------- ---------------------------------------------------------------------- +2.1.0-6 - Add bedSort step into bigWig file generation; terminate with error + when MACS finishes with non-zero exit code. 2.1.0-5 - User must explicitly specify the format for the inputs (to allow for paired-end data) 2.1.0-4 - Remove 'bdgcmp' functionality. diff -r f346287fe52c -r 4e85d68a2347 macs21_wrapper.py --- a/macs21_wrapper.py Tue Jul 26 09:54:21 2016 -0400 +++ b/macs21_wrapper.py Wed Mar 22 11:24:52 2017 -0400 @@ -61,7 +61,8 @@ $ fetchChromSizes.sh mm9 > mm9.chrom.sizes $ bedClip treat.bedgraph mm9.chrom.sizes treat.clipped - $ bedGraphToBigWig treat.clipped mm9.chrom.sizes treat.bw + $ bedSort treat.clipped treat.clipped.sorted + $ bedGraphToBigWig treat.clipped.sorted mm9.chrom.sizes treat.bw Get the binaries from http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/ @@ -111,8 +112,20 @@ if not os.path.exists(treat_clipped): sys.stderr.write("Failed to create clipped bed file\n") sys.exit(1) + # Run bedSort + treat_clipped_sorted = "%s.sorted" % os.path.basename(treat_clipped) + cmd = "bedSort %s %s" % (treat_clipped,treat_clipped_sorted) + print "Running %s" % cmd + proc = subprocess.Popen(args=cmd,shell=True,cwd=working_dir) + proc.wait() + # Check that sorted file exists + treat_clipped_sorted = os.path.join(working_dir,treat_clipped_sorted) + if not os.path.exists(treat_clipped_sorted): + sys.stderr.write("Failed to create sorted clipped bed file\n") + sys.exit(1) # Run bedGraphToBigWig - cmd = "bedGraphToBigWig %s %s %s" % (treat_clipped,chrom_sizes, + cmd = "bedGraphToBigWig %s %s %s" % (treat_clipped_sorted, + chrom_sizes, bigwig_file) print "Running %s" % cmd proc = subprocess.Popen(args=cmd,shell=True,cwd=working_dir) @@ -206,6 +219,10 @@ proc = subprocess.Popen(args=cmdline,shell=True,cwd=working_dir, stderr=open(stderr_filen,'wb')) proc.wait() + exit_code = proc.returncode + if exit_code != 0: + sys.stderr.write(open(stderr_filen,'rb').read()) + sys.exit(exit_code) # Run R script to create PDF from model script if os.path.exists(os.path.join(working_dir,"%s_model.r" % experiment_name)): diff -r f346287fe52c -r 4e85d68a2347 macs21_wrapper.xml --- a/macs21_wrapper.xml Tue Jul 26 09:54:21 2016 -0400 +++ b/macs21_wrapper.xml Wed Mar 22 11:24:52 2017 -0400 @@ -1,11 +1,11 @@ - + Model-based Analysis of ChIP-Seq: peak calling python numpy macs2 R - ucsc_tools_for_macs21 + ucsc_tools_for_macs21 macs2 --version diff -r f346287fe52c -r 4e85d68a2347 tool_dependencies.xml --- a/tool_dependencies.xml Tue Jul 26 09:54:21 2016 -0400 +++ b/tool_dependencies.xml Wed Mar 22 11:24:52 2017 -0400 @@ -8,7 +8,7 @@ - + @@ -25,6 +25,13 @@ $INSTALL_DIR/bedClip + + + http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bedSort + + + $INSTALL_DIR/bedSort + http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bedGraphToBigWig