Tải bản đầy đủ (.pdf) (7 trang)

3642302920 pyth split 1 4537

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (175.19 KB, 7 trang )

Simpo PDF Merge and Split Unregistered Version -


Simpo PDF Merge and Split Unregistered Version -


Simpo PDF Merge and Split Unregistered Version -

Texts in Computational Science
and Engineering

Editors
Timothy J. Barth
Michael Griebel
David E. Keyes
Risto M. Nieminen
Dirk Roose
Tamar Schlick

6


Simpo PDF Merge and Split Unregistered Version -


Simpo PDF Merge and Split Unregistered Version -

Hans Petter Langtangen

A Primer on Scientific
Programming


with Python
Third Edition


Simpo PDF Merge and Split Unregistered Version -
6.8 Exercises

Exercise 6.31. Make a function more robust.
Consider the function get_base_counts(dna) (from Chapter 6.6.3),
which counts how many times A, C, G, and T appears in the string dna:
Unfortunately, this function crashes if other letters appear in dna.
Write an enhanced function get_base_counts2 which solves this problem. Test it on a string like ’ADLSTTLLD’. Name of program file:
get_base_counts2.py.
def get_base_counts(dna):
counts = {’A’: 0, ’T’: 0, ’G’: 0, ’C’: 0}
for base in dna:
counts[base] += 1
return counts

Exercise 6.32. Find proportion of bases inside/outside exons.
Consider the lactase gene as described in Chapters 6.6.4 and 6.6.5.
What is the proportion of base A inside and outside exons of the lactase gene? Write a function get_exons, which returns all the substrings
of the exon regions concatenated, and a function get_introns, which
returns all the substrings between the exon regions concatenated. The
function get_base_frequencies from Chapter 6.6.3 can then be used
to analyze the frequencies of bases A, C, G, and T in the two strings.
Name of program file: prop_A_exons.py.

339



Simpo PDF Merge and Split Unregistered Version -



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×