Make PROPKA input file generation optional.
Fixes https://github.com/jensengroup/propka-3.1/issues/51.
This commit is contained in:
@@ -68,11 +68,6 @@ def read_molecule_file(input_file, mol_container):
|
||||
mol_container.conformations[name].sort_atoms()
|
||||
# find coupled groups
|
||||
mol_container.find_covalently_coupled_groups()
|
||||
# write out the input file
|
||||
# TODO - figure out why this I/O has to happen here
|
||||
output_path = Path(input_path.name.replace(
|
||||
input_file_extension, '.propka_input'))
|
||||
write_propka(mol_container, output_path)
|
||||
elif input_file_extension.lower() == '.propka_input':
|
||||
# input is a propka_input file
|
||||
conformations, conformation_names = read_propka(
|
||||
|
||||
@@ -279,6 +279,9 @@ def build_parser(parser=None):
|
||||
group.add_argument(
|
||||
"-q", "--quiet", action="store_const", const="WARNING",
|
||||
dest="log_level", help="suppress non-warning messages")
|
||||
group.add_argument(
|
||||
"--generate-propka-input", action="store_true",
|
||||
help="Generate a PROPKA input file")
|
||||
group.add_argument(
|
||||
"--protonate-all", dest="protonate_all", action="store_true",
|
||||
help="Protonate all atoms (will not influence pKa calculation)",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Molecular container for storing all contents of PDB files."""
|
||||
import os
|
||||
import propka.version
|
||||
from propka.output import write_propka, write_pka, print_header, print_result
|
||||
from propka.conformation_container import ConformationContainer
|
||||
from propka.lib import info, warning, make_grid
|
||||
|
||||
@@ -26,7 +27,7 @@ class MolecularContainer:
|
||||
options: options object
|
||||
"""
|
||||
# printing out header before parsing input
|
||||
propka.output.print_header()
|
||||
print_header()
|
||||
self.conformation_names = []
|
||||
self.conformations = {}
|
||||
self.options = options
|
||||
@@ -82,7 +83,7 @@ class MolecularContainer:
|
||||
# find the average of the conformations
|
||||
self.average_of_conformations()
|
||||
# print out the conformation-average results
|
||||
propka.output.print_result(self, 'AVR', self.version.parameters)
|
||||
print_result(self, 'AVR', self.version.parameters)
|
||||
|
||||
def average_of_conformations(self):
|
||||
"""Generate an average of conformations."""
|
||||
@@ -117,6 +118,16 @@ class MolecularContainer:
|
||||
self.conformation_names[0]].chains
|
||||
self.conformations['AVR'] = avr_conformation
|
||||
|
||||
def write_propka(self, filename=None):
|
||||
"""Write PROPKA input file.
|
||||
|
||||
Args:
|
||||
filename: file to write to
|
||||
"""
|
||||
if filename is None:
|
||||
filename = os.path.join('{0:s}.propka'.format(self.name))
|
||||
write_propka(self, filename)
|
||||
|
||||
def write_pka(self, filename=None, reference="neutral",
|
||||
direction="folding", options=None):
|
||||
"""Write pKa information to a file.
|
||||
@@ -127,8 +138,8 @@ class MolecularContainer:
|
||||
direction: folding vs. unfolding
|
||||
options: options object
|
||||
"""
|
||||
# write out the average conformation
|
||||
filename = os.path.join('{0:s}.pka'.format(self.name))
|
||||
if filename is None:
|
||||
filename = os.path.join('{0:s}.pka'.format(self.name))
|
||||
# if the display_coupled_residues option is true, write the results out
|
||||
# to an alternative pka file
|
||||
if self.options.display_coupled_residues:
|
||||
@@ -138,7 +149,7 @@ class MolecularContainer:
|
||||
filename = os.path.join(
|
||||
'{0:s}_{1:s}.pka'.format(
|
||||
self.name, self.version.parameters.output_file_tag))
|
||||
propka.output.write_pka(
|
||||
write_pka(
|
||||
self, self.version.parameters, filename=filename,
|
||||
conformation='AVR', reference=reference)
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ def main(optargs=None):
|
||||
my_molecule = read_molecule_file(pdbfile, my_molecule)
|
||||
my_molecule.calculate_pka()
|
||||
my_molecule.write_pka()
|
||||
if options.generate_propka_input:
|
||||
my_molecule.write_propka()
|
||||
|
||||
|
||||
def single(pdbfile, optargs=None):
|
||||
@@ -44,4 +46,6 @@ def single(pdbfile, optargs=None):
|
||||
my_molecule = read_molecule_file(pdbfile, my_molecule)
|
||||
my_molecule.calculate_pka()
|
||||
my_molecule.write_pka()
|
||||
if options.generate_propka_input:
|
||||
my_molecule.write_propka()
|
||||
return my_molecule
|
||||
|
||||
@@ -28,6 +28,8 @@ def main():
|
||||
my_molecule = read_molecule_file(pdbfile, my_molecule)
|
||||
my_molecule.calculate_pka()
|
||||
my_molecule.write_pka()
|
||||
if options.generate_propka_input:
|
||||
my_molecule.write_propka()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -78,6 +78,8 @@ def run_propka(options, pdb_path, tmp_path):
|
||||
molecule = read_molecule_file(str(pdb_path), molecule)
|
||||
molecule.calculate_pka()
|
||||
molecule.write_pka()
|
||||
if args.generate_propka_input:
|
||||
molecule.write_propka()
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user