56 std::string &compressionFormat) {
61 if (boost::algorithm::iends_with(path,
".maegz")) {
63 compressionFormat =
"gz";
65 }
else if (boost::algorithm::iends_with(path,
".sdfgz")) {
67 compressionFormat =
"gz";
69 }
else if (boost::algorithm::iends_with(path,
".gz")) {
70 compressionFormat =
"gz";
71 basename = path.substr(0, path.size() - 3);
72 }
else if (boost::algorithm::iends_with(path,
".zst") ||
73 boost::algorithm::iends_with(path,
".bz2") ||
74 boost::algorithm::iends_with(path,
".7z")) {
76 "Unsupported compression extension (.zst, .bz2, .7z) given path: " +
80 compressionFormat =
"";
83 if (boost::algorithm::iends_with(basename,
"." + suffix)) {
89 "Unsupported structure or compression extension given path: " + path);
101 std::string fileFormat =
"";
102 std::string compressionFormat =
"";
107 if (compressionFormat.empty()) {
108 strm =
new std::ifstream(path.c_str(), std::ios::in | std::ios::binary);
110#ifdef RDK_USE_BOOST_IOSTREAMS
111 strm =
new gzstream(path);
114 "compressed files are only supported if the RDKit is built with boost::iostreams support");
118 if ((!(*strm)) || strm->bad()) {
119 std::ostringstream errout;
120 errout <<
"Bad input file " << path;
125 if (strm->bad() || strm->eof()) {
126 std::ostringstream errout;
127 errout <<
"Invalid input file " << path;
132#ifdef RDK_BUILD_THREADSAFE_SSS
133 FileParsers::MultithreadedMolSupplier::Parameters params;
137 if (fileFormat ==
"sdf") {
142#ifdef RDK_BUILD_THREADSAFE_SSS
143 if (params.numWriterThreads > 1) {
144 return std::make_unique<FileParsers::MultithreadedSDMolSupplier>(
145 strm,
true, params, parseParams);
148 return std::make_unique<FileParsers::ForwardSDMolSupplier>(strm,
true,
152 else if (fileFormat ==
"smi" || fileFormat ==
"csv" || fileFormat ==
"txt" ||
153 fileFormat ==
"tsv") {
160#ifdef RDK_BUILD_THREADSAFE_SSS
161 if (params.numWriterThreads > 1) {
162 return std::make_unique<FileParsers::MultithreadedSmilesMolSupplier>(
163 strm,
true, params, parseParams);
166 return std::make_unique<FileParsers::SmilesMolSupplier>(strm,
true,
169#ifdef RDK_BUILD_MAEPARSER_SUPPORT
170 else if (fileFormat ==
"mae") {
171 FileParsers::MaeMolSupplierParams parseParams;
172 parseParams.sanitize = opt.
sanitize;
173 parseParams.removeHs = opt.
removeHs;
174 return std::make_unique<FileParsers::MaeMolSupplier>(strm,
true,
178 else if (fileFormat ==
"tdt") {
184 return std::make_unique<FileParsers::TDTMolSupplier>(strm,
true,