Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import random
  2.  
  3. class Sequence:
  4. def generate(length, alphabet):
  5. AllSeq = []
  6. for j in range(length):
  7. number = random.randint(0,len(alphabet)-1)
  8. AllSeq.append(alphabet[number])
  9. return AllSeq
  10.  
  11. def Dictionary(Seq):
  12. SequenceOfNucleotides = []
  13. CountA = 0
  14. CountC = 0
  15. CountT = 0
  16. CountG = 0
  17. for j in range(len(Seq)):
  18. if(Seq[j] == 'A'):
  19. CountA = CountA + 1
  20. if(Seq[j] == 'C'):
  21. CountC = CountC + 1
  22. if(Seq[j] == 'T'):
  23. CountT = CountT + 1
  24. if(Seq[j] == 'G'):
  25. CountG = CountG + 1
  26. Dictionary = dict(A=0, C=0, T=0, G=0)
  27. Dictionary['A'] = CountA
  28. Dictionary['C'] = CountC
  29. Dictionary['T'] = CountT
  30. Dictionary['G'] = CountG
  31. SequenceOfNucleotides.append(Dictionary)
  32. return SequenceOfNucleotides
  33. #def getDictionary():
  34.  
  35.  
  36. #Рабочая область
  37. Lists = ['A','C','T','G']
  38. Length = int(input('Введите длину последовательности:'))
  39. Seq = Sequence.generate(Length,Lists)
  40. Dictionary = Sequence.Dictionary(Seq)
  41. print(Dictionary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement