mirror of
https://github.com/rdk/p2rank.git
synced 2026-06-04 12:44:24 +08:00
Lazy-init EnergyCalculator and LJEnergyCalculator in energy features
This commit is contained in:
@@ -27,14 +27,6 @@ class MethylEnergyCloudSF extends SasFeatureCalculator implements Parametrized {
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyCloudSF() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the feature with the energy calculator
|
||||
*/
|
||||
@Override
|
||||
void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
initializeCalculator()
|
||||
|
||||
@@ -29,14 +29,6 @@ class MethylEnergyCloudX2FullSF extends SasFeatureCalculator implements Parametr
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyCloudX2FullSF() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the feature with the energy calculator
|
||||
*/
|
||||
@Override
|
||||
void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
initializeCalculator()
|
||||
|
||||
@@ -29,14 +29,6 @@ class MethylEnergyCloudX2SF extends SasFeatureCalculator implements Parametrized
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyCloudX2SF() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the feature with the energy calculator
|
||||
*/
|
||||
@Override
|
||||
void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
initializeCalculator()
|
||||
|
||||
@@ -29,14 +29,6 @@ class MethylEnergyCloudXFullSF extends SasFeatureCalculator implements Parametri
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyCloudXFullSF() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the feature with the energy calculator
|
||||
*/
|
||||
@Override
|
||||
void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
initializeCalculator()
|
||||
|
||||
@@ -29,14 +29,6 @@ class MethylEnergyCloudXSF extends SasFeatureCalculator implements Parametrized
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyCloudXSF() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the feature with the energy calculator
|
||||
*/
|
||||
@Override
|
||||
void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
initializeCalculator()
|
||||
|
||||
@@ -22,25 +22,11 @@ class MethylEnergyFeature extends SasFeatureCalculator implements Parametrized {
|
||||
// Immutable calculator instance
|
||||
private LJEnergyCalculator calculator
|
||||
|
||||
MethylEnergyFeature() {
|
||||
// TODO re-init with new params before each run
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Initialize the feature with the energy calculator
|
||||
// */
|
||||
// @Override
|
||||
// void preProcessProtein(Protein protein, ProcessedItemContext itemContext) {
|
||||
// initializeCalculator()
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the energy calculator with current parameters
|
||||
* Initialize the energy calculator with current parameters (lazy, called on first use per protein).
|
||||
*/
|
||||
private void initializeCalculator() {
|
||||
private void ensureCalculatorInitialized() {
|
||||
if (calculator != null) return
|
||||
calculator = new LJEnergyCalculator(
|
||||
params.energy_probe_sigma,
|
||||
params.energy_probe_epsilon,
|
||||
@@ -63,8 +49,8 @@ class MethylEnergyFeature extends SasFeatureCalculator implements Parametrized {
|
||||
*/
|
||||
@Override
|
||||
double[] calculateForSasPoint(Atom sasPoint, SasFeatureCalculationContext context) {
|
||||
ensureCalculatorInitialized()
|
||||
|
||||
// try {
|
||||
// Get neighbor atoms around the SAS point
|
||||
//Atoms neighbourAtoms = context.extractor.deepLayer.cutoutSphere(sasPoint, params.energy_rc)
|
||||
Atoms neighbourAtoms = context.neighbourhoodAtoms
|
||||
|
||||
@@ -27,14 +27,9 @@ import static cz.siret.prank.utils.MathUtils.nanToZero
|
||||
@CompileStatic
|
||||
abstract class AbstractProbeEnergyFeature extends SasFeatureCalculator implements Parametrized {
|
||||
|
||||
// Immutable calculator instance
|
||||
protected EnergyCalculator calculator
|
||||
protected EnergyCalculatorConfig config
|
||||
|
||||
AbstractProbeEnergyFeature() {
|
||||
initializeCalculator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the probe type that this feature calculates
|
||||
*/
|
||||
@@ -46,7 +41,8 @@ abstract class AbstractProbeEnergyFeature extends SasFeatureCalculator implement
|
||||
abstract String getSecondaryDataKey()
|
||||
|
||||
/**
|
||||
* Initialize the energy calculator with current parameters and specific probe selection
|
||||
* Initialize the energy calculator with current parameters and specific probe selection.
|
||||
* Called lazily from preProcessProtein before first use.
|
||||
*/
|
||||
protected void initializeCalculator() {
|
||||
// Create config with only the specific probe type selected
|
||||
|
||||
Reference in New Issue
Block a user