10#ifdef RDK_BUILD_THREADSAFE_SSS
11#ifndef MULTITHREADED_SD_MOL_SUPPLIER
12#define MULTITHREADED_SD_MOL_SUPPLIER
21 :
public MultithreadedMolSupplier {
23 explicit MultithreadedSDMolSupplier(
24 const std::string &fileName,
const Parameters ¶ms = Parameters(),
25 const MolFileParserParams &parseParams = MolFileParserParams());
27 explicit MultithreadedSDMolSupplier(
28 std::istream *inStream,
bool takeOwnership =
true,
29 const Parameters ¶ms = Parameters(),
30 const MolFileParserParams &parseParams = MolFileParserParams());
32 MultithreadedSDMolSupplier();
33 virtual ~MultithreadedSDMolSupplier() {close();}
34 void init()
override {}
37 bool getEnd()
const override;
38 void setProcessPropertyLists(
bool val) { df_processPropertyLists = val; }
39 bool getProcessPropertyLists()
const {
return df_processPropertyLists; }
40 bool getEOFHitOnRead()
const {
return df_eofHitOnRead; }
43 bool extractNextRecord(std::string &record,
unsigned int &lineNum,
44 unsigned int &index)
override;
45 void readMolProps(RWMol &mol, std::istringstream &inStream);
47 RWMol *processMoleculeRecord(
const std::string &record,
48 unsigned int lineNum)
override;
50 void closeStreams()
override;
53 void initFromSettings(
bool takeOwnership,
const Parameters ¶ms,
54 const MolFileParserParams &parseParams);
58 bool df_processPropertyLists =
true;
59 bool df_eofHitOnRead =
false;
60 unsigned int d_currentRecordId = 1;
61 MolFileParserParams d_parseParams;
71 using ContainedType = v2::FileParsers::MultithreadedSDMolSupplier;
72 MultithreadedSDMolSupplier() {}
73 explicit MultithreadedSDMolSupplier(
74 const std::string &fileName,
bool sanitize =
true,
bool removeHs =
true,
75 bool strictParsing =
true,
unsigned int numWriterThreads = 1,
76 size_t sizeInputQueue = 5,
size_t sizeOutputQueue = 5) {
77 v2::FileParsers::MultithreadedSDMolSupplier::Parameters params;
78 params.numWriterThreads = numWriterThreads;
79 params.sizeInputQueue = sizeInputQueue;
80 params.sizeOutputQueue = sizeOutputQueue;
81 v2::FileParsers::MolFileParserParams parseParams;
82 parseParams.sanitize = sanitize;
84 parseParams.strictParsing = strictParsing;
86 dp_supplier.reset(
new v2::FileParsers::MultithreadedSDMolSupplier(
87 fileName, params, parseParams));
90 explicit MultithreadedSDMolSupplier(
91 std::istream *inStream,
bool takeOwnership =
true,
bool sanitize =
true,
92 bool removeHs =
true,
bool strictParsing =
true,
93 unsigned int numWriterThreads = 1,
size_t sizeInputQueue = 5,
94 size_t sizeOutputQueue = 5) {
95 v2::FileParsers::MultithreadedSDMolSupplier::Parameters params;
96 params.numWriterThreads = numWriterThreads;
97 params.sizeInputQueue = sizeInputQueue;
98 params.sizeOutputQueue = sizeOutputQueue;
99 v2::FileParsers::MolFileParserParams parseParams;
100 parseParams.sanitize = sanitize;
102 parseParams.strictParsing = strictParsing;
104 dp_supplier.reset(
new v2::FileParsers::MultithreadedSDMolSupplier(
105 inStream, takeOwnership, params, parseParams));
109 bool getEOFHitOnRead()
const {
111 return static_cast<ContainedType *
>(dp_supplier.get())->getEOFHitOnRead();
120 unsigned int getLastRecordId()
const {
122 return static_cast<ContainedType *
>(dp_supplier.get())->getLastRecordId();
125 std::string getLastItemText()
const {
127 return static_cast<ContainedType *
>(dp_supplier.get())->getLastItemText();
129 void setProcessPropertyLists(
bool val) {
131 static_cast<ContainedType *
>(dp_supplier.get())
132 ->setProcessPropertyLists(val);
134 bool getProcessPropertyLists()
const {
136 return static_cast<ContainedType *
>(dp_supplier.get())
137 ->getProcessPropertyLists();
#define PRECONDITION(expr, mess)
#define RDKIT_FILEPARSERS_EXPORT
RDKIT_GRAPHMOL_EXPORT ROMol * removeHs(const ROMol &mol, bool implicitOnly, bool updateExplicitCount=false, bool sanitize=true)
returns a copy of a molecule with hydrogens removed