Handle DOS files in SynthonSpaceSearch (#8075)

* Handle DOS files.

* Smaller test file.
Add DOS file to .gitattributes.

* Update Code/GraphMol/SynthonSpaceSearch/substructure_search_catch_tests.cpp

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
This commit is contained in:
David Cosgrove
2024-12-09 16:29:17 +00:00
committed by GitHub
parent bd85b29d43
commit d985a44f26
4 changed files with 21 additions and 2 deletions

2
.gitattributes vendored
View File

@@ -16,6 +16,7 @@ CMakeLists.txt text
# Declare files that will always have CRLF line endings on checkout.
#*.sln text eol=crlf
Code/GraphMol/SynthonSpaceSearch/data/amide_space_dos.txt eol=crlf
# Declare files that will always have LF line endings on checkout.
#*.svg text eol=lf
@@ -26,4 +27,3 @@ CMakeLists.txt text
*.pkl binary
*.fpb binary

View File

@@ -26,6 +26,7 @@
#include <GraphMol/SynthonSpaceSearch/SynthonSpaceSubstructureSearcher.h>
#include <GraphMol/SynthonSpaceSearch/SynthonSet.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <RDGeneral/StreamOps.h>
namespace RDKit::SynthonSpaceSearch {
@@ -123,7 +124,8 @@ void SynthonSpace::readTextFile(const std::string &inFilename) {
std::string nextLine;
int lineNum = 1;
std::vector<std::string> nextSynthon;
while (getline(ifs, nextLine)) {
while (!ifs.eof()) {
nextLine = getLine(ifs);
++lineNum;
if (nextLine.empty() || nextLine[0] == '#') {
continue;

View File

@@ -0,0 +1,8 @@
SMILES synton_id synton# reaction_id
c1ccccc1C(=O)[1*] 1-1 0 amide-1
C1CCCCC1C(=O)[1*] 1-2 0 amide-1
Clc1ccccc1C(=O)[1*] 1-3 0 amide-1
CCCCC(=O)[1*] 1-4 0 amide-1
[1*]N1CCCC1 2-1 1 amide-1
[1*]NCCCCC 2-2 1 amide-1
[1*]NCC1CC1 2-3 1 amide-1

View File

@@ -550,4 +550,13 @@ TEST_CASE("Greg Space Failure") {
auto results = synthonspace.substructureSearch(*queryMol, params);
CHECK(results.getHitMolecules().size() == 1);
}
TEST_CASE("DOS File") {
REQUIRE(rdbase);
std::string fName(rdbase);
std::string libName = fName + "/Code/GraphMol/SynthonSpaceSearch/data/amide_space_dos.txt";
SynthonSpace synthonspace;
synthonspace.readTextFile(libName);
CHECK(synthonspace.getNumProducts() == 12);
}