I am trying to edit a fastq file, which is simply a text file to store DNA or RNA reads.
In the file, I am simply editing the '@' to 'A', 'B' to 'C', etc as shown in the code, and i am writing the changed sequence to the new file.
But, in the new file, some non printable characters like '^F' , '^B', etc are being introduced instead of the newline character. This was only done at a few places and not in all places, that's why I am not sure why this is happening.
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
int main()
{
ifstream in;
ofstream out;
in.open("file1.fq");
out.open("newfile1.fq",ios::out|ios::app|ios::ate);
while(!in.eof())
{
string head,plus,seq,qs;
in>>head>>seq>>plus>>qs;
if(head[0]!='@')
continue;
out<<head<<endl;
for(int i=0;i<seq.size();i++)
{
if(seq[i]=='@')
seq[i] = 'A';
else if(seq[i]=='B')
seq[i] = 'C';
else if(seq[i] =='F')
seq[i] = 'G';
else if(seq[i]=='S')
seq[i] = 'T';
}
out<<seq<<endl;
out<<"+"<<endl;
out<<qs<<endl;
}
in.close();
out.close();
}
In between, some non printable characters are introduced in the new file like '^B' , '^F', etc, which are not present in the input file.