Skip to content
Permalink
Browse files

added point properties component

  • Loading branch information...
schallerdavid committed Jun 16, 2019
1 parent a2cd034 commit e20465380a7fdfb5852c8c1e4001efa9b6780132
Showing with 53 additions and 5 deletions.
  1. +21 −0 configs/point_properties.cfg
  2. +14 −4 pyrod.py
  3. +6 −0 pyrod_lib/config.py
  4. +11 −0 pyrod_lib/grid.py
  5. +1 −1 pyrod_lib/lookup.py
@@ -0,0 +1,21 @@
###############################################################################
### This is a config-file for PyRod. Please do not modify the original ###
### version. Create and change a new copy for each run to avoid errors. ###
###############################################################################

[directory]
###############################################################################
### Section for defining the path to the output directory. If no path is ###
### specified, the output will be saved in a directory named pyrod in the ###
### current working directory. ###
###############################################################################
directory:

[point properties parameters]
###############################################################################
### Section for defining parameters to retrieve dMIF properties of a grid ###
### point. The grid point is described by coordinates, e.g. from a ###
### pharmacophore feature. Path to dmif.pkl needs to be specified. ###
###############################################################################
point: 0, 0, 0
dmif: /path/to/pyrod/data/dmif.pkl
@@ -19,10 +19,11 @@

# pyrod modules
try:
from pyrod.pyrod_lib.grid import generate_grid, dmif_data_structure, post_processing, generate_dmif_excess
from pyrod.pyrod_lib.grid import generate_grid, dmif_data_structure, post_processing, generate_dmif_excess, \
get_point_properties
from pyrod.pyrod_lib.config import test_grid_parameters, trajectory_analysis_parameters, \
exclusion_volume_parameters, feature_parameters, pharmacophore_parameters, library_parameters, \
dmif_excess_parameters, centroid_parameters
dmif_excess_parameters, centroid_parameters, point_properties_parameters
from pyrod.pyrod_lib.lookup import logo, __version__, grid_list_dict, feature_types
from pyrod.pyrod_lib.pharmacophore import generate_exclusion_volumes, generate_features, generate_library
from pyrod.pyrod_lib.pharmacophore_helper import select_features, renumber_features
@@ -31,10 +32,11 @@
from pyrod.pyrod_lib.write import file_path, pdb_grid, dmif_writer, pharmacophore_writer, pickle_writer, \
setup_logger, update_user, time_to_text
except ImportError:
from pyrod_lib.grid import generate_grid, dmif_data_structure, post_processing, generate_dmif_excess
from pyrod_lib.grid import generate_grid, dmif_data_structure, post_processing, generate_dmif_excess, \
get_point_properties
from pyrod_lib.config import test_grid_parameters, trajectory_analysis_parameters, \
exclusion_volume_parameters, feature_parameters, pharmacophore_parameters, library_parameters, \
dmif_excess_parameters, centroid_parameters
dmif_excess_parameters, centroid_parameters, point_properties_parameters
from pyrod_lib.lookup import logo, __version__, grid_list_dict, feature_types
from pyrod_lib.pharmacophore import generate_exclusion_volumes, generate_features, generate_library
from pyrod_lib.pharmacophore_helper import select_features, renumber_features
@@ -84,6 +86,14 @@ def chunks(iterable, chunk_size):
space += 0.5
else:
space += 1
# point properties
if config.has_section('point properties parameters'):
logger.debug('\n'.join([': '.join(list(_)) for _ in config.items('point properties parameters')]))
point, dmif_path = point_properties_parameters(config)
update_user('Getting point properties from {}.'.format(dmif_path), logger)
point_properties_dict = get_point_properties(point, dmif_path)
for key, value in point_properties_dict.items():
update_user('{}: {}'.format(key, value), logger)
# trajectory analysis
if config.has_section('trajectory analysis parameters'):
update_user('Starting trajectory analysis.', logger)
@@ -27,6 +27,12 @@ def test_grid_parameters(config):
return [center, edge_lengths, name]


def point_properties_parameters(config):
point = [float(x.strip()) for x in config.get('point properties parameters', 'point').split(',')]
dmif_path = config.get('point properties parameters', 'dmif')
return point, dmif_path


def trajectory_analysis_parameters(config, debugging):
center = [int(x.strip()) for x in config.get('trajectory analysis parameters', 'center').split(',')]
edge_lengths = [int(x.strip()) for x in config.get('trajectory analysis parameters', 'edge lengths').split(',')]
@@ -7,6 +7,7 @@


# python standard library
from collections import OrderedDict
import copy
import operator
import pickle
@@ -126,3 +127,13 @@ def generate_dmif_excess(dmif1_path, dmif2_path):
else:
print('Specified dmifs were not generated with the same grid parameters.')
sys.exit()


def get_point_properties(point, dmif_path):
with open(dmif_path, 'rb') as file:
dmif = pickle.load(file)
point_properties = dmif[(dmif['x'] == point[0]) & (dmif['y'] == point[1]) & (dmif['z'] == point[2])]
point_properties_dict = OrderedDict()
for point_property in point_properties.dtype.names:
point_properties_dict[point_property] = round(point_properties[point_property][0], 2)
return point_properties_dict
@@ -376,7 +376,7 @@
'pi': 10, 'hi': 11, 'hi_norm': 12, 'ai': 13, 'tw': 14, 'h2o': 15}
grid_list_dict = {'ha': 0, 'hd': 1, 'ha2': 2, 'hd2': 3, 'hda': 4, 'ai': 5}
feature_types = ('ai', 'ha2', 'hd2', 'hda', 'ha', 'hd', 'hi', 'pi', 'ni')
__version__ = '0.7.3' # PyRod version
__version__ = '0.7.4' # PyRod version
terminal_width = shutil.get_terminal_size()[0]
logo = ('',
'{:^{width}}'.format(' |X| ', width=terminal_width),

0 comments on commit e204653

Please sign in to comment.
You can’t perform that action at this time.