fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <map>
  7. #include <boost/algorithm/string/classification.hpp>
  8. #include <boost/algorithm/string/split.hpp>
  9.  
  10. using namespace std;
  11.  
  12. int main(int argc, char * argv[]){
  13.  
  14. ifstream readR1file(argv[1]);
  15. ifstream readR2file(argv[2]);
  16.  
  17. typedef map<string, string> mapType;
  18. mapType R1_SEQ_MAP;
  19. mapType R2_SEQ_MAP;
  20.  
  21. string str="", key="", tmp_value="", value="";
  22. int r1_line_cnt = 0;
  23. while(getline(readR1file, str, '\n'))
  24. {
  25. if(r1_line_cnt<40000){
  26. r1_line_cnt++;
  27. vector<string> id_str;
  28. if(r1_line_cnt%4==1){
  29. value = "";
  30. boost::split(id_str,str,boost::is_any_of("/"));
  31. key = id_str[0];
  32. }else{
  33. tmp_value = "";
  34. tmp_value = str + "\n";
  35. value += tmp_value;
  36. }
  37. if(r1_line_cnt%4==0){
  38. R1_SEQ_MAP.insert(map<string, string>::value_type (key, value));
  39. }
  40. }
  41. }
  42. readR1file.close();
  43.  
  44. str="", key="", tmp_value="", value="";
  45. int r2_line_cnt = 0;
  46. while(getline(readR2file, str, '\n'))
  47. {
  48. r2_line_cnt++;
  49. vector<string> id_str;
  50. if(r2_line_cnt%4==1){
  51. value = "";
  52. boost::split(id_str,str,boost::is_any_of("/"));
  53. key = id_str[0];
  54. }else{
  55. tmp_value = "";
  56. tmp_value = str + "\n";
  57. value += tmp_value;
  58. }
  59. if(r2_line_cnt%4==0){
  60. R2_SEQ_MAP.insert(map<string, string>::value_type (key, value));
  61. }
  62. }
  63. readR2file.close();
  64.  
  65. ofstream writeR1file(argv[3]);
  66. ofstream writeR2file(argv[4]);
  67.  
  68. //find
  69. map<string,string>::iterator iter = R1_SEQ_MAP.begin();
  70. for (iter=R1_SEQ_MAP.begin(); iter!=R1_SEQ_MAP.end(); ++iter){
  71. string find_key = iter->first;
  72. string r1_key = find_key + "/1";
  73. string r2_key = find_key + "/2";
  74. if(R2_SEQ_MAP.find(find_key) == R2_SEQ_MAP.end()){
  75. // not found
  76. }else{
  77. // found
  78. writeR1file << r1_key << "\n" << iter->second;
  79. writeR2file << r2_key << "\n" << R2_SEQ_MAP.find(find_key)->second;
  80. }
  81. }
  82. writeR2file.close();
  83. writeR2file.close();
  84.  
  85. R1_SEQ_MAP.clear();
  86. R2_SEQ_MAP.clear();
  87. /*
  88. map<string,string>::iterator it = R2_SEQ_MAP.begin();
  89. for (it=R2_SEQ_MAP.begin(); it!=R2_SEQ_MAP.end(); ++it)
  90. cout << it->first << " => " << it->second << '\n';
  91. */
  92. return 0;
  93. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:53: fatal error: boost/algorithm/string/classification.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty