Functions and Recursions – Strings – Problem #8
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
A genetic sequence is a string formed from a four-letter alphabet {Adenine (A), Thymine (T), Guanine (G), Cytosine (C)} of biological macromolecules referred to together as the DNA bases. A gene is a genetic sequence that contains the information needed to construct a protein. Following are some examples of parts of gene structures: ATTGCATGGACCTGCGAATCTGAGGCTA GGTCCAAGAGATTAACTGTGCAAAC CTAGGCTGCAAGTCACAATCGTGTGTAACAAGGT Dr. Xu is performing some study with the genes of Sars Covid19 virus and some of its variants. In the study, he needs to find the similarity between two genes coming from two different Covid variants by means of a "similarity score". The goal is that, if the two genetic sequences are similar enough, we might expect them to have similar functions. Dr. Xu wants to measure the similarity of two genetic sequences by the following procedure. The two sequences will be aligned, and we will pay a penalty for each mismatch between two corresponding characters. However if the two sequences do not have the same length, then "gaps" (represented by '-') will be inserted to the shorter sequence to make the two sequences have the same length. For simplicity, we consider maximum 2 gaps in the sequences (that means, the length of the two sequences will differ by maximum 2 characters). There can be many possibilities of inserting the gap(s) in a sequence. Our goal is to find the gap positions for which the "similarity score" is the minimum. The following rules are followed for the penalty and cost: Penalty Cost ------- ---- Per gap 2 Per mismatch 1 Per match 0 For example, consider the following two sequences: AACAGTTACC and TAAGGTCA. Two possible alignments can be: Example 1 Sequence1 AACAGTTACC Sequence2 TAAGGTCA - - Penalty 10 1 1 0 0 1 0 2 2 Similarity score = 8 Example 2 Sequence1 AACAGTTACC Sequence2 TA - AGGT- CA Penalty 10 2 0 0 10 2 01 Similarity score = 7 There can be many other combinations of inserting gaps. Your task is to write a C program which takes the two sequences as two strings from the user as input. If the sequences have different lengths, then find the alignment of the two sequences for which the Similarity score is minimum. If the sequences have same length, then simply find the similarity score by the above mentioned rules. Your output should display the aligned sequences (along with the gaps represented by '- '), as well as the similarity score. You are not allowed to use/call any String.h library functions. Feel free to write your own functions and invoke them. (May use ASCII code etc to identify the special characters)