Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I have c programming homework you can see below,but i cant use fscanf !! only stdin stdout . Overview: In this project, you will

Hello I have c programming homework you can see below,but i cant use fscanf !! only stdin stdout . Overview: In this project, you will implement some basic functionality for manipulating DNA sequences. A DNA sequence is a list of characters chosen from some alphabet. DNA is composed of the four characters A, C, G, and T. Your program will maintain multiple DNA sequences. For that reason you will use a 2D array of characters, where each row is one DNA sequence. For example row 0 of the 2D array is one DNA sequence, row 1 is another one, etc. Lets call this the sequence array. For each sequence, you will be storing one letter of the sequence in an array location. The end of a DNA sequence will be denoted by the termination character (\0). You will initially create a large enough sequence array (e.g. say an array of 200 rows and 200 columns). You may assume we will not test with more than 200 sequences and no sequence will contain more than 199 chacters. Initially there are no DNA sequences storedi.e. the array is empty. However to denote an empty row, you should store # in the 0-th column of the row. Indices, both for the sequence array and for positions in a sequence start with 0. You are NOT allowed to use the string.h functions. You have to write your own functions. Your program will read from standard input, but as you did in Lab5, you will redirect input from an input file test-hw2.txt. The input file consists of a sequence of directives, each indicating an operation to be performed on the sequence array. There will be one directive per line. The last line of the file will contain the directive quit.Each directive consists of the name of the directive followed by 0 or more arguments, separated by spaces. You may assume that only the directives given below will appear in the file, and the specified arguments will always appear. However, you must check for possible invalid arguments, such as any attempts to index out-of-bounds in the sequence array or in a sequence. The output of the directives will be written to standard output. Here are the possible directives and their meanings. insert pos sequence Insert sequence to row pos in the sequence array. If there is already a sequence at pos then the new sequence replaces the old one at that position. It is possible that sequence be empty (contain no characters). In that case an empty sequence will be inserted at pos. Note that an empty sequence is different than having a row no sequence at all (#). remove pos Remove the sequence at row pos in the sequence array. Set the row to empty (#). If there is no sequence at pos, output a suitable message. display-all Print out all sequences in the sequence array. For each sequence, print its position (row index) within the sequence array and the characters in the sequence. display pos Print the the characters in the sequence at row pos in the sequence array. If there is no sequence in that position, print a suitable message. clip pos start end Replace the sequence at row pos with a clipped version of the sequence. The clipped version is that part of the sequence beginning at character at index start and ending with character at index end, inclusive. If start has a value less than zero, or if start or end are larger than the last index of the sequence, or if the value for end is less than the value for start, you should consider this an error, and make no change to the sequence. If there is no sequence at this slot, output a suitable message. copy pos1 pos2 Copy the sequence in row pos1 to pos2. If there is no sequence at row pos1, output a suitable message and do not modify the sequence at row pos2. If there is already a sequence at row pos2 then the new sequence replaces the old one at that row. swap pos1 start1 pos2 start2 Swap the tails of the sequences at rows pos1 and pos2. The tail for pos1 begins at character at index start1 and the tail for pos2 begins at character at index start2. It is an error if the value of the start position is greater than the length of the sequence or less than zero. If the length of a sequence is n, the start position may be n, meaning that the tail of the other sequence is appended (i.e., a tail of null length is being swapped). If one of the slots does not contain a sequence, it is an error. In either case, output a suitable message, and make no change to the sequences. max-overlap pos1 pos2 Determine the position of maximum overlap between the sequences at rows pos1 and pos2. The maximum overlap is the subsequence such that the maximum number of characters match in the two sequences, where the overlapping characters must be a suffix of the sequence at row pos1 and a prefix of the sequence at row pos2. Print out the length of the maximum overlap and the overlapping subsequence. If there is no such overlap, print a suitable message. For example, if sequence at row pos1: ACGTAGGCTATG and at row pos2: CTATGAAAGGG, then the maximum overlap is CTATG. If either slot does not contain a sequence, then print a suitable message and do not check for overlap. quit This directive will mean that the input has ended and your program will exit.

example of file to which the information is read===> file.txt : display-all clip 1 5 7 swap 2 4 6 0 insert 4 ACTGGCTACGTAAATTGACTTCGATCATGATTGCC display 3 display-all copy 1 4 copy 4 1 insert 2 ACTGCTGGATCTAGGCAATCTG swap 1 10 6 5 swap 6 0 1 10 copy 6 -1 max-overlap 4 5 insert 1 TTGCCAGTCAGTACGGGAAATACGATGCATGACATGATACGATAGCAT max-overlap 4 1 max-overlap 1 4 remove 1 remove 8 swap 2 22 4 24 display-all max-overlap 3 -1 insert 7 ACGTAGGTACGATCAGAGTGG clip 4 5 15 clip 4 -1 15 clip 4 5 15 display 7 display-all insert 1 AGCTAGCGATCGATCGATCGACGTGACTAGCTA remove 1 display 1 remove -2 display -1 insert 42 BKFKDGACGTGACGTGAFKLM insert -1 ACGTGACGTGA swap 2 10 1 5 quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions