Question: Hello., I got this assignmentI wrote some code but I dont know how to write the rest, I added my code at the end, If
Hello.,
I got this assignmentI wrote some code but I dont know how to write the rest, I added my code at the end, If I could get some help to finish the code it would be great
thank you
The Assignment is to build a simple analysis program that will compute basic statistics for a list of DNA strings. the program should work as follows: -The program will accept as a command line argument the name of a text file that will contain an arbitrary list of DNA strings. (ie. ~/assign1/filename.txt) DNA strings consist of a sequence of nucleotides (A,C,T, or G). There will be 1 string per line of the file. No guarantees on capitalization. -The program will then compute the sum, mean, variance, and standard deviation of the length of the DNA strings in the list. It will also compute the relative probability of each nucleotide (A,C,T, or G), as well as the probability of each nucleotide bigram (AA, AC, AT, AG, CA, CC, CT, CG, etc) across the entire collection. -The program will output the labeled results to a file called yourname.out. At the top of the file, output your name, student id, etc. -After printing the summary statistics to yourname.out, you will generate 1000 DNA strings whose lengths follow a Gaussian distribution with the same mean and variance as calculated above. The relative frequency of nucleotides will also follow the statistics calculated above. Append the 1000 strings to the end of yourname.out. -The program will then ask the user if they want to process another list. -If not, the program will exit. If so, the program will prompt for the name of the next file, process it, and append the results to the output file. Hints To generate the length of a string from a Gaussian distribution with mean and variance 2 , you can use the rand() function (normalized see RAND_MAX) to generate 2 random numbers, a and b, uniformly distributed in [0,1). Using the Box-Muller transform it is then possible to compute a random variable C, such that: C = sqrt(-2 ln (a)) * cos(2b) Here C is a standard Gaussian with mean 0 and variance 1. You can then convert to a normal random variable D with mean and variance 2 as follows: D = C + Note that here we use the standard deviation, , which as you know from basic statistics is simply the square root of variance. The Rules - You may NOT use any non-primitive data structures to do the math. (No arrays, Vectors, Lists, etc) Just use individual primitive variables (int, double, etc) and std strings.
my code:
#include
#include
#include
#include
#include
using namespace std ;
int main()
{
ifstream myfile;
myfile.open("mydna.txt");
string line;
int count = 0;
while(myfile.is_good())
{
//read each line of the file
getline(myfile, line);
count << txt << endl;
count++;
}
myfile << "This is DNA test";
myfile.close();
int sum, avg, variance, standard_deviation ;
int a, b, i;
bool true = 'YES', false = 'NO';
char ch= {'A ', 'C', 'T', 'G'};
cout << "The DNA nucleotides is A,C,Tor G" << endl;
srand(time(NULL));
int random_ch = rand();
cout << random_number ;
coun << i << end;
return 0;
}
int sumArray()
{
int sum=0;
int i;
int count=0;
for(int i=0; i<=size ; i++)
{
sum += i;
count++;
}
return sum;
}
avg = sum /coun;
{
int variance=0;
int i;
for(int i = 0; i < size; i++)
{
variance += pow((i - avg),2);
variance /= count;
count++;
}
return variance;
}
double standardDeviation()
{
return sqrt(variance(arr, n));
}
//output
cout << "The sum is " << sum << endl;
cout << "The average is " << avg << endl;
cout << "The variance is "<< variance << endl;
cout << "The Standard Deviation is: " << standardDeviation(array, size) << endl;
cout << "Do you want to process another list ?" << endl;
cin >> command;
switch (command) {
case 'NO': /* value */:
break;
case 'YES':
delete Array[i]; //deallocate storage
}
return 0;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
