Loading...
Searching...
No Matches
RDKit::v2::FileParsers::MolSupplier Class Referenceabstract

`#include <MolSupplier.h>`

Inheritance diagram for RDKit::v2::FileParsers::MolSupplier:

## Public Member Functions

| MolSupplier ()
virtual | ~MolSupplier ()
virtual void | init ()=0
virtual void | reset ()=0
virtual bool | atEnd ()=0
virtual std::unique_ptr< RWMol > | next ()=0
virtual void | close ()

## Protected Member Functions

std::istream * | openAndCheckStream (const std::string &filename)

## Protected Attributes

std::istream * | dp_inStream = nullptr
bool | df_owner = false

## Detailed Description

Here are some of the ways one can interact with MolSuppliers:

1) Lazy (works with forward and random access suppliers): while(!supplier.atEnd()){ auto mol = supplier.next(); // mol is a std::unique_ptr<RWMol> if(mol){ do something; } }

2) Range based for loops (works with forward and random access suppliers): for(auto mol : supplier){ if(mol) { do something; // mol is a shared_ptr<RWMol> } }

3) Random Access: for(int i=0;i<supplier.length();i++){ auto mol = supplier[i]; // mol is a std::unique_ptr<RWMol> if(mol){ do something; } }

4) Random access supplier also support caching: supplier.setCaching(true); for(auto mol : supplier){ if(mol) { do something; // mol is a shared_ptr<RWMol> } } Subsequent iterations will be much faster as the molecules are cached after the first read.

It's also possible to access the cached molecules directly using the getShared method: supplier.setCaching(true); for(int i=0;i<supplier.length();i++){ auto mol = supplier.getShared(i); // mol is a std::shared_ptr<RWMol>; if(mol){ do something; } }

5) Random access suppliers can also be used with parallel algorithms: supplier.setCaching(true); std::for_each(std::execution::par, supplier.begin(), supplier.end(), [](auto mol) { if (mol) { do something; } });

Caching is not required here, but if you are planning on working with the molecules multiple times, it can speed things up significantly.

Definition at line 106 of file MolSupplier.h.

## Constructor & Destructor Documentation

## MolSupplier()

RDKit::v2::FileParsers::MolSupplier::MolSupplier | ( |  | ) |

inline

Definition at line 109 of file MolSupplier.h.

## ~MolSupplier()

virtual RDKit::v2::FileParsers::MolSupplier::~MolSupplier | ( |  | ) |

inline virtual

Definition at line 110 of file MolSupplier.h.

## Member Function Documentation

## atEnd()

virtual bool RDKit::v2::FileParsers::MolSupplier::atEnd | ( |  | ) |

pure virtual

Implemented in RDKit::v2::FileParsers::ForwardSDMolSupplier, RDKit::v2::FileParsers::SDMolSupplier, RDKit::v2::FileParsers::SmilesMolSupplier, and RDKit::v2::FileParsers::TDTMolSupplier.

## close()

virtual void RDKit::v2::FileParsers::MolSupplier::close | ( |  | ) |

inline virtual

Definition at line 116 of file MolSupplier.h.

References df_owner, and dp_inStream.

Referenced by RDKit::v2::FileParsers::ForwardSDMolSupplier::~ForwardSDMolSupplier(), RDKit::v2::FileParsers::SDMolSupplier::~SDMolSupplier(), RDKit::v2::FileParsers::SmilesMolSupplier::~SmilesMolSupplier(), and RDKit::v2::FileParsers::TDTMolSupplier::~TDTMolSupplier().

## init()

virtual void RDKit::v2::FileParsers::MolSupplier::init | ( |  | ) |

pure virtual

Implemented in RDKit::v2::FileParsers::ForwardSDMolSupplier, RDKit::v2::FileParsers::SDMolSupplier, RDKit::v2::FileParsers::SmilesMolSupplier, and RDKit::v2::FileParsers::TDTMolSupplier.

## next()

virtual std::unique_ptr< RWMol > RDKit::v2::FileParsers::MolSupplier::next | ( |  | ) |

pure virtual

Implemented in RDKit::v2::FileParsers::ForwardSDMolSupplier, RDKit::v2::FileParsers::SDMolSupplier, RDKit::v2::FileParsers::SmilesMolSupplier, and RDKit::v2::FileParsers::TDTMolSupplier.

## openAndCheckStream()

std::istream * RDKit::v2::FileParsers::MolSupplier::openAndCheckStream | ( | const std::string & | filename | ) |

inline protected

Definition at line 140 of file MolSupplier.h.

## reset()

virtual void RDKit::v2::FileParsers::MolSupplier::reset | ( |  | ) |

pure virtual

Implemented in RDKit::v2::FileParsers::ForwardSDMolSupplier, RDKit::v2::FileParsers::SDMolSupplier, RDKit::v2::FileParsers::SmilesMolSupplier, and RDKit::v2::FileParsers::TDTMolSupplier.

## Member Data Documentation

## df_owner

bool RDKit::v2::FileParsers::MolSupplier::df_owner = false

protected

Definition at line 136 of file MolSupplier.h.

Referenced by close().

## dp_inStream

std::istream* RDKit::v2::FileParsers::MolSupplier::dp_inStream = nullptr

protected

Definition at line 134 of file MolSupplier.h.

Referenced by close().

The documentation for this class was generated from the following file:

- MolSupplier.h