0 down vote favorite
I am trying to read from the file where 3 columns are present; Turn, R1[integer value] and R2[integer value]. I am supposed to create a file for each "turn" I encounter with the name as that of the turn [e.g. for TurnII, it creates Turn2.txt]and then read the second and third column entry for the corresponding turn and then look for all the values between the second and third column, inclusive, from a different file and do some operations on that file.
The problem is that my code reads the turn, but I am not able to read the next character i.e the first character of the second column. I tried to do every possible thing even removed loops and goto statements and wrote a big code. But I don' understand where the fstream object points after reading T,U,R,N and the index value e.g. I or I,I.
This is the link to the file I am trying to read.
http://goo.gl/EIfFrQ
I am giving you the function which does this task.
void Tempread()
{
char c2[10];
int qw;
int i;
double ret;
fstream f("temp.txt",ios::in);
while(!f.eof())
{
f>>c2[0];
if(c2[0]=='T')
{
f>>c2[1];
if(c2[1]=='u')
{
f>>c2[2];
if(c2[2]=='r')
{
f>>c2[3];
if(c2[3]=='n')
{
f>>c2[4];
if (c2[4]=='I'||c2[4]=='V')
{
f>>c2[5];
if (c2[5]=='I'||c2[5]=='\''||c2[5]=='V')
{
f>>c2[6];
if (c2[6]=='I'||c2[6]=='a'||c2[6]=='b'||c2[6]=='\'')
{
f>>c2[7];
if (c2[7]=='I') //VIII
{
fstream f1("Turn8.txt",ios::app|ios::out);
//residue1(f,f1);
f1.close();
}
else
{ //f.seekg(-1,ios::cur);
if (c2[6]=='\'') //II'
{ fstream f1("Turn2'.txt",ios::app|ios::out);
f1.close();
}
else if (c2[6]=='b') //VIb,
{ fstream f1("Turn6b.txt",ios::app|ios::out);
f1.close();
}
else if (c2[6]=='a') //VIa
{ fstream f1("Turn6a.txt",ios::app|ios::out);
f1.close();
}
}
}
else // II/I'/IV
{
f.seekg(-2,ios::cur);
if (c2[5]=='I') //II
{
qw=0;
while(qw!=2) //Seraches for range of residue
{
getline(f,str[qw],'\t');
value[qw] = atoi(str[qw].c_str());
qw++;
}
cout<<str[0]<<'\t'<<str[1];
}
else if (c2[5]=='\'') //I'
{ fstream f1("Turn1'.txt",ios::app|ios::out);
f1.close();
}
else if (c2[5]=='V') //IV
{
qw=0;
while(qw!=2) //Seraches for range of residue
{
getline(f,str[qw],'\t');
value[qw] = atoi(str[qw].c_str());
qw++;
}
fstream f1("Turn4_Phi.txt",ios::app|ios::out);
}
}
}
else //I
{
f.seekg(-3,ios::cur);
qw=0;
while(qw!=2) //Seraches for range of residue
{
getline(f,str[qw],'\t');
value[qw] = atoi(str[qw].c_str());
qw++;
}
}
}
}
}
}
}
}
f.close();
}