4.2. ligandparam.stages.charge
- class ligandparam.stages.charge.StageNormalizeCharge(name, orig_mol2=None, new_mol2=None, precision=0.0001, inputoptions=None)[source]
Bases:
AbstractStageThis class normalizes the charges to the net charge.
This class works by calculating the charge difference, and then normalizing the charges based on the overall precision that you select, by adjusting each atom charge by the precision until the charge difference is zero.
- Parameters:
name (str) – The name of the stage
base_cls (Ligand) – The base class of the ligand
orig_mol2 (str) – The original mol2 file
new_mol2 (str) – The new mol2 file
precision (float) – The precision of the charge normalization
- Raises:
ValueError – If the original mol2 file is not provided
ValueError – If the new mol2 file is not provided
Methods
check_charge(charges)This function checks the total charge and the charge difference.
list_files_in_directory(directory)List all the files in a directory.
normalize(charges, charge_difference)This function normalizes the charges to the net charge.
print_charge_differences(names, ...)This function prints the charge differences between the original and new charges.
print_docs()Print the documentation for the stage.
append_stage
clean
execute
- _abc_impl = <_abc._abc_data object>
- _append_stage(stage: AbstractStage) AbstractStage[source]
- _execute(dry_run=False)[source]
This class normalizes the charges to the net charge.
This function works by calculating the charge difference, and then normalizing the charges based on the overall precision that you select, by adjusting each atom charge by the precision until the charge difference is zero, starting with the largest charges.
- Raises:
ValueError – If the charge normalization fails
TODO – Check what happens when netcharge is nonzero:
TODO – Check what happens when charge difference is larger than the number of atoms:
- check_charge(charges)[source]
This function checks the total charge and the charge difference.
- Parameters:
charges (np.array) – The charges
- Returns:
total_charge (float) – The total charge
charge_difference (float) – The charge difference
- class ligandparam.stages.charge.StageUpdateCharge(name, orig_mol2=None, new_mol2=None, charge_source='multistate', charge_column=None, inputoptions=None)[source]
Bases:
AbstractStageThis class creates a new mol2 file with updated charges.
- Parameters:
name (str) – The name of the stage
base_cls (Ligand) – The base class of the ligand
orig_mol2 (str) – The original mol2 file
new_mol2 (str) – The new mol2 file
charge_source (str) – The source of the charges
charge_column (int) – The column of the charges
Methods
list_files_in_directory(directory)List all the files in a directory.
print_docs()Print the documentation for the stage.
append_stage
clean
execute
- _abc_impl = <_abc._abc_data object>
- _append_stage(stage: AbstractStage) AbstractStage[source]
- _execute(dry_run=False)[source]
Execute StageUpdateCharge to update charges in a mol2 file from a charge source.
This stage will update the charges in a mol2 file from a charge source file. This could be a respfit.out file, or any other file with charges stored in a column. The column number is specified in the charge_column variable when the stage is initialized.
- Parameters:
dry_run (bool, optional) – If True, the stage will not be executed, but the function will print the commands that would
- Raises:
FileNotFoundError – If the charge source file is not found
ValueError – If the number of charges does not match the number of atoms