本文整理汇总了Python中galaxy.util.bunch.Bunch.command方法的典型用法代码示例。如果您正苦于以下问题:Python Bunch.command方法的具体用法?Python Bunch.command怎么用?Python Bunch.command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.util.bunch.Bunch
的用法示例。
在下文中一共展示了Bunch.command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __main__
# 需要导入模块: from galaxy.util.bunch import Bunch [as 别名]
# 或者: from galaxy.util.bunch.Bunch import command [as 别名]
#.........这里部分代码省略.........
# Handle --strand
set_options += '--strand=%s ' % options.strand
# Handle --ambiguous
if options.ambiguous not in [ "no" ]:
set_options += '--ambiguous=%s ' % options.ambiguous
# Handle --shortcuts_for_yasra
if options.shortcuts_for_yasra not in [ 'none' ]:
set_options += '--%s ' % ( options.shortcuts_for_yasra )
# Specify input2 and add [fullnames] modifier if output format is diffs
if options.format == 'diffs':
input2 = '%s[fullnames]' % options.input2
else:
input2 = options.input2
if options.format == 'tabular':
# Change output format to general if it's tabular and add field names for tabular output
format = 'general-'
tabular_fields = ':score,name1,strand1,size1,start1,zstart1,end1,length1,text1,name2,strand2,size2,start2,zstart2,end2,start2+,zstart2+,end2+,length2,text2,diff,cigar,identity,coverage,gaprate,diagonal,shingle'
elif options.format == 'sam':
# We currently need to keep headers.
format = 'sam'
tabular_fields = ''
else:
format = options.format
tabular_fields = ''
# Set up our queues
threads = int( options.threads )
lastz_job_queue = LastzJobQueue( threads, slots=SLOTS )
combine_data_queue = CombineDataQueue( options.output )
if str( options.ref_source ) in [ 'history', 'self' ]:
# Reference is a fasta dataset from the history or the dataset containing the target sequence itself,
# so split job across the number of sequences in the dataset ( this could be a HUGE number ).
try:
# Ensure there is at least 1 sequence in the dataset ( this may not be necessary ).
error_msg = "The reference dataset is missing metadata. Click the pencil icon in the history item and 'auto-detect' the metadata attributes."
ref_sequences = int( options.ref_sequences )
if ref_sequences < 1:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( error_msg )
except:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( error_msg )
seqs = 0
fasta_reader = FastaReader( open( options.input1 ) )
while True:
# Read the next sequence from the reference dataset
seq = fasta_reader.next()
if not seq:
break
seqs += 1
# Create a temporary file to contain the current sequence as input to lastz
tmp_in_fd, tmp_in_name = tempfile.mkstemp( suffix='.in' )
tmp_in = os.fdopen( tmp_in_fd, 'wb' )
# Write the current sequence to the temporary input file
tmp_in.write( '>%s\n%s\n' % ( seq.name, seq.text ) )
tmp_in.close()
# Create a 2nd temporary file to contain the output from lastz execution on the current sequence
tmp_out_fd, tmp_out_name = tempfile.mkstemp( suffix='.out' )
os.close( tmp_out_fd )
# Generate the command line for calling lastz on the current sequence
command = 'lastz %s%s %s %s --format=%s%s > %s' % ( tmp_in_name, ref_name, input2, set_options, format, tabular_fields, tmp_out_name )
# Create a job object
job = Bunch()
job.command = command
job.output = tmp_out_name
job.cleanup = [ tmp_in_name, tmp_out_name ]
job.combine_data_queue = combine_data_queue
# Add another job to the lastz_job_queue. Execution will wait at this point if the queue is full.
lastz_job_queue.put( job, block=True )
# Make sure the value of sequences in the metadata is the same as the number of
# sequences read from the dataset. According to Bob, this may not be necessary.
if ref_sequences != seqs:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( "The value of metadata.sequences (%d) differs from the number of sequences read from the reference (%d)." % ( ref_sequences, seqs ) )
else:
# Reference is a locally cached 2bit file, split job across number of chroms in 2bit file
tbf = TwoBitFile( open( options.input1, 'r' ) )
for chrom in tbf.keys():
# Create a temporary file to contain the output from lastz execution on the current chrom
tmp_out_fd, tmp_out_name = tempfile.mkstemp( suffix='.out' )
os.close( tmp_out_fd )
command = 'lastz %s/%s%s %s %s --format=%s%s >> %s' % \
( options.input1, chrom, ref_name, input2, set_options, format, tabular_fields, tmp_out_name )
# Create a job object
job = Bunch()
job.command = command
job.output = tmp_out_name
job.cleanup = [ tmp_out_name ]
job.combine_data_queue = combine_data_queue
# Add another job to the lastz_job_queue. Execution will wait at this point if the queue is full.
lastz_job_queue.put( job, block=True )
# Stop the lastz_job_queue.
for t in lastz_job_queue.threads:
lastz_job_queue.put( STOP_SIGNAL, True )
# Although all jobs are submitted to the queue, we can't shut down the combine_data_queue
# until we know that all jobs have been submitted to its queue. We do this by checking
# whether all of the threads in the lastz_job_queue have terminated.
while threading.activeCount() > 2:
time.sleep( 1 )
# Now it's safe to stop the combine_data_queue.
combine_data_queue.put( STOP_SIGNAL )
示例2: __main__
# 需要导入模块: from galaxy.util.bunch import Bunch [as 别名]
# 或者: from galaxy.util.bunch.Bunch import command [as 别名]
#.........这里部分代码省略.........
options.O, options.E, options.X, options.Y, options.K, options.L, options.entropy )
# Specify input2 and add [fullnames] modifier if output format is diffs
if options.format == 'diffs':
input2 = '%s[fullnames]' % options.input2
else:
input2 = options.input2
if options.format == 'tabular':
# Change output format to general if it's tabular and add field names for tabular output
format = 'general-'
tabular_fields = ':score,name1,strand1,size1,start1,zstart1,end1,length1,text1,name2,strand2,size2,start2,zstart2,end2,start2+,zstart2+,end2+,length2,text2,diff,cigar,identity,coverage,gaprate,diagonal,shingle'
elif options.format == 'sam':
# We currently ALWAYS suppress SAM headers.
format = 'sam-'
tabular_fields = ''
else:
format = options.format
tabular_fields = ''
# Set up our queues
lastz_job_queue = LastzJobQueue( WORKERS, slots=SLOTS )
combine_data_queue = CombineDataQueue( options.output )
if options.ref_source == 'history':
# Reference is a fasta dataset from the history, so split job across
# the number of sequences in the dataset ( this could be a HUGE number )
try:
# Ensure there is at least 1 sequence in the dataset ( this may not be necessary ).
error_msg = "The reference dataset is missing metadata, click the pencil icon in the history item and 'auto-detect' the metadata attributes."
ref_sequences = int( options.ref_sequences )
if ref_sequences < 1:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( error_msg )
except:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( error_msg )
seqs = 0
fasta_reader = FastaReader( open( options.input1 ) )
while True:
# Read the next sequence from the reference dataset
seq = fasta_reader.next()
if not seq:
break
seqs += 1
# Create a temporary file to contain the current sequence as input to lastz
tmp_in_fd, tmp_in_name = tempfile.mkstemp( suffix='.in' )
tmp_in = os.fdopen( tmp_in_fd, 'wb' )
# Write the current sequence to the temporary input file
tmp_in.write( '>%s\n%s\n' % ( seq.name, seq.text ) )
tmp_in.close()
# Create a 2nd temporary file to contain the output from lastz execution on the current sequence
tmp_out_fd, tmp_out_name = tempfile.mkstemp( suffix='.out' )
os.close( tmp_out_fd )
# Generate the command line for calling lastz on the current sequence
command = 'lastz %s%s%s %s %s --ambiguousn --nolaj --identity=%s..%s --coverage=%s --format=%s%s > %s' % \
( tmp_in_name, unmask, ref_name, input2, set_options, options.identity_min,
options.identity_max, options.coverage, format, tabular_fields, tmp_out_name )
# Create a job object
job = Bunch()
job.command = command
job.output = tmp_out_name
job.cleanup = [ tmp_in_name, tmp_out_name ]
job.combine_data_queue = combine_data_queue
# Add another job to the lastz_job_queue. Execution
# will wait at this point if the queue is full.
lastz_job_queue.put( job, block=True )
# Make sure the value of sequences in the metadata is the same as the
# number of sequences read from the dataset ( this may not be necessary ).
if ref_sequences != seqs:
stop_queues( lastz_job_queue, combine_data_queue )
stop_err( "The value of metadata.sequences (%d) differs from the number of sequences read from the reference (%d)." % ( ref_sequences, seqs ) )
else:
# Reference is a locally cached 2bit file, split job across number of chroms in 2bit file
tbf = TwoBitFile( open( options.input1, 'r' ) )
for chrom in tbf.keys():
# Create a temporary file to contain the output from lastz execution on the current chrom
tmp_out_fd, tmp_out_name = tempfile.mkstemp( suffix='.out' )
os.close( tmp_out_fd )
command = 'lastz %s/%s%s%s %s %s --ambiguousn --nolaj --identity=%s..%s --coverage=%s --format=%s%s >> %s' % \
( options.input1, chrom, unmask, ref_name, input2, set_options, options.identity_min,
options.identity_max, options.coverage, format, tabular_fields, tmp_out_name )
# Create a job object
job = Bunch()
job.command = command
job.output = tmp_out_name
job.cleanup = [ tmp_out_name ]
job.combine_data_queue = combine_data_queue
# Add another job to the lastz_job_queue. Execution
# will wait at this point if the queue is full.
lastz_job_queue.put( job, block=True )
# Stop the lastz_job_queue
for t in lastz_job_queue.threads:
lastz_job_queue.put( STOP_SIGNAL, True )
# Although all jobs are submitted to the queue, we can't shut down the combine_data_queue
# until we know that all jobs have been submitted to its queue. We do this by checking
# whether all of the threads in the lastz_job_queue have terminated.
while threading.activeCount() > 2:
time.sleep( 1 )
# Now it's safe to stop the combine_data_queue
combine_data_queue.put( STOP_SIGNAL )