Advertisement
Vervena_Limona

Untitled

Mar 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.88 KB | None | 0 0
  1. from string import *
  2. import numpy as np
  3.  
  4. str1=input("Votre fichier 1: ")
  5. str2=input("Votre fichier 2: ")
  6.  
  7.  
  8. def list_fasta (str): #Cela décompose un fichier fasta dans un dictionnaire, mais nous n'utiliserons que la clé "sNuc" du dictionnaire
  9.     f= open(str, 'r')
  10.     index = f.readline()
  11.     dicosequence={}
  12.     while index !="":
  13.         if index[0] == '>':
  14.             dicosequence["nom"]=index
  15.         else:
  16.             dicosequence["sNuc"]=index
  17.         index= f.readline()
  18.     return dicosequence
  19.  
  20. seq1=list_fasta(str1)
  21. seq1=seq1["sNuc"]
  22. seq2=list_fasta(str2)
  23. seq2=seq1["sNuc"]
  24.  
  25. def faites_votre_score_Nucleo():
  26.     scoreperso={}
  27.     scoreperso["match"] = input("Score match : \n")
  28.     scoreperso["transition"] = input("Score mismatch Purine/Purine ou Pyrimidine/pyrimidine :\n")
  29.     scoreperso["transversion"] = input("Score mismatch différents : \n")
  30.     scoreperso["ouverture_gap"] = input("Score ouverture de gap : \n")
  31.     scoreperso["ext_gap"] = input("Score extension gap : \n")
  32.     return scoreperso
  33.  
  34. #scoredefaut = {"match" : 2, "transversion" : -1, "transition" : 1, "ouverture_gap" : -10 , "ext_gap" : -1}
  35.  
  36. def choix_nucleo():
  37.     choix = input("voulez vous faire votre propre matrice? tapez y pour oui  et n pour non\n")
  38.     while choix !="y" and choix !="n":
  39.         choix = input("voulez vous faire votre propre matrice? tapez y pour oui  et n pour non:\n")
  40.     if choix == "y":
  41.         dicoscore = faites_votre_score_Nucleo()
  42.     else:
  43.         dicoscore = {"match" : 2, "transversion" : -1, "transition" : 1, "ouverture_gap" : -10 , "ext_gap" : -1}
  44.     return dicoscore
  45.  
  46.  
  47. def choix_prot() :
  48.     matrixFile=open("blosum62.txt","r")
  49.     lines = matrixFile.readlines()
  50.     matrixFile.close()
  51.     dictaa = {}
  52.     aminoacidstring = lines[0]
  53.     aminoacidstring = aminoacidstring.split()
  54.     i = 1
  55.     while i <= (len(lines) - 1) :
  56.         row = lines[i]
  57.         row = row.split()
  58.  
  59.         j = 1
  60.         for character in row[1 :25] :
  61.             dictaa[aminoacidstring[i - 1], aminoacidstring[
  62.                 j - 1]] = character
  63.             j += 1
  64.         i += 1
  65.     choix=input("Voulez vous choisir vos score de gap ? y : OUI, n : NON\n")
  66.     while choix!="y" and choix!="n":
  67.         choix = input("Voulez vous choisir vos score de gap ? y : OUI, n : NON\n")
  68.     if choix=="y":
  69.         dictaa["Ouverture_gap"]=input("Score ouverture de gap:\n")
  70.         dictaa["ext_gap"]=input("Score d'extension de gap:\n")
  71.     else:
  72.         dictaa["Ouverture_gap"]=-10
  73.         dictaa["ext_gap"]=-1
  74.  
  75.     return (dictaa)
  76.  
  77.  
  78. def interface_user():
  79.     choix=input("1: Utiliser une matrice pour nucléotide\n2:Utiliser une matrice pour protéine\n")
  80.     while choix !=1 and choix !="2":
  81.         choix = input("1: Utiliser une matrice pour nucléotide\n2:Utiliser une matrice pour protéine\n")
  82.     if choix=="1":
  83.         choix_nucleo()
  84.     else:
  85.         choix_prot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement