Exemplo n.º 1
0
def write_output_file(outDir, res, name, e_di, sum, exMat):
    '''
    Write the output of edits and bowtie files.
    '''
    fname = '{}/{}/{}_{}.txt'.format(outDir, name, res, name)
    with open(fname, 'a+') as f:
        for k, v in e_di.iteritems():
            f.write('{}\tCount:{}\tEM:{}'.format(k, ftoi(sum[k]), ftoi(exMat[k])))
            for edit in sorted(v):
                item = '{}:{}'.format(edit, ftoi(v[edit]))
                f.write('\t{}'.format(item))
            f.write('\n')
    with open(fname, 'r') as f:
        logging.info(fname)
        logging.info(f.read())
Exemplo n.º 2
0
def write_output_file(outDir, res, name, e_di, sum, exMat):
    '''
    Write the output of edits and bowtie files.
    '''
    fname = '{}/{}/{}_{}.txt'.format(outDir, name, res, name)
    with open(fname, 'a+') as f:
        for k, v in e_di.iteritems():
            f.write('{}\tCount:{}\tEM:{}'.format(k, ftoi(sum[k]),
                                                 ftoi(exMat[k])))
            for edit in sorted(v):
                item = '{}:{}'.format(edit, ftoi(v[edit]))
                f.write('\t{}'.format(item))
            f.write('\n')
    with open(fname, 'r') as f:
        logging.info(fname)
        logging.info(f.read())
Exemplo n.º 3
0
def write_processed_shrimp_output(hits, tags, mirLi, mirStr, shrimp_dir):
    '''
    Write the processed shrimp output to chromosomal directory in g1Results.
    '''
    dname = '{}/g1Results'.format(os.path.dirname(shrimp_dir))
    read_size = os.path.basename(shrimp_dir)
    for win, tag in hits.iteritems():
        chr, st, sp, str = alter_window_name(win)
        dirName = '{}/{}'.format(dname, chr)
        if not os.path.exists(dirName):
            os.makedirs(dirName)

        fname = '{}/{}.results_{}'.format(dirName, win, read_size)
        if len(tag) > 0:
            with open(fname, 'w') as fo:
                for h in hits[win]:
                    readTag, window, strand, cSt, cEn, rSt, rEn, rLen, score, estr, null = hits[win][h].split('\t')
                    if 'M' in str:
                        pos = int(sp) - int(cEn)
                        winStr = '-'
                    else:
                        pos = int(st) + int(cSt)
                        winStr = '+'
                    mir = check_if_mir(chr, pos, winStr, mirLi, mirStr)
                    fo.write('{}{}\t{}\n'.format(hits[win][h], mir, ftoi(tags[h][win])))
Exemplo n.º 4
0
def write_processed_shrimp_output(hits, tags, mirLi, mirStr, shrimp_dir):
    '''
    Write the processed shrimp output to chromosomal directory in g1Results.
    '''
    dname = '{}/g1Results'.format(os.path.dirname(shrimp_dir))
    read_size = os.path.basename(shrimp_dir)
    for win, tag in hits.iteritems():
        chr, st, sp, str = alter_window_name(win)
        dirName = '{}/{}'.format(dname, chr)
        if not os.path.exists(dirName):
            try:
                os.makedirs(dirName)
            except:
                pass

        fname = '{}/{}.results_{}'.format(dirName, win, read_size)
        if len(tag) > 0:
            with open(fname, 'w') as fo:
                for h in hits[win]:
                    readTag, window, strand, cSt, cEn, rSt, rEn, rLen, score, estr, null = hits[win][h].split('\t')
                    if 'M' in str:
                        pos = int(sp) - int(cEn)
                        winStr = '-'
                    else:
                        pos = int(st) + int(cSt)
                        winStr = '+'
                    mir = check_if_mir(chr, pos, winStr, mirLi, mirStr)
                    fo.write('{}{}\t{}\n'.format(hits[win][h], mir, ftoi(tags[h][win])))