3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7d7419ddad18/ Changeset: 7d7419ddad18 Branch: stable User: natefoo Date: 2015-01-28 15:38:22+00:00 Summary: Allow BAM's set_meta() to use samtools 1 to generate the index, if the samtools found on $PATH is samtools 1. Affected #: 1 file diff -r 837baf8a92add3084c7e230cf537016192a78b55 -r 7d7419ddad18212b60eaf1b5c30196bf9ad2328b lib/galaxy/datatypes/binary.py --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -240,10 +240,19 @@ ##$ samtools index ##Usage: samtools index <in.bam> [<out.index>] stderr_name = tempfile.NamedTemporaryFile( prefix = "bam_index_stderr" ).name - command = 'samtools index %s %s' % ( dataset.file_name, index_file.file_name ) - proc = subprocess.Popen( args=command, shell=True, stderr=open( stderr_name, 'wb' ) ) + command = [ 'samtools', 'index', dataset.file_name, index_file.file_name ] + proc = subprocess.Popen( args=command, stderr=open( stderr_name, 'wb' ) ) exit_code = proc.wait() #Did index succeed? + if exit_code == -6: + # SIGABRT, most likely samtools 1.0+ which does not accept the index name parameter. + command = [ 'samtools', 'index', dataset.file_name ] + proc = subprocess.Popen( args=command, stderr=open( stderr_name, 'wb' ) ) + exit_code = proc.wait() + if os.path.exists( os.path.join( dataset.file_name, '.bai' ) ): + shutil.move( os.path.join( dataset.file_name, '.bai' ), index_file.file_name ) + else: + open( stderr_name, 'ab+' ).write( 'Galaxy attempted to build the BAM index with samtools 1.0+ but failed\n') stderr = open( stderr_name ).read().strip() if stderr: if exit_code != 0: https://bitbucket.org/galaxy/galaxy-central/commits/d05da0df53b9/ Changeset: d05da0df53b9 Branch: stable User: natefoo Date: 2015-01-28 16:58:23+00:00 Summary: Use a symlink to the dataset in the same directory as the MetadataTempFile as the input to samtools index so there's no clobber risk. Thanks Dan. Affected #: 1 file diff -r 7d7419ddad18212b60eaf1b5c30196bf9ad2328b -r d05da0df53b98639d753d94e9ffaa1e99c918142 lib/galaxy/datatypes/binary.py --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -246,13 +246,18 @@ #Did index succeed? if exit_code == -6: # SIGABRT, most likely samtools 1.0+ which does not accept the index name parameter. - command = [ 'samtools', 'index', dataset.file_name ] - proc = subprocess.Popen( args=command, stderr=open( stderr_name, 'wb' ) ) - exit_code = proc.wait() - if os.path.exists( os.path.join( dataset.file_name, '.bai' ) ): - shutil.move( os.path.join( dataset.file_name, '.bai' ), index_file.file_name ) - else: - open( stderr_name, 'ab+' ).write( 'Galaxy attempted to build the BAM index with samtools 1.0+ but failed\n') + dataset_symlink = os.path.join( os.path.dirname( index_file.file_name ), + '__dataset_%d_%s' % ( dataset.id, os.path.basename( index_file.file_name ) ) ) + os.symlink( dataset.file_name, dataset_symlink ) + try: + command = [ 'samtools', 'index', dataset_symlink ] + proc = subprocess.Popen( args=command, stderr=open( stderr_name, 'wb' ) ) + exit_code = proc.wait() + shutil.move( dataset_symlink + '.bai', index_file.file_name ) + except Exception, e: + open( stderr_name, 'ab+' ).write( 'Galaxy attempted to build the BAM index with samtools 1.0+ but failed: %s\n' % e) + finally: + os.unlink( dataset_symlink ) stderr = open( stderr_name ).read().strip() if stderr: if exit_code != 0: https://bitbucket.org/galaxy/galaxy-central/commits/a481d17c0448/ Changeset: a481d17c0448 Branch: stable User: natefoo Date: 2015-01-28 18:25:11+00:00 Summary: Use subprocess.call() rather than Popen(), thanks Nicola. Affected #: 1 file diff -r d05da0df53b98639d753d94e9ffaa1e99c918142 -r a481d17c04482b069e6b2ebdda4fbca01448fa9c lib/galaxy/datatypes/binary.py --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -251,8 +251,7 @@ os.symlink( dataset.file_name, dataset_symlink ) try: command = [ 'samtools', 'index', dataset_symlink ] - proc = subprocess.Popen( args=command, stderr=open( stderr_name, 'wb' ) ) - exit_code = proc.wait() + exit_code = subprocess.call( args=command, stderr=open( stderr_name, 'wb' ) ) shutil.move( dataset_symlink + '.bai', index_file.file_name ) except Exception, e: open( stderr_name, 'ab+' ).write( 'Galaxy attempted to build the BAM index with samtools 1.0+ but failed: %s\n' % e) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.