Fix i-files for RDK_USE_BOOST_IOSTREAMS=OFF (#4933)

* fix i-files for RDK_USE_BOOST_IOSTREAMS=OFF

* separate gzstream test

Co-authored-by: Kazuya Ujihara <ujihara@preferred.jp>
This commit is contained in:
Kazuya Ujihara
2022-01-23 15:06:36 +09:00
committed by GitHub
parent cdc8e4a82b
commit 0530d468e2
5 changed files with 45 additions and 22 deletions

View File

@@ -54,6 +54,7 @@
%include <GraphMol/FileParsers/MolSupplier.h>
#ifdef RDK_USE_BOOST_IOSTREAMS
%extend RDKit::ForwardSDMolSupplier {
ForwardSDMolSupplier(RDKit::gzstream *strm, bool sanitize=true, bool removeHs = true,
bool strictParsing = true) {
@@ -66,6 +67,7 @@
return foo;
}
};
#endif
%include <GraphMol/Resonance.h>

View File

@@ -49,6 +49,7 @@ namespace std {
class istream;
}
#ifdef RDK_USE_BOOST_IOSTREAMS
%extend RDKit::gzstream {
std::istream* _GetStream() { return (std::istream*)$self; }
std::string Dump() {
@@ -68,6 +69,7 @@ class istream;
return streamRef;
}
%}
#endif
%include <../RDStreams/streams.h>

View File

@@ -173,6 +173,10 @@ if(NOT RDK_BUILD_INCHI_SUPPORT)
LIST(REMOVE_ITEM JAVA_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src-test/org/RDKit/InchiTests.java")
endif()
if(NOT RDK_USE_BOOST_IOSTREAMS)
LIST(REMOVE_ITEM JAVA_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src-test/org/RDKit/GzStreamTests.java")
endif()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_JAVA_TEST_OUTDIR}/org/RDKit/WrapperTests.class
COMMAND ${JAVA_COMPILE} ${DOCLINT_FLAGS} -d ${CMAKE_JAVA_TEST_OUTDIR} -cp "\"${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar${PATH_SEP}${JUNIT_JAR}\"" ${JAVA_TEST_FILES}

View File

@@ -0,0 +1,37 @@
package org.RDKit;
import static org.junit.Assert.*;
import java.io.*;
import java.util.ArrayList;
import org.junit.*;
public class GzStreamTests extends GraphMolTest {
@Test
public void test11GZstream() {
// NCI_aids_few.sdf.gz
File base = getRdBase();
File gzpath = new File(base, "Code" + File.separator + "GraphMol" + File.separator +
"FileParsers" + File.separator + "test_data");
File fileN = new File(gzpath, "NCI_aids_few.sdf.gz");
assertTrue(fileN.exists());
gzstream stream = new gzstream(fileN.getPath());
ForwardSDMolSupplier suppl = new ForwardSDMolSupplier(stream);
assertFalse(suppl.atEnd());
ArrayList<ROMol> ms = new ArrayList<ROMol>();
ROMol m;
do {
m = suppl.next();
if (m != null)
ms.add(m);
} while (!suppl.atEnd());
assertEquals(16, ms.size());
}
public static void main(String args[]) {
org.junit.runner.JUnitCore.main("org.RDKit.GzStreamTests");
}
}

View File

@@ -167,28 +167,6 @@ public class SuppliersTests extends GraphMolTest {
if((i%1000)==0) System.err.printf("Done: %s\n",i);
}
}
@Test
public void test11GZstream() {
// NCI_aids_few.sdf.gz
File base = getRdBase();
File gzpath = new File(base, "Code" + File.separator + "GraphMol" + File.separator +
"FileParsers" + File.separator + "test_data");
File fileN = new File(gzpath, "NCI_aids_few.sdf.gz");
assertTrue(fileN.exists());
gzstream stream = new gzstream(fileN.getPath());
ForwardSDMolSupplier suppl = new ForwardSDMolSupplier(stream);
assertFalse(suppl.atEnd());
ArrayList<ROMol> ms = new ArrayList<ROMol>();
ROMol m;
do {
m = suppl.next();
if (m != null)
ms.add(m);
} while (!suppl.atEnd());
assertEquals(16, ms.size());
}
public static void main(String args[]) {
org.junit.runner.JUnitCore.main("org.RDKit.SuppliersTests");