
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Fan; Class: Introduction to Computing Using MATLAB; Subject: Computer Science; University: Cornell University; Term: Fall 2008;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

CS100M Section Exercise 9
In the DNA double helix, two strands twist together and “face” each other. The two strands are reverse- complementary, i.e., reading one strand in reverse order and exchanging each base with its complement gives the other strand. A and T are complementary; C and G are complementary.
For example, given the DNA sequence
AGTAGCAT
the reverse sequence is
TACGATGA
so the reverse complement is
ATGCTACT
Write a function rComplement(dna) to return the reverse complement of a DNA strand. Use a loop to reverse the strand—do not use vectorized code. Assume that dna contains only the letters ’A’, ’T’, ’C’, and ’G’.
Write a function countPattern(dna,p) to find out (and return) how many times a pattern p occurs in dna. Assume both parameters to be strings that contain the letters ’A’, ’T’, ’C’, and ’G’ only. Note that if p is longer than dna, then p appears in dna zero times. Use the built-in function strcmp to compare two strings. Again, use a loop to solve this problem
Rewrite the function countPattern(dna,p) without using the strcmp function.