Esempio n. 1
0
def eggnog_map_one(f, cpu=8):
    for db_f in ['eggnog.db', 'eggnog_proteins.dmnd']:
        if not exists(join('/dev/shm', db_f)):
            copy(join(Annotate.OM_RGC.EmapperDir, 'data', db_f),
                 join('/dev/shm', db_f))
        elif os.stat(join('/dev/shm', db_f)).st_size != os.stat(
                join(Annotate.OM_RGC.EmapperDir, 'data', db_f)).st_size:
            sleep(200)  #wait for file to copy
    tmpdir = join(Annotate.OM_RGC.AnnotDir, 'tmp', split3way(f)[1])
    rmrf(tmpdir)
    chdirmkifnotexist(tmpdir)
    shell_command("{} {} -i {} --output {} -m diamond --cpu {} --override --data_dir /dev/shm --temp_dir {} --no_file_comment"\
                  .format(Annotate.OM_RGC.Py27, Annotate.OM_RGC.EmapperPy, f,
                          join(Annotate.OM_RGC.AnnotDir, split3way(f)[1]), cpu,
                          tmpdir), verbose=True)
def filt_sort_split(fnames, outfol, out_fname, reference_list, prob_thresh,
                    threads):
    filts = []
    unite_f = join(outfol, out_fname + '.u.bam')
    sort_f = unite_f.replace('.u.bam', '.s.bam')
    if not exists('{}.done'.format(join(outfol, out_fname))):
        for fname in fnames:
            filt_f = join(outfol,
                          basename(fname.replace('.icra.bam', '.filt.bam')))
            filts.append(filt_f)
            do(fname, filt_f, prob_thresh)
        samcat(filts, unite_f, delinfile=True)
        samsort(unite_f, sort_f, threads, delinfile=True)
        shell_command('touch {}.done'.format(join(outfol, out_fname)))
    splitbam(sort_f, outfol, reference_list)
Esempio n. 3
0
def mpilupcall(fnames,
               db_fasta,
               outvcf,
               Q=15,
               L=1000,
               d=100000,
               m=2,
               threads=8):
    if len(fnames) == 0:
        return
    cmd = 'bcftools mpileup --threads {} -a FORMAT/AD -Q {} -L {} -d {} -m {} -f {} {}'\
            .format(threads, Q, L , d, m, db_fasta, ' '.join(fnames))
    cmd += ' | bcftools call --threads {} -Ov -mv -o {}'.format(
        threads, outvcf)
    shell_command(cmd)
def mpileup_call(dirnm, threads, fasta_db, mpileup_params, del_indir=True):
    shell_command('ulimit -n 16384')
    outvcf = dirnm + '.vcf'
    donef = dirnm + '_calling.done'
    if exists(donef):
        return
    mpilupcall([join(dirnm, '*.bam')],
               fasta_db,
               outvcf,
               Q=mpileup_params['min_base_qual'],
               L=mpileup_params['max_depth_indel'],
               d=mpileup_params['max_depth'],
               m=mpileup_params['min_iReads'],
               threads=threads)
    if del_indir:
        rmrf(dirnm)
    shell_command('touch {}'.format(donef))
Esempio n. 5
0
def samcat(fnames, unite_f, delinfile=True):
    shell_command('samtools cat -o {} {}'.format(unite_f, ' '.join(fnames)))
    if delinfile:
        for fname in fnames:
            tryrm(fname)
Esempio n. 6
0
def samsort(fname_in, fname_out, threads, delinfile=False):
    shell_command('samtools sort -@ {} -o {} {}'.format(
        threads - 1, fname_out, fname_in))
    if delinfile:
        tryrm(fname_in)