Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/c/indigo/src/indigo_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ bool IndigoMoleculeSubstructureMatcher::findTautomerMatch(QueryMolecule& query,
if (tau_matcher.get() == 0)
{
bool substructure = true;
tau_matcher.create(*target_prepared, substructure);
tau_matcher = std::make_unique<MoleculeTautomerMatcher>(*target_prepared, substructure);
}

tau_matcher->setRulesList(&tautomer_rules);
Expand Down Expand Up @@ -903,7 +903,7 @@ CEXPORT int indigoMatch(int target_matcher, int query)
}

if (matcher.matcher.get() == 0)
matcher.matcher.create(matcher.target);
matcher.matcher = std::make_unique<ReactionSubstructureMatcher>(matcher.target);

matcher.matcher->use_daylight_aam_mode = matcher.daylight_aam;
matcher.matcher->setQuery(qrxn);
Expand Down
11 changes: 9 additions & 2 deletions api/c/indigo/src/indigo_match.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
#include "reaction/reaction.h"
#include "reaction/reaction_substructure_matcher.h"

#include <memory>

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4251)
#endif

class IndigoQueryMolecule;

#ifdef _WIN32
Expand Down Expand Up @@ -130,7 +137,7 @@ class DLLEXPORT IndigoMoleculeSubstructureMatcher : public IndigoObject
Molecule& target;
Molecule moleculeFound;

Obj<MoleculeTautomerMatcher> tau_matcher;
std::unique_ptr<MoleculeTautomerMatcher> tau_matcher;
IndigoTautomerParams tau_params;
bool findTautomerMatch(QueryMolecule& query, PtrArray<TautomerRule>& tautomer_rules, Array<int>& mapping_out);

Expand Down Expand Up @@ -159,7 +166,7 @@ class DLLEXPORT IndigoReactionSubstructureMatcher : public IndigoObject
Reaction target;
bool daylight_aam;

Obj<ReactionSubstructureMatcher> matcher;
std::unique_ptr<ReactionSubstructureMatcher> matcher;
ObjArray<Array<int>> mappings;
Array<int> mol_mapping;
};
Expand Down
51 changes: 25 additions & 26 deletions bingo/bingo-core-c/src/bingo_core_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str)
QS_DEF(Array<char>, column);
BufferScanner scanner(fields_str);

self.import_properties.free();
self.import_columns.free();
self.import_properties.create();
self.import_columns.create();
self.import_properties.reset();
self.import_columns.reset();
self.import_properties = std::make_unique<StringPool>();
self.import_columns = std::make_unique<StringPool>();

scanner.skipSpace();

Expand All @@ -402,8 +402,8 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str)
scanner.readWord(column, " ,");
scanner.skipSpace();

self.import_properties.ref().add(prop.ptr());
self.import_columns.ref().add(column.ptr());
self.import_properties->add(prop.ptr());
self.import_columns->add(column.ptr());

if (scanner.isEOF())
break;
Expand All @@ -412,7 +412,7 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str)
throw BingoError("importParseFieldList(): comma expected");
scanner.skipSpace();
}
return self.import_properties.ref().size();
return self.import_properties->size();
}

CEXPORT int bingoImportParseFieldList(const char* fields_str)
Expand All @@ -428,7 +428,7 @@ const char* BingoCore::bingoImportGetColumnName(int idx)
{
if (self.import_columns.get() == 0)
throw BingoError("bingo import list has not been parsed yet");
return self.import_columns.ref().at(idx);
return self.import_columns->at(idx);
}

CEXPORT const char* bingoImportGetColumnName(int idx)
Expand All @@ -446,7 +446,7 @@ CEXPORT const char* bingoImportGetPropertyName(int idx)
{
if (self.import_properties.get() == 0)
throw BingoError("bingo import list has not been parsed yet");
return self.import_properties.ref().at(idx);
return self.import_properties->at(idx);
}
BINGO_END("", "");
}
Expand All @@ -455,7 +455,7 @@ const char* BingoCore::bingoImportGetPropertyValue(int idx)
{
if (self.import_properties.get() == 0)
throw BingoError("bingo import list has not been parsed yet");
const char* property_name = self.import_properties.ref().at(idx);
const char* property_name = self.import_properties->at(idx);
if (self.sdf_loader.get())
{
return self.sdf_loader->properties.at(property_name);
Expand Down Expand Up @@ -486,8 +486,8 @@ CEXPORT const char* bingoImportGetPropertyValue(int idx)
void BingoCore::bingoSDFImportOpen(const char* file_name)
{
self.bingoSDFImportClose();
self.file_scanner.create(file_name);
self.sdf_loader.create(self.file_scanner.ref());
self.file_scanner = std::make_unique<FileScanner>(file_name);
self.sdf_loader = std::make_unique<SdfLoader>(*self.file_scanner);
}

CEXPORT int bingoSDFImportOpen(const char* file_name)
Expand All @@ -501,8 +501,8 @@ CEXPORT int bingoSDFImportOpen(const char* file_name)

void BingoCore::bingoSDFImportClose()
{
self.sdf_loader.free();
self.file_scanner.free();
self.sdf_loader.reset();
self.file_scanner.reset();
}

CEXPORT int bingoSDFImportClose()
Expand Down Expand Up @@ -557,8 +557,8 @@ CEXPORT const char* bingoSDFImportGetProperty(const char* param_name)
void BingoCore::bingoRDFImportOpen(const char* file_name)
{
self.bingoRDFImportClose();
self.file_scanner.create(file_name);
self.rdf_loader.create(self.file_scanner.ref());
self.file_scanner = std::make_unique<FileScanner>(file_name);
self.rdf_loader = std::make_unique<RdfLoader>(*self.file_scanner);
}

CEXPORT int bingoRDFImportOpen(const char* file_name)
Expand All @@ -572,8 +572,8 @@ CEXPORT int bingoRDFImportOpen(const char* file_name)

void BingoCore::bingoRDFImportClose()
{
self.rdf_loader.free();
self.file_scanner.free();
self.rdf_loader.reset();
self.file_scanner.reset();
}

CEXPORT int bingoRDFImportClose()
Expand Down Expand Up @@ -773,14 +773,14 @@ static void _bingoIndexEnd(BingoCore& self)
}

if (self.single_mango_index.get())
self.single_mango_index.free();
self.single_mango_index.reset();
if (self.single_ringo_index.get())
self.single_ringo_index.free();
self.single_ringo_index.reset();

self.mango_index = 0;
self.ringo_index = 0;
self.index_record_data_id = -1;
self.index_record_data.free();
self.index_record_data.reset();
}

int BingoCore::bingoIndexEnd()
Expand All @@ -805,7 +805,7 @@ int BingoCore::bingoIndexBegin()

_bingoIndexEnd(self);

self.index_record_data.create();
self.index_record_data = std::make_unique<Array<char>>();
return 1;
}

Expand All @@ -830,8 +830,7 @@ CEXPORT int bingoIndexSetSkipFP(bool skip)

void BingoCore::bingoSMILESImportOpen(const char* file_name)
{
self.file_scanner.free();
self.file_scanner.create(file_name);
self.file_scanner = std::make_unique<FileScanner>(file_name);

// detect if input is gzipped
byte magic[2];
Expand All @@ -840,7 +839,7 @@ void BingoCore::bingoSMILESImportOpen(const char* file_name)
self.file_scanner->seek(pos, SEEK_SET);
if (magic[0] == 0x1f && magic[1] == 0x8b)
{
self.gz_scanner = std::make_unique<GZipScanner>(self.file_scanner.ref());
self.gz_scanner = std::make_unique<GZipScanner>(*self.file_scanner);
self.smiles_scanner = self.gz_scanner.get();
}
else
Expand All @@ -859,7 +858,7 @@ CEXPORT int bingoSMILESImportOpen(const char* file_name)
void BingoCore::bingoSMILESImportClose()
{
self.gz_scanner.reset(nullptr);
self.file_scanner.free();
self.file_scanner.reset();
self.smiles_scanner = 0;
}

Expand Down
25 changes: 17 additions & 8 deletions bingo/bingo-core-c/src/bingo_core_c_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
#include "bingo_core_c.h"
#include "bingo_core_c_parallel.h"

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4251)
#endif

namespace indigo
{
class GZipScanner;
Expand Down Expand Up @@ -149,12 +154,12 @@ namespace indigo
MangoContext* mango_context;
RingoContext* ringo_context;

Obj<StringPool> import_properties;
Obj<StringPool> import_columns;
std::unique_ptr<StringPool> import_properties;
std::unique_ptr<StringPool> import_columns;

Obj<FileScanner> file_scanner;
Obj<SdfLoader> sdf_loader;
Obj<RdfLoader> rdf_loader;
std::unique_ptr<FileScanner> file_scanner;
std::unique_ptr<SdfLoader> sdf_loader;
std::unique_ptr<RdfLoader> rdf_loader;

std::unique_ptr<GZipScanner> gz_scanner;
Scanner* smiles_scanner;
Expand All @@ -164,11 +169,11 @@ namespace indigo
MangoIndex* mango_index;
RingoIndex* ringo_index;

Obj<Array<char>> index_record_data;
std::unique_ptr<Array<char>> index_record_data;
int index_record_data_id;

Obj<MangoIndex> single_mango_index;
Obj<RingoIndex> single_ringo_index;
std::unique_ptr<MangoIndex> single_mango_index;
std::unique_ptr<RingoIndex> single_ringo_index;

std::unique_ptr<IndexingDispatcher> parallel_indexing_dispatcher;

Expand Down Expand Up @@ -359,4 +364,8 @@ namespace indigo
} // namespace bingo_core
} // namespace indigo

#ifdef _WIN32
#pragma warning(pop)
#endif

#endif // __bingo_core_c_h___
2 changes: 1 addition & 1 deletion bingo/bingo-core-c/src/bingo_core_c_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool IndexingDispatcher::_setupCommand(OsCommand& cmd)
_finished = true;
break;
}
command.records.add(_core.index_record_data.ref());
command.records.add(*_core.index_record_data);
command.ids.push(_core.index_record_data_id);
}
return command.ids.size() != 0;
Expand Down
24 changes: 16 additions & 8 deletions bingo/bingo-core-c/src/mango_core_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@
using namespace indigo;
using namespace indigo::bingo_core;

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4251)
#endif

int BingoCore::mangoIndexProcessSingleRecord()
{
BufferScanner scanner(self.index_record_data.ref());
BufferScanner scanner(*self.index_record_data);

NullOutput output;

Expand All @@ -49,7 +54,7 @@ int BingoCore::mangoIndexProcessSingleRecord()
{
if (self.single_mango_index.get() == NULL)
{
self.single_mango_index.create();
self.single_mango_index = std::make_unique<MangoIndex>();
self.single_mango_index->init(*self.bingo_context);
self.single_mango_index->skip_calculate_fp = self.skip_calculate_fp;
}
Expand Down Expand Up @@ -464,18 +469,17 @@ int BingoCore::mangoMatchTargetBinary(const char* target_bin, int target_bin_len
TRY_READ_TARGET_MOL
{
BufferScanner scanner(target_bin, target_bin_len);
BufferScanner* xyz_scanner = 0;
Obj<BufferScanner> xyz_scanner_obj;

std::unique_ptr<BufferScanner> xyz_scanner;
if (target_xyz_len != 0)
{
xyz_scanner_obj.create(target_xyz, target_xyz_len);
xyz_scanner = xyz_scanner_obj.get();
xyz_scanner = std::make_unique<BufferScanner>(target_xyz, target_xyz_len);
}

if (self.mango_search_type == BingoCore::_SUBSTRUCTRE)
{
MangoSubstructure& substructure = self.mango_context->substructure;
return substructure.matchBinary(scanner, xyz_scanner) ? 1 : 0;
return substructure.matchBinary(scanner, xyz_scanner.get()) ? 1 : 0;
}
else if (self.mango_search_type == BingoCore::_TAUTOMER)
{
Expand All @@ -485,7 +489,7 @@ int BingoCore::mangoMatchTargetBinary(const char* target_bin, int target_bin_len
else if (self.mango_search_type == BingoCore::_EXACT)
{
MangoExact& exact = self.mango_context->exact;
return exact.matchBinary(scanner, xyz_scanner) ? 1 : 0;
return exact.matchBinary(scanner, xyz_scanner.get()) ? 1 : 0;
}
else if (self.mango_search_type == BingoCore::_SIMILARITY)
{
Expand Down Expand Up @@ -1136,3 +1140,7 @@ CEXPORT const char* mangoStandardize(const char* molecule, int molecule_len, con
}
BINGO_END(0, 0);
}

#ifdef _WIN32
#pragma warning(pop)
#endif
4 changes: 2 additions & 2 deletions bingo/bingo-core-c/src/ringo_core_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace indigo::bingo_core;

int BingoCore::ringoIndexProcessSingleRecord()
{
BufferScanner scanner(self.index_record_data.ref());
BufferScanner scanner(*self.index_record_data);

NullOutput output;

Expand All @@ -47,7 +47,7 @@ int BingoCore::ringoIndexProcessSingleRecord()
{
if (self.single_ringo_index.get() == NULL)
{
self.single_ringo_index.create();
self.single_ringo_index = std::make_unique<RingoIndex>();
self.single_ringo_index->init(*self.bingo_context);
self.single_ringo_index->skip_calculate_fp = self.skip_calculate_fp;
}
Expand Down
10 changes: 10 additions & 0 deletions bingo/bingo-core/src/core/bingo_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
#define __bingo_context__

#include <map>
#include <memory>

#include "base_cpp/nullable.h"
#include "bingo_version.h"
#include "lzw/lzw_dictionary.h"
#include "molecule/molecule_fingerprint.h"
#include "molecule/molecule_tautomer.h"

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4251)
#endif

// extern const char *bingo_version_string;

namespace indigo
Expand Down Expand Up @@ -120,4 +126,8 @@ void bingoGetTauCondition(const char* list_ptr, int& aromaticity, indigo::Array<

void bingoGetName(indigo::Scanner& scanner, indigo::Array<char>& result);

#ifdef _WIN32
#pragma warning(pop)
#endif

#endif
Loading