# HG changeset patch # User pjbriggs # Date 1490196967 14400 # Node ID 00d73c8123993124b9b0201611a36b2c7d3d82a5 # Parent 02a01ea5472274f611397bd8c8845daf88fa68a8 Version 2.1.0-6: add sorting step in bigWig generation, and explicitly terminate tool on error from MACS2. diff -r 02a01ea54722 -r 00d73c812399 README.rst --- a/README.rst Tue Jul 26 10:34:49 2016 -0400 +++ b/README.rst Wed Mar 22 11:36:07 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 02a01ea54722 -r 00d73c812399 macs21_wrapper.py --- a/macs21_wrapper.py Tue Jul 26 10:34:49 2016 -0400 +++ b/macs21_wrapper.py Wed Mar 22 11:36:07 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 02a01ea54722 -r 00d73c812399 macs21_wrapper.xml --- a/macs21_wrapper.xml Tue Jul 26 10:34:49 2016 -0400 +++ b/macs21_wrapper.xml Wed Mar 22 11:36:07 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 02a01ea54722 -r 00d73c812399 tool_dependencies.xml --- a/tool_dependencies.xml Tue Jul 26 10:34:49 2016 -0400 +++ b/tool_dependencies.xml Wed Mar 22 11:36:07 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