Facebook
From Agata, 4 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 73
  1. def complement(dna):
  2.     dna2= ""
  3.     for letter in dna:
  4.         if(letter == 'A'):
  5.             dna2 += 'T'
  6.         elif(letter == 'C'):
  7.             dna2 += 'G'
  8.         elif(letter == 'T'):
  9.             dna2 += 'A'
  10.         elif(letter == 'G'):
  11.             dna2 += 'C'
  12.     return dna2
  13.  
  14. def reverse_complement(dna):
  15.     dna2 = complement(dna)
  16.     x = dna2[::-1]
  17.     return x
  18.  
  19. sites = []
  20.  
  21. def restriction_sites(dna):
  22.    
  23.     dna3 = reverse_complement(dna)
  24.     for i in range(4,12,2):
  25.         for x in dna3:
  26.             if(dna[x:x+1] == dna3[x:x+1]):
  27.                 sites.append((dna[x+1], dna[x+i], dna[x:x+i]))
  28.  
  29. dna = 'TCAATGCATGCGGGTCTATATGCAT'
  30.  
  31. print(dna)
  32. print(complement(dna))
  33. print(reverse_complement(dna))
  34. print(restriction_sites(dna))

Replies to sjp - python obiektowo rss

Title Name Language When
Re: sjp - python obiektowo Agata python 4 Months ago.