# HG changeset patch # User bgruening # Date 1423689687 18000 # Node ID 507901240749923d3e3b1a0bb4beeca01d3bd538 # Parent 0895fe70075de47b23e9135fc34e9a64a8c67ec6 Uploaded diff -r 0895fe70075d -r 507901240749 bismark_bowtie2_wrapper.xml --- a/bismark_bowtie2_wrapper.xml Mon Jan 26 14:46:05 2015 -0500 +++ b/bismark_bowtie2_wrapper.xml Wed Feb 11 16:21:27 2015 -0500 @@ -1,4 +1,4 @@ - + bisulfite mapper (bowtie2) @@ -7,10 +7,16 @@ samtools bowtie2 - + + + + + + + @@ -213,7 +222,7 @@ - + - singlePaired['sPaired'] == "paired" - params['settingsType'] == "custom" - params['supressed_read_file'] is True + + (( + singlePaired['sPaired'] == "paired" and + params['settingsType'] == "custom" and + params['suppressed_read_file'] is True + )) + @@ -295,9 +308,9 @@ - + @@ -319,18 +332,22 @@ - + - singlePaired['sPaired'] == "paired" - params['settingsType'] == "custom" - params['unmapped_read_file'] is True + + (( + singlePaired['sPaired'] == "paired" and + params['settingsType'] == "custom" and + params['unmapped_read_file'] is True + )) + @@ -339,9 +356,9 @@ - + @@ -352,6 +369,7 @@ + + + 10.1093/bioinformatics/btr167 + diff -r 0895fe70075d -r 507901240749 bismark_bowtie_wrapper.xml --- a/bismark_bowtie_wrapper.xml Mon Jan 26 14:46:05 2015 -0500 +++ b/bismark_bowtie_wrapper.xml Wed Feb 11 16:21:27 2015 -0500 @@ -1,4 +1,4 @@ - + bisulfite mapper (bowtie) @@ -7,8 +7,14 @@ samtools bowtie - + + + + + + + @@ -191,7 +201,7 @@ - + @@ -271,9 +281,9 @@ - + @@ -295,9 +305,9 @@ - + @@ -314,21 +324,20 @@ - + - - + + + 10.1093/bioinformatics/btr167 + diff -r 0895fe70075d -r 507901240749 bismark_methylation_extractor.xml --- a/bismark_methylation_extractor.xml Mon Jan 26 14:46:05 2015 -0500 +++ b/bismark_methylation_extractor.xml Wed Feb 11 16:21:27 2015 -0500 @@ -1,4 +1,4 @@ - + Reports on methylation status of reads mapped by Bismark @@ -9,6 +9,7 @@ + @@ -187,11 +189,12 @@ + diff -r 0895fe70075d -r 507901240749 bismark_wrapper.py --- a/bismark_wrapper.py Mon Jan 26 14:46:05 2015 -0500 +++ b/bismark_wrapper.py Wed Feb 11 16:21:27 2015 -0500 @@ -17,7 +17,6 @@ def __main__(): - print 'tempfile_location',tempfile.gettempdir() #Parse Command Line parser = argparse.ArgumentParser(description='Wrapper for the bismark bisulfite mapper.') parser.add_argument( '-p', '--num-threads', dest='num_threads', @@ -258,9 +257,6 @@ # Final bismark command: cmd = cmd % arguments - print 'bismark_cmd:', cmd - #sys.stderr.write( cmd ) - #sys.exit(1) # Run try: tmp_out = tempfile.NamedTemporaryFile().name @@ -321,8 +317,8 @@ """ #tmp_out = tempfile.NamedTemporaryFile( dir=output_dir ).name tmp_stdout = open( tmp_out, 'wab' ) - tmp_err = tempfile.NamedTemporaryFile( dir=output_dir ).name - tmp_stderr = open( tmp_err, 'wb' ) + #tmp_err = tempfile.NamedTemporaryFile( dir=output_dir ).name + tmp_stderr = open( tmp_err, 'wab' ) tmp_res = tempfile.NamedTemporaryFile( dir= output_dir).name @@ -338,18 +334,22 @@ if returncode != 0: raise Exception, open( tmp_stderr.name ).read() else: - tmp_res = bam_files[0] + tmp_res = bam_files[0] bam_path = "%s" % tmp_res if os.path.exists( bam_path ): - if args.sort_bam: - cmd = 'samtools sort -@ %s %s %s' % (args.num_threads, bam_path, args.output) - else: - shutil.copy( bam_path, args.output ) + if args.sort_bam: + cmd = 'samtools sort -@ %s %s sorted_bam' % (args.num_threads, bam_path) + proc = subprocess.Popen( args=shlex.split( cmd ) ) + returncode = proc.wait() + if returncode != 0: + raise Exception("Error during '%s'" % cmd) + shutil.move( 'sorted_bam.bam', args.output ) + else: + shutil.move( bam_path, args.output ) else: stop_err( 'BAM file no found:\n' + str( bam_path ) ) - # TODO: look for errors in program output.