Question


Population of DNA. In previous weeks, we worked with DNA sequences. Oftentimes, geneticists nav to deal with not just one DNA
please use c program
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The source code is given below:

/************
dnaseq.c
*************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define COLS_MAX 80
#define ROWS_MAX 20
void setupRandDNAPop(int n,int m, char pop[][COLS_MAX]);/* function prototype */
void printPop(int n,int m, char pop[][COLS_MAX],char label[]);/* function prototype */
void printBlankOut(int n,int m, char pop[][COLS_MAX],char base,char label[]);/* function prototype */
void printBaseCounts(int n,int m, char pop[][COLS_MAX],char label[]);/* function prototype */
int main()
{ char pop[ROWS_MAX][COLS_MAX];/* pop 2 dimensional array declaration */
   char label[30],base;
   int n,m;
   printf("Enter total no.of DNA sequences required(should not be > %d):",ROWS_MAX);/* input of row size(total no od DNA seq) */
   scanf("%d",&n);
   if(n<=0 || n>ROWS_MAX) /* row size validation */
       {printf("Please Enter total no.of DNA sequences required(should not be > %d or <=0):",ROWS_MAX);
       exit(0);
       }  
   printf("Enter length of DNA sequence required(should not be > %d):",COLS_MAX);/* input of cols size( length of DNA seq) */
   scanf("%d",&m);
   if(m<=0 || m>COLS_MAX)/* col size validation */
       {printf("Please Enter total no.of DNA sequences required(should not be > %d or <=0):",COLS_MAX);
       exit(0);
       }  
   printf("Enter the label:");/* label entry */
   scanf("%s",label);
   setupRandDNAPop(n,m,pop); /* setupRandDNAPop() call */
   printPop(n,m,pop,label); /* printPop() call */
   printf("\nEnter the base:");/* base entry */
   scanf(" %c",&base);
   printBlankOut(n,m, pop,base,label);/* printBlankOut() call */
   printBaseCounts(n,m,pop,label);/* printBaseCounts() call */
   printf("\n");
   return 0;
}
void setupRandDNAPop(int n,int m, char pop[][COLS_MAX])/* setupRandDNAPop() definition */
{   int i,j;
   char ch;
   for(i=0;i<n;i++) /* population of 2d array*/
   {printf("\nEnter a DNA sequence of length %d:",m);
       for(j=0;j<m;j++)
       {   scanf(" %c",&ch);
           if(ch=='A'||ch=='G'||ch=='C'||ch=='T') /* validation of proper chars in DNA seq */
               pop[i][j]=ch;
           else{
               printf("Please enter chars only from \" A G C T \"");
               j--;
           }
       }
       pop[i][j]='\0';
   }

}
void printPop(int n,int m, char pop[][COLS_MAX],char label[])/* printPop() definition */
{ int i,len;
   printf("\nPopulation: %s",label);
   len=m+3-strlen(label)-12;
   for(i=0;i<len;i++)
       printf("-");
   for(i=0;i<n;i++)  
       printf("\n%d: %s",i,pop[i]);
}
void printBlankOut(int n,int m, char pop[][COLS_MAX],char base,char label[])/* printBlankOut() definition */
{   int i,j,len;
   printf("\nPopulation [%c]: %s",base,label);
   len=m+3-strlen(label)-16;
   for(i=0;i<len;i++)
       printf("-");
   for(i=0;i<n;i++)
   {   printf("\n%d: ",i);
       for(j=0;j<m;j++)
       {   if(pop[i][j]!=base)
               printf(".");
           else
               printf("%c",pop[i][j]);
       }  
   }  

}
void printBaseCounts(int n,int m, char pop[][COLS_MAX],char label[])/* printBaseCounts() definition */
{
   int i,j,len,nA,nG,nC,nT;
   printf("\nPopulation Stats: %s",label);
   len=(m+16)-strlen(label)-18;
   for(i=0;i<len;i++)
       printf("-");
   printf("\n");
   for(i=0;i<m+5;i++)
       printf(" ");
   printf(" A C G T");
   for(i=0;i<n;i++)
   {   printf("\n%d: ",i);
nA=nG=nC=nT=0;
       for(j=0;j<m;j++)
       {   if(pop[i][j]=='A')
               nA++;
           else if(pop[i][j]=='G')
               nG++;
           else if(pop[i][j]=='C')
               nC++;
           else if(pop[i][j]=='T')
               nT++;
           printf("%c",pop[i][j]);
       }
       printf(" %3d %3d %3d %3d",nA,nC,nG,nT);  
   }  
}

The source code screen shots are also given below for indentation reference:

************ dnaseq.c ************* #include<stdio.h> #include<stdlib.h> #include<string.h> #define COLS_MAX 80 #define ROWS_printBaseCounts(n,m, pop, label);/* printBaseCounts() call */ printf(\n); return; void setupRandDNAPop(int n, int n, char pvoid printBlankout(int n, int m, char pop[][COLS_MAX], char base, char label[])/* printBlankout() definition */ int i, j, lenelse if(pop[i][j]==C) nC++; else if(pop[i][j]==T) printf(%c, pop[i][j]); nT++: print printf(%3d %3d %3d %3d, na, nc,

The output screen shot is also given below:

(base) student@L6-C078:-$ gcc dnaseq.c (base) student@L6-C078:-$ ./a.out Enter total no.of DNA sequences required(should not

The above output is taken on ubuntu/linux system.

Add a comment
Know the answer?
Add Answer to:
please use c program Population of DNA. In previous weeks, we worked with DNA sequences. Oftentimes,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please Complete the following C Code with Comments explaining your solution and post a screenshot of...

    Please Complete the following C Code with Comments explaining your solution and post a screenshot of it working. Summary: This project explores pattern matching techniques to find a pattern in a DNA sequence containing letters in the DNA alphabet {A, C, G, T}. For example, suppose we have a DNA sequence as follows: ATGACGATCTACGTATGGCAGCCACGCTTTTGATGTTAAGTCACACAGCCAAGTCA ACAAGGGCGACTTCATGATCTTTCCGCTCCGTTGGTGTAGGCCCGTGTTCAAATTC AATGGCTGATTGGAATTACCTTTGAAATACTCCAACCGACCGCCACGGCCAGGGT CCCGCTCGCTCTCTGTGGCCCTCCCACAAAACTCCGGTGAAAGTTGATTTGGACAC GGACCCAAAGCAGCGTAGATTATTCGAGCGTATTCGGTAGTCATTGAGGCCCCAA The pattern “AATGG” can be found at the beginning of the third line. Note that overlapping matches are counted individually. For example,...

  • Please use C++ Suppose we have the following book base class: class book { public: book(char*,...

    Please use C++ Suppose we have the following book base class: class book { public: book(char*, char *, int); void show_book(); private: char title[64]; char author[64]; int pages; }; Suppose that we need to derive a new class, called libraryCard class, which adds the following members to the book class: char catalog[64]; int checked_out; // 1 if checked out, otherwise 0 if available libraryCard(char*, char *, int, char *, int); void show_card(); 1. Derive the new class from the base...

  • Writing a program in C please help!! My file worked fine before but when I put...

    Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...

  • Please do in C please. Edit sliding.c. Comments on code would be nice. Thank you. Here is main.c #include "sliding.h" #include <malloc.h> #include <stdlib.h> //Prints grid in row...

    Please do in C please. Edit sliding.c. Comments on code would be nice. Thank you. Here is main.c #include "sliding.h" #include <malloc.h> #include <stdlib.h> //Prints grid in row major order. Tries to ensure even spacing. void print_grid(int * my_array, int rows, int cols){ int i,j; for(i=0; i<rows; i++){ for(j=0; j<cols; j++){ if(my_array[i*cols + j]!=-1){ printf(" %d ", my_array[i*cols + j]); } else{ printf("%d ", my_array[i*cols + j]); } } printf("\n"); } } int main(int argc, char *argv[]) { int seed,rows,cols;...

  • c program Here we see a Stack ADT implemented using array. We would like the stack...

    c program Here we see a Stack ADT implemented using array. We would like the stack to be usable for different max sizes though, so we need to use dynamic memory allocation for our array as well. #include <stdio.h> #include <stdlib.h> typedef struct { int *data;   // stack data, we assume integer for simplicity int top;     // top of the stack int maxSize; // max size of the stack } Stack; void StackInit(Stack* stack, int size) {     // this...

  • C programming Let's try to use the template below to implement a Set with double hashing....

    C programming Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set. Let's reuse the exact hash functions we have seen in example in Part 7 of the lecture notes, page 3. As...

  • C PROGRAM When you print out the old and new bitsets, which are of type unsigned...

    C PROGRAM When you print out the old and new bitsets, which are of type unsigned char, please use the %p control character in the printff statement rather than %x or %d or %c. The compiler will complain, but we don't always listen to them anyway. The difference is it will print the bitset out in hex with a preceeding %0x. unsigned char bitset = 0x14 ; printf("Bitsrt is %p\n", bitset) ; results in Bitset is 0x14, which is what...

  • Please convert this C function into ARM ASSEMBLY LANGUAGE CORTEX M (Must be cortex m) #include<...

    Please convert this C function into ARM ASSEMBLY LANGUAGE CORTEX M (Must be cortex m) #include<stdio.h> int ascii(char c) {                 return (int)c; } int computeMagicNumber(char* name) {                 int sum, i; //varibales                 sum = 0; //set sum to 0                 //calculate sum                 int N = sizeof(name)/sizeof(name[0]); //get name size                 for(i=0;i<N;i++)                                 sum = sum + (i+1)*ascii(name[i]);                                 return sum%1001; //return magic number MAIN FUNCTION : extern int computeMagicNumber(char *); int main(void) { char name[255]="Yusuf Ozturk"; int magic; magic=computeMagicNumber(name); printf("\n Magic number is %d\n",magic); return...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • program in C - Starter code below //In this assignment, we practice call by reference. //Below...

    program in C - Starter code below //In this assignment, we practice call by reference. //Below description of call by reference is from the following link //https://www.tutorialspoint.com/cprogramming/c_function_call_by_reference.htm //The call by reference method of passing arguments to a function copies //the address of an argument into the formal parameter. Inside the function, //the address is used to access the actual argument used in the call. //It means the changes made to the parameter affect the passed argument. //We use an example...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT