Jun 18, 2012 at 10:44pm UTC
aaa
Last edited on Jun 22, 2012 at 5:01pm UTC
Jun 18, 2012 at 10:51pm UTC
what do you have so far?
or do you expect someone to write it for you?
Jun 18, 2012 at 10:55pm UTC
Just give us a little code, have you started yet?
Jun 19, 2012 at 12:20am UTC
I would love to help, but I'm not too experienced with c++. How can I start?
Jun 19, 2012 at 2:09am UTC
HI. I can help you. Working in a genome institute now. HOw to contact you?
Jun 19, 2012 at 5:53am UTC
Hi
My Email address is hjh331@gmail.com
Jun 19, 2012 at 5:57am UTC
Hi
This is what I have so far:
#include<iostream>
#include<fstream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
ifstream infile;
infile.open("gene.txt");
ofstream outfile;
outfile.open("geneanalysis.txt", ios::app);
string line,mature_state,mature,evolving,A,G,T;
while ( !infile.eof())
{
getline(infile, line);
if (A>G)
{
mature_state=mature;
}
else
{
mature_state=evolving;
}
cout<<line<<endl;
outfile<<line<<"\n";
}
infile.close();
outfile.close();
return 0;
}
However, I am getting a problem with excuting the program because it shows me nothing, only black screen with no text. I think the problem goes with if (A>G), but how to fix it ??
Jun 19, 2012 at 5:58am UTC
My contact Adress is hjh331@gmail.com
Thank you :)
Jun 19, 2012 at 6:48am UTC
May I know how your file looks like?
I mean the geneanalysis.txt
Jun 19, 2012 at 7:01am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;
void read_data()
{
ifstream seq("gene.txt" );
ofstream output("geneanalysis.txt" );
if (seq.is_open()){
while (!seq.eof()){
string input;
int A=0, G=0;
getline(input,seq);
for (int i=0; i<input.length(); i++)
{
if (seq[i] == 'A' ) A++;
if (seq[i] == 'G' ) G++;
}
if (A>G) {
output<<seq<<endl;
output<<"Gene is mature." <<endl;
output<<endl;
}else {
output<<seq<<endl;
output<<"Gene is evolving." <<endl;
output<<endl;
}
}
}
}
int main()
{
read_data();
return 1;
}
Last edited on Jun 19, 2012 at 7:02am UTC
Jun 19, 2012 at 12:48pm UTC
Not really sure why you'd choose C++ specifically for this one. Really Java or anything would've done...
Jun 19, 2012 at 5:34pm UTC
Hi guys
I am not really sure that the professor want me to use the (seq) because it still a beginner class. However the file that I should read from should have the following code:
ATGGAAATGAATGATTTAAGAA
ATGATGATAATGGGTAGGTTAGTTA
GTGATGATGAGTGTATGATGGGAATTGG
ATGATGATGAGTATGATG
It is a text file and the result should looks like this:
Gene sequence Analysis Report
Gene: ATGGAAATGAATGATTTAAGAA
Number of A’s: 10
Number of G’s: 5
Maturity Level: mature
and it should print this to a new file called geneanlysis.txt
Thanks Guys
Last edited on Jun 19, 2012 at 5:35pm UTC
Jun 20, 2012 at 1:21am UTC
Any suggest guys..
Sorry lwtan90 the program does not work
Last edited on Jun 20, 2012 at 5:36am UTC
Jun 20, 2012 at 8:28am UTC
Can you print out the errors? Or the output is wrong?
Jun 20, 2012 at 12:56pm UTC
getline() on line 17 has the arguments in the wrong order.
What for the case when A and G are equal?