-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfqparse.cpp
41 lines (39 loc) · 1.05 KB
/
fqparse.cpp
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 <set>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
// written by Pierre Lindenbaum (https://www.biostars.org/p/10353/)
int main(int argc,char **argv)
{
string line;
set<string> names;
/* reads your names */
ifstream in(argv[1],ios::in);
if(!in.is_open()) return EXIT_FAILURE;
while(getline(in,line,'\n'))
{
names.insert(line);
}
in.close();
/* reads the fastq */
string name;
string seq;
string name2;
string qual;
set<string>::iterator r;
/* assuming 4 lines / read */
while(!names.empty())
{
if(!getline(cin,name,'\n')) break;
if(!getline(cin,seq,'\n')) break;
if(!getline(cin,name2,'\n')) break;
if(!getline(cin,qual,'\n')) break;
r=names.find(name);
if(r==names.end()) continue;
names.erase(r);//names are unique we don't need this one anymore
cout << name << "\n" << seq << "\n" << name2 << "\n" << qual << endl;
}
return 0;
}