Lazy-init EnergyCalculator and LJEnergyCalculator in energy features

This commit is contained in:
rdk
2026-03-16 07:55:16 +01:00
parent 48cb681aaa
commit faddcfb70f
7 changed files with 6 additions and 64 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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