Beispiel #1
0
def test_TC(filename, scorer):
    fasta_seqs = SeqIO.parse(open('../RV11/' + filename + '.tfa'), 'fasta')
    seqs = []
    for fs in fasta_seqs:
        seqs.append(strToSeqStruct(fs.id, str(fs.seq)))
    our_bloc = aligne_multiple(seqs, scorer)
    ref = msftoDict('../RV11/' + filename + '.msf')
    print(TC(ref, our_bloc))
Beispiel #2
0
    def alignate():
        global SEQS, params, bloc
        params["openGap"] = float(oG.get())
        params["extendGap"] = float(eG.get())


        scorer = aminoAcidScorer(str(sName.get()), params)
        log(logs, "scorer : " + scorer.getName() + " " + str(scorer.getParams()))
        log(logs, "Alignement des séquences en cours ...")
        bloc = aligne_multiple(SEQS, scorer)
        ButtonMSF['state'] = 'normal'
        showBloc(bloc)
Beispiel #3
0
 def run(self):
     """Code à exécuter pendant l'exécution du thread."""
     self.score = SPS_romainTuned(self.msf,
                                  aligne_multiple(self.seqs, self.scorer))
     print(self.label, int(1000 * self.score) / 1000)
Beispiel #4
0
    def optimize():
        global SEQS, globalparams, bloc, SEQSmsf, filename
        msfToSeqs()
        #globalparams["openGap"] = [float(oGm.get()), float(oGp.get())]
        #globalparams["extendGap"] = [float(eGm.get()), float(eGp.get())]

        if "enf_mixte" not in globalparams:
            globalparams["enf_mixte"] = [0, 4]

        if "vrac_mixte" not in globalparams:
            globalparams["vrac_mixte"] = [0, 0]
        if "helice_mixte" not in globalparams:
            globalparams["helice_mixte"] = [0, 0]
        if "struct_mixte" not in globalparams:
            globalparams["struct_mixte"] = [0, 0]

        if "enf_propre" not in globalparams:
            globalparams["enf_propre"] = [0, 0]

        if "struct_propre" not in globalparams:
            globalparams["struct_propre"] = [0, 3]
        if "helice_propre" not in globalparams:
            globalparams["helice_propre"] = [1, 3]

        if "openGap" not in globalparams:
            globalparams["openGap"] = [14.3, 14.3]
        if "extendGap" not in globalparams:
            globalparams["extendGap"] = [2.9, 2.9]

        print("Parameters : " + str(globalparams))

        PD = pd.DataFrame(columns=["seqName", "SPS", "time", "iter"] +
                          [k for k in globalparams.keys()],
                          index=np.arange(0,
                                          int(niter.get()) * len(SEQS)))

        SPS = 0
        bestparams = dict()

        ii = 0
        for i in range(0, int(niter.get())):
            params = dict()
            for k, v in globalparams.items():
                params[k] = round(10 *
                                  (v[0] +
                                   (v[1] - v[0]) * random.uniform(0, 1))) / 10
            print("Iteration", i, str(params))

            if (multithreading.get()):
                keys = list(SEQS.keys())
                T = [
                    ALIGNEMENT_SCORE([
                        SEQSmsf[keys[k]].copy(), SEQS[keys[k]].copy(),
                        aminoAcidScorer(str(sName.get()), params), keys[k]
                    ]) for k in range(0, len(keys))
                ]
                [T[k].start() for k in range(0, len(keys))]
                [T[k].join() for k in range(0, len(keys))]
                tmpSPS = sum(T[k].getScore()
                             for k in range(0, len(keys))) / len(SEQS)

            else:
                tmpSPS = 0
                scorer = aminoAcidScorer(str(sName.get()), params)
                for kk in SEQS.keys():
                    tt = time.time()
                    b = aligne_multiple(SEQS[kk], scorer)
                    tmptmpSPS = SPS_romainTuned(SEQSmsf[kk], b)

                    PD.loc[ii]["seqName"] = kk
                    PD.loc[ii]["iter"] = i
                    PD.loc[ii]["SPS"] = tmptmpSPS
                    PD.loc[ii]["time"] = time.time() - tt
                    for k in params.keys():
                        PD.loc[ii][k] = params[k]
                    ii += 1
                    print(kk, tmptmpSPS, time.time() - tt)
                    tmpSPS += tmptmpSPS / len(SEQS)
            print("Iteration", i, "SPS =", int(100000 * tmpSPS) / 100000)
            if (tmpSPS > SPS):
                SPS = tmpSPS
                bestparams = params

        d = str(datetime.datetime.now())
        d = d[:4] + "_" + d[5:7] + "_" + d[8:10] + "_" + d[11:13] + "_" + d[
            14:16] + "_" + d[17:19]
        PD.to_csv("RESULT_" + d + ".csv", index=False)
        print(bestparams, SPS)