update fixing bug
This commit is contained in:
parent
5be58df294
commit
e2d486cfd1
22
src/main.cpp
22
src/main.cpp
@ -1,3 +1,4 @@
|
|||||||
|
#include <array>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include<fstream>
|
#include<fstream>
|
||||||
@ -10,11 +11,13 @@
|
|||||||
|
|
||||||
// std::string reversedComplement(std::string DNAsequence);
|
// std::string reversedComplement(std::string DNAsequence);
|
||||||
|
|
||||||
#define OPEN_IFS_AND_CHECK(file_path,value_name)std::ifstream value_name(file_path);if(value_name.is_open()==false){std::stringstream ss;ss<<"cannot open input file stream : "<<file_path.filename();throw std::runtime_error(ss.str());}
|
#define OPEN_IFS_AND_CHECK(file_path,value_name)std::ifstream value_name(file_path);if(value_name.is_open()==false){std::stringstream ss;ss<<"cannot open input file stream : "<<file_path.filename();throw std::runtime_error(ss.str());}else{zt::print("Open input file stream to value ["#value_name"] ok , from [",file_path.filename(),"]\n");}
|
||||||
|
|
||||||
#define OPEN_OFS_AND_CHECK(file_path,value_name)std::ofstream value_name(file_path);if(value_name.is_open()==false){std::stringstream ss;ss<<"cannot open output file stream : "<<file_path.filename();throw std::runtime_error(ss.str());}
|
#define OPEN_OFS_AND_CHECK(file_path,value_name)std::ofstream value_name(file_path);if(value_name.is_open()==false){std::stringstream ss;ss<<"cannot open output file stream : "<<file_path.filename();throw std::runtime_error(ss.str());}else{zt::print("Open output file stream to value ["#value_name"] ok , from [",file_path.filename(),"]\n");}
|
||||||
|
|
||||||
std::string reverseComplement(std::string DNAsequence)
|
const size_t MAX_SIZE = 5e4+5;
|
||||||
|
|
||||||
|
std::string reverseComplement(std::array<char, MAX_SIZE> DNAsequence)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -50,7 +53,7 @@ int main()
|
|||||||
// std::ios_base::sync_with_stdio(false); //加了没效果
|
// std::ios_base::sync_with_stdio(false); //加了没效果
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
char buf[50000];
|
std::array<char,MAX_SIZE> buf;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
|
|
||||||
filesystem::path input_path("filteredReads.txt"),output_path("reversedSequence.txt");
|
filesystem::path input_path("filteredReads.txt"),output_path("reversedSequence.txt");
|
||||||
@ -60,18 +63,15 @@ int main()
|
|||||||
OPEN_IFS_AND_CHECK(input_path, input_file_stream)
|
OPEN_IFS_AND_CHECK(input_path, input_file_stream)
|
||||||
OPEN_OFS_AND_CHECK(output_path, output_file_stream)
|
OPEN_OFS_AND_CHECK(output_path, output_file_stream)
|
||||||
|
|
||||||
zt::check_fstream_isopen(input_file_stream, output_file_stream);
|
|
||||||
|
|
||||||
zt::print("open file ok!\n");
|
|
||||||
|
|
||||||
string l = "";
|
string l = "";
|
||||||
|
|
||||||
while (input_file_stream.getline(buf,50000,'\n'))
|
while (input_file_stream.getline(buf.data(),50000,'\n'))
|
||||||
{
|
{
|
||||||
int m = lines%2;
|
int m = lines%2;
|
||||||
if (m == 1)
|
if (m == 1)
|
||||||
output_file_stream << reverseComplement(buf) << endl;
|
reverseComplement(buf);
|
||||||
else
|
// output_file_stream << reverseComplement(buf) << endl;
|
||||||
|
// else
|
||||||
output_file_stream << buf << endl;
|
output_file_stream << buf << endl;
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user