本文整理汇总了Python中nesoni.io.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_bowtie_index
def build_bowtie_index(self):
io.execute([
'bowtie2-build',
self.reference_fasta_filename(),
self/'bowtie',
],
)
示例2: build_snpeff
def build_snpeff(self):
jar = io.find_jar('snpEff.jar')
with open(self/'snpeff.config','wb') as f:
print >> f, 'data_dir = snpeff'
print >> f, 'genomes : ' + self.name
print >> f, self.name + '.genome : ' + self.name
snpwork = io.Workspace(self/'snpeff',must_exist=False)
snpwork_genome = io.Workspace(snpwork/self.name,must_exist=False)
snpwork_genomes = io.Workspace(snpwork/'genomes',must_exist=False)
annotations = self.annotations_filename()
assert annotations
with open(snpwork_genome/'genes.gff','wb') as f:
for record in annotation.read_annotations(annotations):
if record.end <= record.start: continue
if not record.attr:
record.attr['attributes'] = 'none'
print >> f, record.as_gff()
with open(snpwork_genomes/(self.name+'.fa'),'wb') as f:
for name, seq in io.read_sequences(self.reference_fasta_filename()):
io.write_fasta(f, name, seq)
io.execute('java -jar JAR build NAME -gff3 -c CONFIG',
JAR=jar, NAME=self.name, CONFIG=self/'snpeff.config')
示例3: run
def run(self):
genome = self.genome
if os.path.isdir(genome):
genome = os.path.join(genome, os.path.split(genome)[1]+'.genome')
print genome
#pref_filename = os.path.join(os.path.expanduser('~'),'igv','prefs.properties')
#if os.path.exists(pref_filename):
# with open(pref_filename,'rb') as f:
# lines = f.readlines()
# with open(pref_filename,'wb') as f:
# for line in lines:
# if line.startswith('DEFAULT_GENOME_KEY='):
# #line = 'DEFAULT_GENOME_KEY=\n'
# continue
# f.write(line)
with workspace.tempspace() as temp:
with open(temp/'batch.txt','wb') as f:
print >> f, 'new'
print >> f, 'preference LAST_TRACK_DIRECTORY', os.getcwd()
print >> f, 'preference LAST_GENOME_IMPORT_DIRECTORY', os.getcwd()
print >> f, 'genome '+os.path.abspath(genome)
for filename in self.files:
print >> f, 'load '+os.path.abspath(filename)
io.execute(['java','-Xmx32000m',
#Flags from igb.sh script:
'-Dproduction=true','-Dapple.laf.useScreenMenuBar=true','-Djava.net.preferIPv4Stack=true',
'-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
示例4: sort_and_index
def sort_and_index(in_filename, out_prefix):
io.execute([
'samtools', 'sort', in_filename, out_prefix
])
io.execute([
'samtools', 'index', out_prefix + '.bam'
])
示例5: build_bowtie_index
def build_bowtie_index(self, log_to=sys.stdout):
io.execute([
'bowtie2-build',
self.reference_fasta_filename(),
self/'bowtie',
],
stdout = log_to,
)
示例6: index_vcf
def index_vcf(filename):
""" IGV index a VCF file.
Don't fail if igvtools fails (eg not installed).
"""
try:
io.execute('igvtools index FILENAME',FILENAME=filename)
except (OSError, AssertionError):
print >> sys.stderr, 'Failed to index VCF file with igvtools. Continuing.'
示例7: sort_bam
def sort_bam(in_filename, out_prefix, by_name=False, cores=8):
cores = min(cores, legion.coordinator().get_cores())
megs = max(10, 800 // cores)
io.execute(
[ 'samtools', 'sort', '[email protected]', '%d' % cores, '-m', '%dM' % megs ] +
([ '-n' ] if by_name else [ ]) +
[ in_filename, out_prefix ], cores=cores)
示例8: run
def run(self):
base = os.path.split(self.prefix)[1]
annotations = [ ]
sequences = [ ]
for filename in self.filenames:
any = False
if io.is_sequence_file(filename):
sequences.append(filename)
any = True
if annotation.is_annotation_file(filename):
annotations.append(filename)
any = True
assert any, 'File is neither a recognized sequence or annotation file'
cytoband_filename = os.path.join(self.prefix,base+'_cytoband.txt')
property_filename = os.path.join(self.prefix,'property.txt')
gff_filename = os.path.join(self.prefix,base+'.gff')
output_filenames = [ cytoband_filename, property_filename, gff_filename ]
if not os.path.exists(self.prefix):
os.mkdir(self.prefix)
f = open(property_filename,'wb')
print >> f, 'ordered=true'
print >> f, 'id=%s' % base
print >> f, 'name=%s' % (self.name or base)
print >> f, 'cytobandFile=%s_cytoband.txt' % base
print >> f, 'geneFile=%s.gff' % base
print >> f, 'sequenceLocation=%s' % base
f.close()
trivia.As_gff(output=gff_filename,
filenames=annotations,
exclude=[ 'gene', 'source' ]
).run()
f_cyt = open(cytoband_filename,'wb')
for filename in sequences:
for name, seq in io.read_sequences(filename):
assert '/' not in name
f = open(os.path.join(self.prefix, name + '.txt'), 'wb')
f.write(seq)
f.close()
print >> f_cyt, '%s\t0\t%d' % (name, len(seq))
f_cyt.close()
genome_filename = self.prefix + '.genome'
if os.path.exists(genome_filename):
os.unlink(genome_filename)
io.execute(
['zip', '-j', io.abspath(genome_filename)] +
[ io.abspath(item) for item in output_filenames ]
)
for filename in output_filenames:
if os.path.exists(filename):
os.unlink(filename)
示例9: run
def run(self):
with workspace.tempspace() as temp:
with open(temp/'batch.txt','wb') as f:
print >> f, 'new'
print >> f, 'genome '+os.path.abspath(self.genome)
for filename in self.files:
print >> f, 'load '+os.path.abspath(filename)
io.execute(['java','-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
示例10: build_shrimp_mmap
def build_shrimp_mmap(self, cs=False):
suffix = '-cs' if cs else '-ls'
grace.status('Building SHRiMP mmap')
io.execute([
'gmapper' + suffix,
'--save', self.object_filename('reference' + suffix),
self.reference_fasta_filename(),
])
grace.status('')
示例11: run
def run(self):
from nesoni import io
f_in = self.begin_input()
f_out = self.begin_output()
try:
io.execute(self.command, stdin=f_in, stdout=f_out)
finally:
self.end_output(f_out)
self.end_input(f_in)
示例12: run
def run(self):
with workspace.tempspace() as temp:
with open(temp/'batch.txt','wb') as f:
print >> f, 'new'
print >> f, 'preference LAST_TRACK_DIRECTORY', os.getcwd()
print >> f, 'preference LAST_GENOME_IMPORT_DIRECTORY', os.getcwd()
print >> f, 'genome '+os.path.abspath(self.genome)
for filename in self.files:
print >> f, 'load '+os.path.abspath(filename)
io.execute(['java','-jar',io.find_jar('igv.jar'),'-b',temp/'batch.txt'])
示例13: run
def run(self):
reference = reference_directory.Reference(self.reference, must_exist=True)
jar = io.find_jar('snpEff.jar')
with open(self.prefix + '.vcf','wb') as f:
io.execute('java -jar JAR eff GENOME VCF -c CONFIG',
JAR=jar, GENOME=reference.name, VCF=self.vcf, CONFIG=reference/'snpeff.config',
stdout=f)
index_vcf(self.prefix+'.vcf')
示例14: run
def run(self):
work = self.get_workspace()
acc = self.run_accession
io.execute(
'wget -c URL',
URL='http://ftp-private.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByRun/sra/%s/%s/%s/%s.sra'
% (acc[:3],acc[:6],acc,acc),
cwd=work.working_dir,
)
io.execute(
'fastq-dump --split-files --bzip2 FILENAME',
FILENAME=acc+'.sra',
cwd=work.working_dir,
)
示例15: run
def run(self):
from nesoni import io
assert self.command, 'Nothing to execute!'
print self.ident()
f_in = self.begin_input()
f_out = self.begin_output()
try:
io.execute(self.command[:1] + self.execution_options + self.command[1:],
stdin=f_in, stdout=f_out)
finally:
self.end_output(f_out)
self.end_input(f_in)