QuBiEngine::QuBiEngine(ifstream& dnaFile)
{
int i = 0;
while(!dnaFile.eof()) //while the file isn't at its end
{
dna.push_back(""); //creates an element
if(!dnaFile.good())//checks for failbits and other errors
{
dna[i] = "Not a valid sequence";
i++;
continue;
}
getline(dnaFile, dna[i]);
//checks to see if the character is valid ie: a, t, c, g
for(int j=0; j<dna[i].length(); j++)
{
dna[i][j] = putchar(tolower(dna[i][j]));
if((dna[i][j]!='a')||(dna[i][j]!='t')||(dna[i][j]!='c')||(dna[i][j]!='g'))
{
dna[i] = "Not a valid sequence";
i++;
break;
}
}
i++;
}
}
これは dnaFile の各行を取得ifstream
し、テストに合格した場合はベクターに入れます。そうでない場合は、無効なものをベクターに入れます。