本文整理匯總了Python中pysam.faidx方法的典型用法代碼示例。如果您正苦於以下問題:Python pysam.faidx方法的具體用法?Python pysam.faidx怎麽用?Python pysam.faidx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pysam
的用法示例。
在下文中一共展示了pysam.faidx方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_vcf_and_read_depths_files
# 需要導入模塊: import pysam [as 別名]
# 或者: from pysam import faidx [as 別名]
def _make_vcf_and_read_depths_files(self):
if not os.path.exists(self.ref_fa + '.fai'):
pysam.faidx(self.ref_fa)
tmp_vcf = self.vcf_file + '.tmp'
with open(tmp_vcf, 'w') as f:
print(pysam.mpileup(
'-t', 'INFO/AD,INFO/ADF,INFO/ADR',
'-L', '99999999',
'-A',
'-f', self.ref_fa,
'-u',
'-v',
self.bam,
), end='', file=f)
got = vcfcall_ariba.vcfcall_ariba(tmp_vcf, self.outprefix, self.min_var_read_depth, self.min_second_var_read_depth, self.max_allele_freq)
if got != 0:
raise Error('Error parsing vcf file. Cannot contine')
pysam.tabix_compress(self.outprefix + '.read_depths', self.read_depths_file)
pysam.tabix_index(self.read_depths_file, seq_col=0, start_col=1, end_col=1)
os.unlink(self.outprefix + '.read_depths')
os.unlink(tmp_vcf)
示例2: indexGenome
# 需要導入模塊: import pysam [as 別名]
# 或者: from pysam import faidx [as 別名]
def indexGenome(infile, outfile):
'''index the genome for samtools.
Samtools does not like long lines, so create a new file
with split lines (what a waste).
'''
# statement = '''fold %(infile)s | perl -p -e "s/chr//" > %(outfile)s'''
statement = '''fold %(infile)s > %(outfile)s'''
P.run()
pysam.faidx(outfile)
######################################################################
######################################################################
######################################################################
示例3: get_sequence
# 需要導入模塊: import pysam [as 別名]
# 或者: from pysam import faidx [as 別名]
def get_sequence(self, locus):
if self.genome_path is None:
tprint('MSILocusLoader error: Can not use .get_sequence() without'
+ ' specifying the path to the reference genome!')
exit(1)
sequence = []
for subseq in pysam.faidx(self.genome_path, locus)[1:]:
sequence.append(subseq.strip())
return ''.join(sequence).upper()
# end .get_sequence()
# end MSILocusLoader class definition.
示例4: write_fa_subset
# 需要導入模塊: import pysam [as 別名]
# 或者: from pysam import faidx [as 別名]
def write_fa_subset(seq_names, infile, outfile):
if not os.path.exists(infile + '.fai'):
pysam.faidx(infile)
f = pyfastaq.utils.open_file_write(outfile)
for name in seq_names:
print(pysam.faidx(infile, name), end='', file=f)
pyfastaq.utils.close(f)