mlmisha

6_mers

Dec 18th, 2021 (edited)
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. print("Введите бактерию")
  2. bacterion = input()
  3. seq = whole_seq(f"{bacterion}_fasta")
  4. ORF_start = []
  5. minus = []
  6. pseudo_check = []
  7. with open(f"{bacterion}_gb", mode = "r") as data:
  8.   line = data.readline()
  9.   while line!="":
  10.     while not line.startswith("     gene") and line != "":
  11.       line = data.readline()
  12.     if line!= "":
  13.       pseudo = line
  14.       pseudo_check.append(pseudo)
  15.       pseudo = data.readline()
  16.       while pseudo.startswith("       "):
  17.         pseudo_check.append(pseudo)
  18.         pseudo = data.readline()
  19.       if pseudo_check != []:  
  20.         pseudo_check = "".join(pseudo_check)
  21.       if pseudo_check.find("pseudo") < 0:
  22.         line = line.split()
  23.         if line[1].find("join") < 0:
  24.           if line[1].startswith("complement"):
  25.             ORF_start.append(int(line[1][11:].split("..")[0]))
  26.           else:
  27.             ORF_start.append(int(line[1].split("..")[0]))
  28.     line = data.readline()
  29.     pseudo_check = []
  30. Six_mer = {}
  31. Mers = []
  32. index = 0
  33. for i in ORF_start:
  34.   minus.append(seq[i-21:i-1]) # на этом этапе имеем список всех нужных участков длиной 20 п.н.
  35.   for j in range(0,14,1):
  36.     if minus[index][j:j+6] in Six_mer:
  37.       Six_mer[minus[index][j:j+6]] +=1
  38.     else:
  39.       Six_mer[minus[index][j:j+6]] = 1
  40.       Mers.append(minus[index][j:j+6])
  41.   index += 1
  42. Mers.sort()
  43. with open(f"Six_mer_{bacterion}.txt",mode = "w") as result:
  44.   for i in Mers:
  45.     print (f"{i}\t{Six_mer[i]}", file=result)
Add Comment
Please, Sign In to add comment