Clean line breaks.
See https://github.com/jensengroup/propka-3.1/issues/43
This commit is contained in:
@@ -37,8 +37,10 @@ class LigandPkaValues:
|
|||||||
location of program
|
location of program
|
||||||
"""
|
"""
|
||||||
path = os.environ.get('PATH').split(os.pathsep)
|
path = os.environ.get('PATH').split(os.pathsep)
|
||||||
locs = [i for i in filter(lambda loc: os.access(loc, os.F_OK), \
|
locs = [
|
||||||
map(lambda dir: os.path.join(dir, program), path))]
|
i for i in filter(lambda loc: os.access(loc, os.F_OK),
|
||||||
|
map(lambda dir: os.path.join(dir, program),
|
||||||
|
path))]
|
||||||
if len(locs) == 0:
|
if len(locs) == 0:
|
||||||
str_ = "'Error: Could not find %s." % program
|
str_ = "'Error: Could not find %s." % program
|
||||||
str_ += ' Please make sure that it is found in the path.'
|
str_ += ' Please make sure that it is found in the path.'
|
||||||
@@ -46,7 +48,8 @@ class LigandPkaValues:
|
|||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
return locs[0]
|
return locs[0]
|
||||||
|
|
||||||
def get_marvin_pkas_for_pdb_file(self, pdbfile, num_pkas=10, min_ph=-10, max_ph=20):
|
def get_marvin_pkas_for_pdb_file(self, pdbfile, num_pkas=10, min_ph=-10,
|
||||||
|
max_ph=20):
|
||||||
"""Use Marvin executables to get pKas for a PDB file.
|
"""Use Marvin executables to get pKas for a PDB file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -56,12 +59,11 @@ class LigandPkaValues:
|
|||||||
max_ph: maximum pH value
|
max_ph: maximum pH value
|
||||||
"""
|
"""
|
||||||
molecule = propka.molecular_container.Molecular_container(pdbfile)
|
molecule = propka.molecular_container.Molecular_container(pdbfile)
|
||||||
self.get_marvin_pkas_for_molecular_container(molecule,
|
self.get_marvin_pkas_for_molecular_container(
|
||||||
num_pkas=num_pkas,
|
molecule, num_pkas=num_pkas, min_ph=min_ph, max_ph=max_ph)
|
||||||
min_ph=min_ph,
|
|
||||||
max_ph=max_ph)
|
|
||||||
|
|
||||||
def get_marvin_pkas_for_molecular_container(self, molecule, num_pkas=10, min_ph=-10, max_ph=20):
|
def get_marvin_pkas_for_molecular_container(self, molecule, num_pkas=10,
|
||||||
|
min_ph=-10, max_ph=20):
|
||||||
"""Use Marvin executables to calculate pKas for a molecular container.
|
"""Use Marvin executables to calculate pKas for a molecular container.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -72,13 +74,10 @@ class LigandPkaValues:
|
|||||||
"""
|
"""
|
||||||
for name in molecule.conformation_names:
|
for name in molecule.conformation_names:
|
||||||
filename = '%s_%s' % (molecule.name, name)
|
filename = '%s_%s' % (molecule.name, name)
|
||||||
self.get_marvin_pkas_for_conformation_container(molecule.conformations[name],
|
self.get_marvin_pkas_for_conformation_container(
|
||||||
name=filename,
|
molecule.conformations[name], name=filename,
|
||||||
reuse=molecule.\
|
reuse=molecule.options.reuse_ligand_mol2_file,
|
||||||
options.reuse_ligand_mol2_file,
|
num_pkas=num_pkas, min_ph=min_ph, max_ph=max_ph)
|
||||||
num_pkas=num_pkas,
|
|
||||||
min_ph=min_ph,
|
|
||||||
max_ph=max_ph)
|
|
||||||
|
|
||||||
def get_marvin_pkas_for_conformation_container(self, conformation,
|
def get_marvin_pkas_for_conformation_container(self, conformation,
|
||||||
name='temp', reuse=False,
|
name='temp', reuse=False,
|
||||||
@@ -95,10 +94,9 @@ class LigandPkaValues:
|
|||||||
max_ph: maximum pH value
|
max_ph: maximum pH value
|
||||||
"""
|
"""
|
||||||
conformation.marvin_pkas_calculated = True
|
conformation.marvin_pkas_calculated = True
|
||||||
self.get_marvin_pkas_for_atoms(conformation.get_heavy_ligand_atoms(),
|
self.get_marvin_pkas_for_atoms(
|
||||||
name=name, reuse=reuse,
|
conformation.get_heavy_ligand_atoms(), name=name, reuse=reuse,
|
||||||
num_pkas=num_pkas, min_ph=min_ph,
|
num_pkas=num_pkas, min_ph=min_ph, max_ph=max_ph)
|
||||||
max_ph=max_ph)
|
|
||||||
|
|
||||||
def get_marvin_pkas_for_atoms(self, atoms, name='temp', reuse=False,
|
def get_marvin_pkas_for_atoms(self, atoms, name='temp', reuse=False,
|
||||||
num_pkas=10, min_ph=-10, max_ph=20):
|
num_pkas=10, min_ph=-10, max_ph=20):
|
||||||
@@ -116,8 +114,8 @@ class LigandPkaValues:
|
|||||||
molecules = propka.lib.split_atoms_into_molecules(atoms)
|
molecules = propka.lib.split_atoms_into_molecules(atoms)
|
||||||
for i, molecule in enumerate(molecules):
|
for i, molecule in enumerate(molecules):
|
||||||
filename = '%s_%d.mol2'%(name, i+1)
|
filename = '%s_%d.mol2'%(name, i+1)
|
||||||
self.get_marvin_pkas_for_molecule(molecule, filename=filename,
|
self.get_marvin_pkas_for_molecule(
|
||||||
reuse=reuse, num_pkas=num_pkas,
|
molecule, filename=filename, reuse=reuse, num_pkas=num_pkas,
|
||||||
min_ph=min_ph, max_ph=max_ph)
|
min_ph=min_ph, max_ph=max_ph)
|
||||||
|
|
||||||
def get_marvin_pkas_for_molecule(self, atoms, filename='__tmp_ligand.mol2',
|
def get_marvin_pkas_for_molecule(self, atoms, filename='__tmp_ligand.mol2',
|
||||||
@@ -138,25 +136,28 @@ class LigandPkaValues:
|
|||||||
propka.pdb.write_mol2_for_atoms(atoms, filename)
|
propka.pdb.write_mol2_for_atoms(atoms, filename)
|
||||||
# check that we actually have a file to work with
|
# check that we actually have a file to work with
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
errstr = "Didn't find a user-modified file '%s' - generating one" \
|
errstr = ("Didn't find a user-modified file '%s' - generating one"
|
||||||
% filename
|
% filename)
|
||||||
warning(errstr)
|
warning(errstr)
|
||||||
propka.pdb.write_mol2_for_atoms(atoms, filename)
|
propka.pdb.write_mol2_for_atoms(atoms, filename)
|
||||||
# Marvin calculate pKa values
|
# Marvin calculate pKa values
|
||||||
options = 'pka -a %d -b %d --min %f --max %f -d large' % (num_pkas,
|
options = ('pka -a %d -b %d --min %f --max %f -d large'
|
||||||
num_pkas,
|
% (num_pkas, num_pkas, min_ph, max_ph))
|
||||||
min_ph,
|
(output, errors) = subprocess.Popen(
|
||||||
max_ph)
|
[self.cxcalc, filename]+options.split(), stdout=subprocess.PIPE,
|
||||||
(output, errors) = subprocess.Popen([self.cxcalc, filename]+options.split(),
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE).communicate()
|
stderr=subprocess.PIPE).communicate()
|
||||||
if len(errors) > 0:
|
if len(errors) > 0:
|
||||||
info('********************************************************************************************************')
|
info('***********************************************************'
|
||||||
info('* Warning: Marvin execution failed: *')
|
'*********************************************')
|
||||||
|
info('* Warning: Marvin execution failed: '
|
||||||
|
' *')
|
||||||
info('* %-100s *' % errors)
|
info('* %-100s *' % errors)
|
||||||
info('* *')
|
info('* '
|
||||||
info('* Please edit the ligand mol2 file and re-run PropKa with the -l option: %29s *' % filename)
|
' *')
|
||||||
info('********************************************************************************************************')
|
info('* Please edit the ligand mol2 file and re-run PropKa with '
|
||||||
|
'the -l option: %29s *' % filename)
|
||||||
|
info('***********************************************************'
|
||||||
|
'*********************************************')
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
# extract calculated pkas
|
# extract calculated pkas
|
||||||
indices, pkas, types = self.extract_pkas(output)
|
indices, pkas, types = self.extract_pkas(output)
|
||||||
@@ -182,8 +183,9 @@ class LigandPkaValues:
|
|||||||
tags = tags.split('\t')
|
tags = tags.split('\t')
|
||||||
values = values.split('\t')
|
values = values.split('\t')
|
||||||
# format values
|
# format values
|
||||||
types = [tags[i][0] for i in range(1, len(tags)-1) if len(values) > i \
|
types = [
|
||||||
and values[i] != '']
|
tags[i][0] for i in range(1, len(tags)-1)
|
||||||
|
if len(values) > i and values[i] != '']
|
||||||
indices = [int(a)-1 for a in values[-1].split(',') if a != '']
|
indices = [int(a)-1 for a in values[-1].split(',') if a != '']
|
||||||
values = [float(v.replace(',', '.')) for v in values[1:-1] if v != '']
|
values = [float(v.replace(',', '.')) for v in values[1:-1] if v != '']
|
||||||
if len(indices) != len(values) != len(types):
|
if len(indices) != len(values) != len(types):
|
||||||
|
|||||||
Reference in New Issue
Block a user