This commit is contained in:
Zengtudor 2024-09-18 15:53:36 +08:00
parent 9dfa5e7bac
commit 5be58df294
2 changed files with 18 additions and 14 deletions

View File

@ -1,15 +1,19 @@
#include <exception>
#include <filesystem>
#include<fstream>
#include <sstream>
#include <stdexcept>
#include<string>
#include<algorithm>
#include<iostream>
#include <type_traits>
#include"tools.hpp"
// 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_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());}
std::string reverseComplement(std::string DNAsequence)
{
using namespace std;
@ -40,12 +44,10 @@ std::string reverseComplement(std::string DNAsequence)
return l;
}
int main()
{
try{
std::ios_base::sync_with_stdio(false); //加了没效果
// std::ios_base::sync_with_stdio(false); //加了没效果
using namespace std;
char buf[50000];
@ -53,8 +55,10 @@ int main()
filesystem::path input_path("filteredReads.txt"),output_path("reversedSequence.txt");
ifstream input_file_stream(input_path);
ofstream output_file_stream(output_path);
// ifstream input_file_stream(input_path);
// ofstream output_file_stream(output_path);
OPEN_IFS_AND_CHECK(input_path, input_file_stream)
OPEN_OFS_AND_CHECK(output_path, output_file_stream)
zt::check_fstream_isopen(input_file_stream, output_file_stream);

View File

@ -70,12 +70,12 @@ namespace zt {
return;
}
template <class ...Args>
inline void check_fstream_isopen(const Args&...args)noexcept(false){
bool is_open=true;
(((!args.is_open())?is_open=false:true),...);
if(is_open==false){
throw std::runtime_error("cannot open file stream ");
}
}
// template <class ...Args>
// inline void check_fstream_isopen(const Args&...args)noexcept(false){
// bool is_open=true;
// (((!args.is_open())?is_open=false:true),...);
// if(is_open==false){
// throw std::runtime_error("cannot open file stream ");
// }
// }
}