31 #include <boost/iostreams/filtering_stream.hpp>
32 #include <boost/iostreams/filter/gzip.hpp>
33 #include <boost/iostreams/device/file_descriptor.hpp>
34 #include <boost/iostreams/copy.hpp>
37 using namespace pwiz::util;
38 using namespace pwiz::proteome;
39 using namespace pwiz::data;
40 using boost::shared_ptr;
52 if (
os_) *
os_ <<
"validateWriteRead()\n " << writeConfig << endl;
65 shared_ptr<Reader> reader;
79 if (diff &&
os_) *
os_ << diff << endl;
83 pd1.
write(filename2, writeConfig);
90 if (diff &&
os_) *
os_ << diff << endl;
94 bio::filtering_istream tinyGZ(bio::gzip_compressor() | bio::file_descriptor_source(filename1));
95 bio::copy(tinyGZ, bio::file_descriptor_sink(filename1+
".gz", ios::out|ios::binary));
101 if (diff &&
os_) *
os_ << diff << endl;
106 bfs::remove(filename1);
107 bfs::remove(filename2);
108 bfs::remove(filename1 +
".gz");
110 bool index1Exists = bfs::exists(filename1 +
".index");
111 bool index2Exists = bfs::exists(filename2 +
".index");
112 bool index3Exists = bfs::exists(filename1 +
".gz.index");
114 bool indexShouldExist = writeConfig.
indexed;
119 if (index1Exists) bfs::remove(filename1 +
".index");
120 if (index2Exists) bfs::remove(filename2 +
".index");
121 if (index3Exists) bfs::remove(filename1 +
".gz.index");
144 virtual std::string identify(
const std::string& uri, shared_ptr<istream> uriStreamPtr)
const
148 if (!bal::iends_with(uri,
".fasta"))
152 getline(*uriStreamPtr, buf);
159 virtual void read(
const std::string& uri,
160 shared_ptr<istream> uriStreamPtr,
166 const char *
getType()
const {
return "testReader";}
176 ofstream os(filename.c_str());
177 os <<
">Id Description\nSEQUENCE\n";
188 boost::filesystem::remove(filename);
194 int main(
int argc,
char* argv[])
200 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;