コード例 #1
0
ファイル: pbsearch.py プロジェクト: forrestzhang/Chorus
def exonerate_pbsearch(fafile, esifile, espath, ep, threadnum, pblength, setpsize, dtm=10, minIdentity=75,
                       exonerateport=10005):

    fa = loadfa.loadfa(fafile)

    fa = fa.replace('n', '')

    fa = fa.replace('N', '')

    seqlen = len(fa)

    windlen = 10000

    sptime = int(seqlen/windlen)+1

    pars = list()

    #start exonerate server

    # exonerate.start_exonerate_server(espath=espath, esifile=esifile, threadnum=24,  exonerateport=exonerateport)

    time.sleep(10)

    for sc in range(sptime):

        nowstart = sc * windlen

        nowend = nowstart + windlen + 50

        if nowend > seqlen:

            nowend = seqlen-1

        nowseq = fa[nowstart:nowend]

        # print(nowseq)

        par = dict()

        par['sequence'] = nowseq

        par['exonerateport'] = exonerateport

        par['ep'] = ep

        par['minIdentity'] = minIdentity

        par['pblength'] = pblength

        pars.append(par)

    pool = Pool(threadnum)

    res = pool.map(exonerate_getseqlen, pars)

    probe = dict()

    for i in res:

        for j in i:

            if j in probe:

                probe[j] = +1
            else:
                probe[j] = 1


    exonerate.stop_exonerate_server()


    probelist = list()

    print(probe)

    for probeseq in probe:

        if probe[probeseq] == 1:

            probelist.append(probeseq)

    return probelist
コード例 #2
0
ファイル: pbsearch.py プロジェクト: forrestzhang/Chorus
            for nowseq in tmpseq:

                if tmpseq[nowseq] == 1:

                    print('>',nowseq, sep='', file=tmpfaio)

                    print(nowseq, file=tmpfaio)

    tmpfaio.close()

    exonerate.exonerate_search_sequence2(ep=ep, sequencefile=tmpfa, exonerateport=exonerateport,
                                                             minIdentity=minIdentity)
    return probelist

if __name__ == "__main__":

    try:
        prb = exonerate_pbsearch(fafile='/Users/Forrest/Documents/Project/Chorus/Test/PGSC_DM_v4.03_pseudomolecules_genes_exon_test.fa',
                       esifile='/Users/Forrest/Documents/Project/Chorus/Test/Gy14.sei',
                       espath='/opt/local/bin/exonerate-server', ep='/opt/local/bin/exonerate',
                       setpsize=5,
                       exonerateport=10005,
                       threadnum=2,
                       pblength = 45, dtm=10, minIdentity=75)

        print(prb)
    except KeyboardInterrupt:
        exonerate.stop_exonerate_server()
        sys.stderr.write("User interrupt\n")

        sys.exit(0)