aboutsummaryrefslogtreecommitdiff
path: root/plip
diff options
context:
space:
mode:
Diffstat (limited to 'plip')
-rw-r--r--plip/basic/config.py2
-rw-r--r--plip/exchange/report.py6
-rw-r--r--plip/plipcmd.py13
-rw-r--r--plip/structure/preparation.py17
-rw-r--r--plip/test/test_command_line.py6
-rw-r--r--plip/test/test_hydrogen_bonds.py2
6 files changed, 24 insertions, 22 deletions
diff --git a/plip/basic/config.py b/plip/basic/config.py
index a7468cf..4eee215 100644
--- a/plip/basic/config.py
+++ b/plip/basic/config.py
@@ -1,4 +1,4 @@
-__version__ = '2.1.0-beta'
+__version__ = '2.1.3'
__maintainer__ = 'PharmAI GmbH (2020) - www.pharm.ai - hello@pharm.ai'
import logging
diff --git a/plip/exchange/report.py b/plip/exchange/report.py
index a559bf8..20f281e 100644
--- a/plip/exchange/report.py
+++ b/plip/exchange/report.py
@@ -97,9 +97,7 @@ class StructureReport:
xml_declaration=True)
else:
output = et.tostring(self.xmlreport, pretty_print=True)
- if config.RAWSTRING:
- output = repr(output)
- print(output)
+ print(output.decode('utf8'))
def write_txt(self, as_string=False):
"""Write the TXT report"""
@@ -108,8 +106,6 @@ class StructureReport:
[f.write(textline + '\n') for textline in self.txtreport]
else:
output = '\n'.join(self.txtreport)
- if config.RAWSTRING:
- output = repr(output)
print(output)
diff --git a/plip/plipcmd.py b/plip/plipcmd.py
index e4c0815..f7dffab 100644
--- a/plip/plipcmd.py
+++ b/plip/plipcmd.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /usr/bin/env python
"""
Protein-Ligand Interaction Profiler - Analyze and visualize protein-ligand interactions in PDB files.
plipcmd.py - Main script for PLIP command line execution.
@@ -166,7 +166,7 @@ def run_analysis(inputstructs, inputpdbids):
logger.info(f'finished analysis, find the result files in {config.BASEPATH}')
-if __name__ == '__main__':
+def main():
"""Parse command line arguments and start main script for analysis."""
parser = ArgumentParser(prog="PLIP", description=description)
pdbstructure = parser.add_mutually_exclusive_group(required=True) # Needs either PDB ID or file
@@ -178,7 +178,7 @@ if __name__ == '__main__':
outputgroup.add_argument("-O", "--stdout", dest="stdout", action="store_true", default=False,
help="Write to stdout instead of file")
parser.add_argument("--rawstring", dest="use_raw_string", default=False, action="store_true",
- help="Use Python raw strings for stdout and stdin")
+ help="Use Python raw strings for stdin")
parser.add_argument("-v", "--verbose", dest="verbose", default=False, help="Turn on verbose mode",
action="store_true")
parser.add_argument("-q", "--quiet", dest="quiet", default=False, help="Turn on quiet mode", action="store_true")
@@ -240,9 +240,7 @@ if __name__ == '__main__':
for t in thresholds:
parser.add_argument('--%s' % t.name, dest=t.name, type=lambda val: threshold_limiter(parser, val),
help=argparse.SUPPRESS)
-
arguments = parser.parse_args()
-
# configure log levels
config.VERBOSE = True if arguments.verbose else False
config.QUIET = True if arguments.quiet else False
@@ -255,7 +253,6 @@ if __name__ == '__main__':
logger.setLevel(logging.CRITICAL)
else:
logger.setLevel(config.DEFAULT_LOG_LEVEL)
-
config.MAXTHREADS = arguments.maxthreads
config.XML = arguments.xml
config.TXT = arguments.txt
@@ -308,3 +305,7 @@ if __name__ == '__main__':
parser.error("The water bridge omega minimum angle has to be smaller than the water bridge omega maximum angle")
expanded_path = tilde_expansion(arguments.input) if arguments.input is not None else None
run_analysis(expanded_path, arguments.pdbid) # Start main script
+
+
+if __name__ == '__main__':
+ main()
diff --git a/plip/structure/preparation.py b/plip/structure/preparation.py
index 6b63d63..c2631d3 100644
--- a/plip/structure/preparation.py
+++ b/plip/structure/preparation.py
@@ -290,20 +290,19 @@ class LigandFinder:
ligtype = classify_by_name(names)
logger.debug(f'ligand classified as {ligtype}')
- hetatoms = set()
+ hetatoms = dict()
for obresidue in kmer:
- hetatoms_res = set([(obatom.GetIdx(), obatom) for obatom in pybel.ob.OBResidueAtomIter(obresidue)
- if obatom.GetAtomicNum() != 1])
-
+ cur_hetatoms = {obatom.GetIdx(): obatom for obatom in pybel.ob.OBResidueAtomIter(obresidue) if
+ obatom.GetAtomicNum() != 1}
if not config.ALTLOC:
# Remove alternative conformations (standard -> True)
- hetatoms_res = set([atm for atm in hetatoms_res
- if not self.mapper.mapid(atm[0], mtype='protein',
- to='internal') in self.altconformations])
- hetatoms.update(hetatoms_res)
+ ids_to_remove = [atom_id for atom_id in hetatoms.keys() if
+ self.mapper.mapid(atom_id, mtype='protein', to='internal') in self.altconformations]
+ for atom_id in ids_to_remove:
+ del cur_hetatoms[atom_id]
+ hetatoms.update(cur_hetatoms)
logger.debug(f'hetero atoms determined (n={len(hetatoms)})')
- hetatoms = dict(hetatoms) # make it a dict with idx as key and OBAtom as value
lig = pybel.ob.OBMol() # new ligand mol
neighbours = dict()
for obatom in hetatoms.values(): # iterate over atom objects
diff --git a/plip/test/test_command_line.py b/plip/test/test_command_line.py
index 5d8e8e5..d3ab332 100644
--- a/plip/test/test_command_line.py
+++ b/plip/test/test_command_line.py
@@ -46,3 +46,9 @@ class CommandLineTest(unittest.TestCase):
shell=True)
self.assertEqual(len(os.listdir(self.tmp_dir.name)), 2)
self.assertEqual(exitcode, 0)
+
+ def test_stdout(self):
+ """A PDB ID with no valid PDB record is provided."""
+ exitcode = subprocess.call(f'{sys.executable} ../plipcmd.py -t -f ./pdb/1eve.pdb -O', shell=True)
+ self.assertEqual(exitcode, 0)
+
diff --git a/plip/test/test_hydrogen_bonds.py b/plip/test/test_hydrogen_bonds.py
index 9d68532..75cae6c 100644
--- a/plip/test/test_hydrogen_bonds.py
+++ b/plip/test/test_hydrogen_bonds.py
@@ -35,4 +35,4 @@ class HydrogenBondTestCase(unittest.TestCase):
self.assertEqual(len(interactions1.hbonds_ldon), 0)
config.NOHYDRO = False
interactions2 = characterize_complex('./pdb/1x0n_state_1.pdb', 'DTF:A:174')
- self.assertEqual(len(interactions2.hbonds_ldon), 1)
+ self.assertEqual(len(interactions2.hbonds_ldon), 1) \ No newline at end of file