a

aaa
Last edited on
what do you have so far?

or do you expect someone to write it for you?
Just give us a little code, have you started yet?
I would love to help, but I'm not too experienced with c++. How can I start?
HI. I can help you. Working in a genome institute now. HOw to contact you?
Hi
My Email address is hjh331@gmail.com
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 ??
My contact Adress is hjh331@gmail.com

Thank you :)
May I know how your file looks like?
I mean the geneanalysis.txt
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
Not really sure why you'd choose C++ specifically for this one. Really Java or anything would've done...
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
Any suggest guys..

Sorry lwtan90 the program does not work

Last edited on
Can you print out the errors? Or the output is wrong?
getline() on line 17 has the arguments in the wrong order.

What for the case when A and G are equal?
Topic archived. No new replies allowed.