if (fin0)
{
do
{
getline(fin0, w);
cout << w<<endl;
i=0;
ind = "";
popname = "";
do {c = w [i];
i++;
if ((c != '>')&(c!='-')) ind=ind+c; } while (c != '-');
do {c = w [i];
i++; } while (c != ' ');
do {c = w [i];
i++;
if (c!= '\n') popname=popname+c; } while (i< w.length());
if (popname != lastpop) { totalpops++;
lastpop=popname;
}
getline (fin0, w);
cout << w<<endl << w.length()<<endl;
for (i=0; i<w.length(); i++)
{if (w[i]=='A') dna[totalpops][0][i]++;
if (w[i]=='C') dna[totalpops][1][i]++;
if (w[i]=='G') dna[totalpops][2][i]++;
if (w[i]=='T') dna[totalpops][3][i]++;
}
for(int k=0;k<1;k++)
{for(int j=0; j<1;j++)
{for (int i=0;i<1;i++)
Af[0] = Af[0][0][0]+dna[i][j][k]; //RETURNS THE ERROR "INCOMPATIBLE TYPES IN ASSIGNMENT OF 'FLOAT' TO 'FLOAT[1][1]'
cout<<Af<<endl;}
}
while (!fin0.eof());
}
system("PAUSE");
return EXIT_SUCCESS;
}
Background: I am very new to C++ and trying to teach myself to use it to supplement my graduate research. I am genetics PhD candidate trying to model different evolutionary histories, and how they affect the frequency of alleles across populations.
Question: I am trying to extract certain portions of data from the "dna" array that I created from the input file. For example, here I have created another array "Af" where I am trying to extract counts for the first "cell," so to speak, of the dna array. The purpose of doing this, is so that I can calculate a frequency by comparing the counts in certain groups of cells to the entire dna array. I can't figure out how to do this. I keep getting the error message: "INCOMPATIBLE TYPES IN ASSIGNMENT OF 'FLOAT' TO 'FLOAT[1][1]'"
I have spent a great deal of time researching this on different forums, but I cannot seem to understand what this error means, and how else to achieve what I'm trying to achieve.
So the dna array I'm visualizing is a made from the input file such that there are 4 rows (A,C,G,T). and then 10 columns (one column for each nucleotide in the series). This "grid" is then stacked 3 times (one "sheet" for each Sample (here sample means population, and there are three individuals per population) as listed on the input file). So from this stack of grids I want to extract, for example, the first cell (the number of A's in Sample 1 at position 1. I would then want to compare this number to the total number of A's at position 1 across all samples. This frequency would then be a meaningful number for the model I'm testing. The problem is, I don't know how to extract portions of the dna array - once I figure out this condensed example, I will be applying it to very large input files, and will want to extract more than one cell at a time. Please help, I've been pouring over my teach yourself C++ books and looking through forums online, but I cannot make sense of this problem. Thanks!