Differences between revisions 1 and 2
Revision 1 as of 2019-10-11 10:59:45
Size: 698
Comment:
Revision 2 as of 2019-10-11 11:02:08
Size: 722
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
<<Anchor(11_10_2019)>>

Przykłady omawiane na konwersatoriach

Funkcja wyznaczająca zawartość GC w sekwencjach DNA

   1 dna1 = 'acgtttaaactt'
   2 dna2 = 'ACgggttAAAAAgggT'
   3 dna3 = 'pppsasda ala ma kota'
   4 
   5 # count c and g in DNA seqs
   6 # input: dna seqs
   7 # output: % content of c+g
   8 # algorithm: 
   9 #  1. number of occs of C
  10 #  2. number of occs of G
  11 #  3. len of a dna seq
  12 #  4. calculations: (#1 + #2)/#3 * 100
  13 
  14 def getGC( sequence ):
  15     seq = sequence.lower()
  16     ileC = seq.count('c')
  17     ileG = seq.count('g')
  18     n = len(seq)
  19     return (ileC+ileG)/n * 100
  20 
  21 wynik = getGC(dna1)        
  22 print('Zawartość C i G w sekwencji %s wynosi: %.2f' % (dna1, wynik))

BioInfoCourses: CodeInPython/Snippets (last edited 2019-10-11 11:02:08 by KrzysztofMurzyn)