Skip to content

Commit

Permalink
Updated Gradle to 8.5 and ran spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasSchaub committed Dec 8, 2023
1 parent ba5b24b commit 04c7585
Show file tree
Hide file tree
Showing 10 changed files with 1,279 additions and 1,275 deletions.
2 changes: 1 addition & 1 deletion License-header/License-header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ErtlFunctionalGroupsFinder for CDK
* Copyright (c) $today.year Sebastian Fritsch, Stefan Neumann, Jonas Schaub, Christoph Steinbeck, and Achim Zielesny
*
* Source code is available at <https://github.com/zielesny/ErtlFunctionalGroupsFinder>
* Source code is available at <https://github.com/JonasSchaub/ErtlFunctionalGroupsFinder>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* Performance test for
/*
* ErtlFunctionalGroupsFinder for CDK
* Copyright (C) 2019 Jonas Schaub
* Copyright (c) 2023 Sebastian Fritsch, Stefan Neumann, Jonas Schaub, Christoph Steinbeck, and Achim Zielesny
*
* Source code is available at <https://github.com/zielesny/ErtlFunctionalGroupsFinder>
* Source code is available at <https://github.com/JonasSchaub/ErtlFunctionalGroupsFinder>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand All @@ -18,8 +17,27 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.ibci.ertlfxgroupsfinder.performancetest;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcher;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.graph.CycleFinder;
import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.io.iterator.IteratingSDFReader;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.CDKHydrogenAdder;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand All @@ -39,96 +57,79 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcher;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.graph.CycleFinder;
import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.io.iterator.IteratingSDFReader;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.CDKHydrogenAdder;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;

/**
* An application for testing the performance of the ErtlFunctionalGroupsFinder.find() method under parallelization on
* multiple threads.
*
* An application for testing the performance of the ErtlFunctionalGroupsFinder.find() method under parallelization on
* multiple threads.
*
* @author Jonas Schaub
* @version 1.0.0.1
*/
public class ErtlFunctionalGroupsFinderPerformanceTest {

//<editor-fold defaultstate="collapsed" desc="Private static final constants">
/**
* Name of file for logging occurred exceptions
*/
private static final String EXCEPTIONS_LOG_FILE_NAME = "Exceptions_Log.txt";

/**
* Name of file for writing results
*/
private static final String RESULTS_FILE_NAME = "Results.txt";

/**
* All allowed atomic numbers to pass to the ErtlFunctionalGroupsFinder;
* String will be split and resulting integers passed to a set
*/
private static final String NON_METALLIC_ATOMIC_NUMBERS = "1,2,6,7,8,9,10,15,16,17,18,34,35,36,53,54,86";
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="Private class variables">
/**
* All allowed atomic numbers to pass to the ErtlFunctionalGroupsFinder as a set of integers (will be parsed from
* NON_METALLIC_ATOMIC_NUMBERS)
*/
private Set<Integer> nonMetallicAtomicNumbersSet;

/**
* The working directory (the jar-file's directory)
*/
private String workingPath;

/**
* The given number of different threads to use
*/
private int numberOfThreadsToUse;

/**
* All molecules loaded from the SD file
*/
private IAtomContainer[] moleculesArray;

/**
* The aromaticity model in use
*/
private Aromaticity aromaticityModel;
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="Constructor">
/**
* Instantiates and starts the application. It first loads all molecules from a given SD file into memory and then
* distributes them equally on the given number of different threads to use. It measures the time it takes for all
* threads to complete the extraction of functional groups using the ErtlFunctionalGroupsFinder. It exits the system
* if an unexpected exception occurs that prevents the application from working, e.g. an IllegalArgumentException
* distributes them equally on the given number of different threads to use. It measures the time it takes for all
* threads to complete the extraction of functional groups using the ErtlFunctionalGroupsFinder. It exits the system
* if an unexpected exception occurs that prevents the application from working, e.g. an IllegalArgumentException
* (will be logged to a file, not printed on the console).
*
* @param anArgs the command line arguments, anArgs[0] must be the name of the SD file to load (must be located in
* @param anArgs the command line arguments, anArgs[0] must be the name of the SD file to load (must be located in
* the same directory as the application's JAR file) and anArgs[1] must be the number of different threads to use
* @throws java.io.IOException if the constructor is unable to open a text file for logging occurred exceptions
*/
public ErtlFunctionalGroupsFinderPerformanceTest(String[] anArgs) throws IOException {
this.workingPath = (new File("").getAbsoluteFile().getAbsolutePath()) + File.separator;
LocalDateTime tmpDateTime = LocalDateTime.now();
String tmpTimeStamp = tmpDateTime.format(DateTimeFormatter.ofPattern("uuuu_MM_dd_HH_mm"));
File tmpExceptionsLogFile = new File(this.workingPath
File tmpExceptionsLogFile = new File(this.workingPath
+ ErtlFunctionalGroupsFinderPerformanceTest.EXCEPTIONS_LOG_FILE_NAME);
FileWriter tmpExceptionsLogFileWriter = new FileWriter(tmpExceptionsLogFile, true);
PrintWriter tmpExceptionsPrintWriter = new PrintWriter(tmpExceptionsLogFileWriter);
Expand Down Expand Up @@ -165,7 +166,7 @@ public ErtlFunctionalGroupsFinderPerformanceTest(String[] anArgs) throws IOExcep
tmpMetalNumbersInt[i] = Integer.parseInt(tmpMetalNumbersStrings[i]);
}
this.nonMetallicAtomicNumbersSet = new HashSet(Arrays.asList(tmpMetalNumbersInt));
File tmpResultsLogFile = new File(this.workingPath
File tmpResultsLogFile = new File(this.workingPath
+ ErtlFunctionalGroupsFinderPerformanceTest.RESULTS_FILE_NAME);
FileWriter tmpResultsLogFileWriter = new FileWriter(tmpResultsLogFile, true);
PrintWriter tmpResultsPrintWriter = new PrintWriter(tmpResultsLogFileWriter);
Expand All @@ -185,7 +186,7 @@ public ErtlFunctionalGroupsFinderPerformanceTest(String[] anArgs) throws IOExcep
tmpMolecule = this.applyFiltersAndPreprocessing(tmpMolecule);
tmpMoleculesList.add(tmpMolecule);
} catch (Exception anException) {
/*If an IllegalArgumentException is thrown in applyFiltersAndPreprocessing (meaning that the molecule
/*If an IllegalArgumentException is thrown in applyFiltersAndPreprocessing (meaning that the molecule
should be filtered) the molecule is skipped by catching this exception*/
}
}
Expand Down Expand Up @@ -240,7 +241,7 @@ public ErtlFunctionalGroupsFinderPerformanceTest(String[] anArgs) throws IOExcep
}
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="Private methods">
/**
* Performs all preprocessing needed for the ErtlFunctionalGroupsFinder and throws an IllegalArgumentException
Expand Down Expand Up @@ -284,7 +285,7 @@ private IAtomContainer applyFiltersAndPreprocessing(IAtomContainer aMolecule) th
this.aromaticityModel.apply(aMolecule);
return aMolecule;
}

/**
* Appends the given exception's stack trace to a log file.
*
Expand All @@ -296,8 +297,8 @@ private void appendToLogfile(Exception anException) {
}
PrintWriter tmpPrintWriter = null;
try {
FileWriter tmpFileWriter = new FileWriter(this.workingPath
+ ErtlFunctionalGroupsFinderPerformanceTest.EXCEPTIONS_LOG_FILE_NAME,
FileWriter tmpFileWriter = new FileWriter(this.workingPath
+ ErtlFunctionalGroupsFinderPerformanceTest.EXCEPTIONS_LOG_FILE_NAME,
true);
tmpPrintWriter = new PrintWriter(tmpFileWriter);
StringWriter tmpStringWriter = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* Performance test for
/*
* ErtlFunctionalGroupsFinder for CDK
* Copyright (C) 2019 Jonas Schaub
* Copyright (c) 2023 Sebastian Fritsch, Stefan Neumann, Jonas Schaub, Christoph Steinbeck, and Achim Zielesny
*
* Source code is available at <https://github.com/zielesny/ErtlFunctionalGroupsFinder>
* Source code is available at <https://github.com/JonasSchaub/ErtlFunctionalGroupsFinder>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand All @@ -18,39 +17,41 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.ibci.ertlfxgroupsfinder.performancetest;

import java.util.concurrent.Callable;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.tools.ErtlFunctionalGroupsFinder;

import java.util.concurrent.Callable;

/**
* A Callable thread that extracts functional groups from all molecules in a given array using the
* A Callable thread that extracts functional groups from all molecules in a given array using the
* ErtlFunctionalGroupsFinder class.
*
*
* @author Jonas Schaub
*/
public class ExtractFunctionalGroupsTask implements Callable<Integer> {

private final IAtomContainer[] moleculesArray;

private final ErtlFunctionalGroupsFinder ertlFinder;

/**
* Instantiates the thread.
*
* @param aListOfMolecules atom containers should meet the ErtlFunctionalGroupsFinder's input specifications but
*
* @param aListOfMolecules atom containers should meet the ErtlFunctionalGroupsFinder's input specifications but
* any occurring exception will be caught
*/
public ExtractFunctionalGroupsTask(IAtomContainer[] aListOfMolecules) {
this.moleculesArray = aListOfMolecules;
this.ertlFinder = new ErtlFunctionalGroupsFinder();
}

/**
* Applies the ErtlFunctionalGroupsFinder.find(IAtomContainer container, boolean clone) method on all given
* Applies the ErtlFunctionalGroupsFinder.find(IAtomContainer container, boolean clone) method on all given
* molecules (parameter clone = false) and counts the occurring exceptions.
*
*
* @return the number of occurred exceptions
* @throws Exception if unable to compute a result (copied from doc in Callable interface)
*/
Expand All @@ -66,5 +67,5 @@ public Integer call() throws Exception {
}
return tmpExceptionsCounter;
}

}
18 changes: 8 additions & 10 deletions src/main/java/de/ibci/ertlfxgroupsfinder/performancetest/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* Performance test for
/*
* ErtlFunctionalGroupsFinder for CDK
* Copyright (C) 2019 Jonas Schaub
* Copyright (c) 2023 Sebastian Fritsch, Stefan Neumann, Jonas Schaub, Christoph Steinbeck, and Achim Zielesny
*
* Source code is available at <https://github.com/zielesny/ErtlFunctionalGroupsFinder>
* Source code is available at <https://github.com/JonasSchaub/ErtlFunctionalGroupsFinder>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand All @@ -18,11 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.ibci.ertlfxgroupsfinder.performancetest;

/**
* Main class for starting application.
*
*
* @author Jonas Schaub
*/
public class Main {
Expand All @@ -32,9 +32,9 @@ private Main() {
}

/**
* Starts the application. Command line arguments must be the name of an SD-file to read (must be located in the
* Starts the application. Command line arguments must be the name of an SD-file to read (must be located in the
* same directory as the application's .jar file) and the number of different threads to use for calculation.
*
*
* @param args the command line arguments
*/
public static void main(String[] args) {
Expand All @@ -45,7 +45,5 @@ public static void main(String[] args) {
System.exit(1);
}
}

}


}
Loading

0 comments on commit 04c7585

Please sign in to comment.