Question: [15 marks] P2: A Compressed DNA Representation Provided files: none Files to submit: dna.py Marking: correctness 15 marks At a very high level, DNA is
![[15 marks] P2: A Compressed DNA Representation Provided files: none Files](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e258da184_76066f4e25834c7b.jpg)

[15 marks] P2: A Compressed DNA Representation Provided files: none Files to submit: dna.py Marking: correctness 15 marks At a very high level, DNA is made up of two strands of chained nucleobases which consist of either cytosine (C), guanine (G), adenine (A) or thymine (T). We can represent one strand as a string consisting of the letters C, G, A and T. The two strands are aligned and bonded to each other and the bonded nucleobases always match up A with T and C with G. So, if we know one strand, we also know the second strand. For example, if one strand is given by the sequence: ACTATGATCAT Then the corresponding second sequence is given by : TGATACTAGTA Write a function called pair that computes and returns the matching sequence (string) given a sequence as input. The signature and return type of the function are given by pair (strand : str) -> str For example, >>> pair ("ACTG") 'TGAC' For this function, you can assume that the input string only contains the letters a,t,c,g, A, T,C, or G. That is, the input string can have upper or lowercase versions of A, T, C and G. The output string must be all uppercase though. Since DNA strands can be very long. In order to reduce the size of the string stored, we can compress a sequence by replacing repeated letters with that letter and a count of how many times it is repeated. For example, AAA can be replaced by 3A, TTTTT by 5T and GG by 2G. When a letter is not repeated, we will leave it alone (and NOT introduce a 1). Write a function, called compress, that takes a DNA strand and compresses it using the description from above. The signature and return type are given by compress (strand : str) -> str Also write a function called expand that takes the compressed version of a strand and returns the uncompressed version of it. It's signature and return type are given by expand (compressedStrand : str) -> str W21 - COMP 1005 Due Friday, Feb 12th at 11:59PM For example, >>> compressed = compress ("CCCGTTTTAATTT") " 3CG4T2A3T' >>> expand ("BAT12GA") "AAATGGGGGGGGGGGGA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
