예제 #1
0
def generateautomata(translatefile, clustalfile):
    # structures initiales
    clustalalilist = dataread.importclustalWdata(clustalfile)
    dictoflistseqstate, listofsequence, setoftransition, linenumber = dataread.importdatadictfromtranslatedata(
        translatefilei
    )
    listoftransition = list(setoftransition)
    listoftransition.sort()  # juste to have the inital number of col in the automata
    numberoftransition = len(listoftransition)
    # creation de l automate
    automata = generatestartautomata(numberoftransition)
    automata = generateinitialstate(automata, listofsequence, listoftransition, numberoftransition)
    # apprentisage a partir de l alignement multiple
    automata = generateloop(automata, clustalalilist, listoftransition, numberoftransition)
import automate
import dataread
import sys

name=str(sys.argv[1]).split("/")[1]
print(name)
reptranslate="datasetstranslate/"
repclustal="aliclustalordered/"
image="image/"
clustalalilist=dataread.importclustalWdata(repclustal+name+".alignement")
dictoflistseqstate,listofsequence,setoftransition,linenumber=dataread.importdatadictfromtranslatedata(reptranslate+name)
listoftransition=list(setoftransition)
listoftransition.sort()#juste to have the inital number of col in the automata
numberoftransition=len(listoftransition)
automata=automate.generatestartautomata(numberoftransition)
automata=automate.generateinitialstate(automata,listofsequence,listoftransition,numberoftransition)
#automate.exportautomateasgraph(automata,False,listoftransition,image+name+".init.png")
automata,dictofloopposition,dictofindexinclustal,poslist=automate.generateloop(automata,clustalalilist,listoftransition,numberoftransition)
#automate.exportautomateasgraph(automata,False,listoftransition,image+name+".generateloop.png")
#print(listoftransition)
#liaison des boucles avec les inits
automata,dictofloopposition,dictofindexinclustal,poslist=automate.mergeloopwithotherstate(automata,dictofloopposition,dictofindexinclustal,poslist,clustalalilist,listoftransition,numberoftransition)
#print("boucleinfo after",dictofloopposition,dictofindexinclustal,poslist)
#print("automate apres merging des loops:",automata)
#automate.exportautomateasgraph(automata,False,listoftransition,image+name+".mergedesloops.png")
#finition de l'automate
#apprentisage a partir des donnes
#on va simplifier le global, complexifier le local:
boucleinformation=[dictofloopposition,dictofindexinclustal,poslist]
automata=automate.learnfromdata(automata,listofsequence,clustalalilist,boucleinformation,listoftransition,numberoftransition)
#print("apres learning du data:",automata)