10#ifdef RDK_BUILD_THREADSAFE_SSS
11#ifndef MULTITHREADED_SMILES_MOL_SUPPLIER
12#define MULTITHREADED_SMILES_MOL_SUPPLIER
20 :
public MultithreadedMolSupplier {
22 explicit MultithreadedSmilesMolSupplier(
23 const std::string &fileName,
const Parameters ¶ms = Parameters(),
24 const SmilesMolSupplierParams &parseParams = SmilesMolSupplierParams());
26 explicit MultithreadedSmilesMolSupplier(
27 std::istream *inStream,
bool takeOwnership =
true,
28 const Parameters ¶ms = Parameters(),
29 const SmilesMolSupplierParams &parseParams = SmilesMolSupplierParams());
30 MultithreadedSmilesMolSupplier();
31 virtual ~MultithreadedSmilesMolSupplier() {close();};
33 void init()
override {}
35 bool getEnd()
const override;
37 void processTitleLine();
39 bool extractNextRecord(std::string &record,
unsigned int &lineNum,
40 unsigned int &index)
override;
42 RWMol *processMoleculeRecord(
const std::string &record,
43 unsigned int lineNum)
override;
46 void closeStreams()
override;
49 void initFromSettings(
50 bool takeOwnership,
const Parameters ¶ms,
51 const SmilesMolSupplierParams &parseParams = SmilesMolSupplierParams());
57 unsigned int d_currentRecordId = 1;
58 SmilesMolSupplierParams d_parseParams;
69 using ContainedType = v2::FileParsers::MultithreadedSmilesMolSupplier;
70 MultithreadedSmilesMolSupplier() {}
71 explicit MultithreadedSmilesMolSupplier(
72 const std::string &fileName,
const std::string &delimiter =
" \t",
73 int smilesColumn = 0,
int nameColumn = 1,
bool titleLine =
true,
74 bool sanitize =
true,
unsigned int numWriterThreads = 1,
75 size_t sizeInputQueue = 5,
size_t sizeOutputQueue = 5) {
76 v2::FileParsers::MultithreadedSmilesMolSupplier::Parameters params;
77 params.numWriterThreads = numWriterThreads;
78 params.sizeInputQueue = sizeInputQueue;
79 params.sizeOutputQueue = sizeOutputQueue;
80 v2::FileParsers::SmilesMolSupplierParams parseParams;
81 parseParams.delimiter = delimiter;
82 parseParams.smilesColumn = smilesColumn;
83 parseParams.nameColumn = nameColumn;
84 parseParams.titleLine = titleLine;
85 parseParams.parseParameters.sanitize = sanitize;
87 dp_supplier.
reset(
new v2::FileParsers::MultithreadedSmilesMolSupplier(
88 fileName, params, parseParams));
91 explicit MultithreadedSmilesMolSupplier(
92 std::istream *inStream,
bool takeOwnership =
true,
93 const std::string &delimiter =
" \t",
int smilesColumn = 0,
94 int nameColumn = 1,
bool titleLine =
true,
bool sanitize =
true,
95 unsigned int numWriterThreads = 1,
size_t sizeInputQueue = 5,
96 size_t sizeOutputQueue = 5) {
97 v2::FileParsers::MultithreadedSmilesMolSupplier::Parameters params;
98 params.numWriterThreads = numWriterThreads;
99 params.sizeInputQueue = sizeInputQueue;
100 params.sizeOutputQueue = sizeOutputQueue;
101 v2::FileParsers::SmilesMolSupplierParams parseParams;
102 parseParams.delimiter = delimiter;
103 parseParams.smilesColumn = smilesColumn;
104 parseParams.nameColumn = nameColumn;
105 parseParams.titleLine = titleLine;
106 parseParams.parseParameters.sanitize = sanitize;
108 dp_supplier.reset(
new v2::FileParsers::MultithreadedSmilesMolSupplier(
109 inStream, takeOwnership, params, parseParams));
113 bool getEOFHitOnRead()
const {
115 return static_cast<ContainedType *
>(dp_supplier.get())->getEOFHitOnRead();
124 unsigned int getLastRecordId()
const {
126 return static_cast<ContainedType *
>(dp_supplier.get())->getLastRecordId();
129 std::string getLastItemText()
const {
131 return static_cast<ContainedType *
>(dp_supplier.get())->getLastItemText();
#define PRECONDITION(expr, mess)
#define RDKIT_FILEPARSERS_EXPORT
std::vector< std::string > STR_VECT