Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
fix doc warnings on docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Jan 20, 2021
1 parent 7fdd458 commit df76e63
Show file tree
Hide file tree
Showing 28 changed files with 227 additions and 237 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ To check if installation is successful, you can run a test

## Tutorial

We give here the tutorial like introduction to the DeepRank machinery. More informatoin can be found in the documentation <http://deeprank.readthedocs.io/en/latest/>. We quickly illsutrate here the two main steps of Deeprank :
We give here the tutorial like introduction to the DeepRank machinery. More informatoin can be found in the documentation <http://deeprank.readthedocs.io/en/latest/>. We quickly illsutrate here the two main steps of Deeprank:

- the generation of the data
- running deep leaning experiments.
Expand Down Expand Up @@ -118,8 +118,8 @@ database.create_database(prog_bar=True)

# define the 3D grid
grid_info = {
'number_of_points' : [30,30,30],
'resolution' : [1.,1.,1.],
'number_of_points': [30,30,30],
'resolution': [1.,1.,1.],
'atomic_densities': {'C': 1.7, 'N': 1.55, 'O': 1.52, 'S': 1.8},
}

Expand All @@ -139,17 +139,17 @@ In the first part of the script we define the path where to find the PDBs of th

We then initialize the `DataGenerator` object. This object (defined in `deeprank/generate/DataGenerator.py`) needs a few input parameters:

- pdb_source : where to find the pdb to include in the dataset
- pdb_native : where to find the corresponding native conformations
- compute_targets : list of modules used to compute the targets
- compute_features : list of modules used to compute the features
- hdf5 : Name of the HDF5 file to store the data set
- pdb_source: where to find the pdb to include in the dataset
- pdb_native: where to find the corresponding native conformations
- compute_targets: list of modules used to compute the targets
- compute_features: list of modules used to compute the features
- hdf5: Name of the HDF5 file to store the data set

We then create the data base with the command `database.create_database()`. This function autmatically create an HDF5 files where each pdb has its own group. In each group we can find the pdb of the complex and its native form, the calculated features and the calculated targets. We can now mapped the features to a grid. This is done via the command `database.map_features()`. As you can see this method requires a dictionary as input. The dictionary contains the instruction to map the data.

- number_of_points: the number of points in each direction
- resolution : the resolution in Angs
- atomic_densities : {'atom_name' : vvdw_radius} the atomic densities required
- resolution: the resolution in Angs
- atomic_densities: {'atom_name': vvdw_radius} the atomic densities required

The atomic densities are mapped following the [protein-ligand paper](https://arxiv.org/abs/1612.02751). The other features are mapped to the grid points using a Gaussian function (other modes are possible but somehow hard coded)

Expand Down
22 changes: 11 additions & 11 deletions deeprank/features/AtomicFeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def __init__(self, pdbfile, chain1='A', chain2='B', param_charge=None,
param_charge (str): file name of the force field file
containing the charges e.g. protein-allhdg5.4_new.top.
Must be of the format:
* CYM atom O type=O charge=-0.500 end
* ALA atom N type=NH1 charge=-0.570 end
* CYM atom O type=O charge=-0.500 end
* ALA atom N type=NH1 charge=-0.570 end
param_vdw (str): file name of the force field containing
vdw parameters e.g. protein-allhdg5.4_new.param.
Must be of the format:
* NONBonded CYAA 0.105 3.750 0.013 3.750
* NONBonded CCIS 0.105 3.750 0.013 3.750
* NONBonded CYAA 0.105 3.750 0.013 3.750
* NONBonded CCIS 0.105 3.750 0.013 3.750
patch_file (str): file name of a valid patch file for
the parameters e.g. patch.top.
Expand Down Expand Up @@ -112,11 +112,11 @@ def __init__(self, pdbfile, chain1='A', chain2='B', param_charge=None,
def read_charge_file(self):
"""Read the .top file given in entry.
This function creates :
This function creates:
- self.charge : dictionary {(resname,atname):charge}
- self.valid_resnames : list ['VAL','ALP', .....]
- self.at_name_type_convertor : dict {(resname,atname):attype}
- self.charge: dictionary {(resname,atname):charge}
- self.valid_resnames: list ['VAL','ALP', .....]
- self.at_name_type_convertor: dict {(resname,atname):attype}
"""

with open(self.param_charge) as f:
Expand Down Expand Up @@ -159,8 +159,8 @@ def read_patch(self):
This function creates
- self.patch_charge : Dict {(resName,atName) : charge}
- self.patch_type : Dict {(resName,atName) : type}
- self.patch_charge: Dict {(resName,atName): charge}
- self.patch_type : Dict {(resName,atName): type}
"""

with open(self.patch_file) as f:
Expand Down Expand Up @@ -197,7 +197,7 @@ def read_vdw_file(self):
This function creates
- self.vdw : dictionary {attype:[E1,S1]}
- self.vdw: dictionary {attype:[E1,S1]}
"""

with open(self.param_vdw) as f:
Expand Down
2 changes: 1 addition & 1 deletion deeprank/features/BSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_contact_residue_sasa(self, cutoff=5.5):
# define the bsa
bsa = asa_unbound - asa_complex

# define the xyz key : (chain,x,y,z)
# define the xyz key: (chain,x,y,z)
chain = {self.chain1: 0, self.chain2: 1}[res[0]]

# get the center
Expand Down
81 changes: 37 additions & 44 deletions deeprank/features/FeatureClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,41 @@ def __init__(self, feature_type):
Arguments
feature_type(str): 'Atomic' or 'Residue'
Notes:
Note:
Each subclass must compute:
- self.feature_data: dictionary of features in
human readable format, e.g.
for atomic features:
{'coulomb': data_dict_clb, 'vdwaals': data_dict_vdw}
data_dict_clb = {atom_info: [values]}
atom_info = (chainID, resSeq, resName, name)
for residue features:
{'PSSM_ALA': data_dict_pssmALA, ...}
data_dict_pssmALA = {residue_info: [values]}
residue_info = (chainID, resSeq, resName, name)
- self.feature_data_xyz: dictionary of features in
xyz-val format, e.g.
{'coulomb': data_dict_clb, 'vdwaals': data_dict_vdw}
data_dict_clb = {xyz_info: [values]}
xyz_info = (chainNum, x, y, z)
- self.feature_data: dictionary of features in human readable format, e.g.
- for atomic features:
- {'coulomb': data_dict_clb, 'vdwaals': data_dict_vdw}
- data_dict_clb = {atom_info: [values]}
- atom_info = (chainID, resSeq, resName, name)
- for residue features:
- {'PSSM_ALA': data_dict_pssmALA, ...}
- data_dict_pssmALA = {residue_info: [values]}
- residue_info = (chainID, resSeq, resName, name)
- self.feature_data_xyz: dictionary of features in xyz-val format, e.g.
- {'coulomb': data_dict_clb, 'vdwaals': data_dict_vdw}
- data_dict_clb = {xyz_info: [values]}
- xyz_info = (chainNum, x, y, z)
"""

self.type = feature_type
self.feature_data = {}
self.feature_data_xyz = {}

def export_data_hdf5(self, featgrp):
"""Export the data in xyz-val format in an HDF5 file group.
Arguments:
featgrp {[hdf5_group]} -- The hdf5 group of the feature
Notes:
Note:
- For atomic features, the format of the data must be:
{(chainID, resSeq, resName, name): [values]}
- For residue features, the format must be:
{(chainID, resSeq, resName): [values]}
"""

# loop through the datadict and name
for name, data in self.feature_data.items():

Expand Down Expand Up @@ -89,14 +83,14 @@ def export_data_hdf5(self, featgrp):
else:
featgrp.create_dataset(name + '_raw', data=ds)


def export_dataxyz_hdf5(self, featgrp):
"""Export the data in xyz-val format in an HDF5 file group.
Arguments:
featgrp {[hdf5_group]} -- The hdf5 group of the feature
"""

# loop through the datadict and name
for name, data in self.feature_data_xyz.items():

Expand All @@ -113,17 +107,17 @@ def export_dataxyz_hdf5(self, featgrp):
@staticmethod
def get_residue_center(sql, centers=['CB','CA','mean'], res=None):
"""Computes the center of each residue by trying different options
Arguments:
sql {pdb2sql} -- The pdb2sql instance
Keyword Arguments:
centers {list} -- list of strings (default: {['CB','CA','mean']})
res {list} -- list of residue to be considered ([[chainID, resSeq, resName]])
Raises:
ValueError: [description]
Returns:
[type] -- list(res), list(xyz)
"""
Expand All @@ -133,27 +127,27 @@ def get_residue_center(sql, centers=['CB','CA','mean'], res=None):
if res is None:
res = [tuple(x) for x in sql.get('chainID,resSeq,resName')]
res = sorted(set(res), key=res.index)


# make sure that we have a list of res
# even if ony 1 res was provided
# res=[chainID, resSeq, resName] -> res=[[chainID, resSeq, resName]]
elif not isinstance(res[0],list):
res = [res]
res = [res]

# make sure that we have a list of possible centers
if not isinstance(centers,list):
centers = list(centers)

xyz = []

for r in res:

for ctr in centers:

if ctr in ['CB','CA']:
xyz_res = sql.get('x,y,z',

xyz_res = sql.get('x,y,z',
chainID=r[0],
resSeq=r[1],
resName=r[2],
Expand All @@ -177,9 +171,8 @@ def get_residue_center(sql, centers=['CB','CA','mean'], res=None):

else:
raise ValueError('Residue center not found')

if len(xyz) == 0:
raise ValueError('Center not found')

return res, xyz

2 changes: 1 addition & 1 deletion deeprank/features/ResidueDensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ResidueDensity(FeatureClass):
def __init__(self, pdb_data, chain1='A', chain2='B'):
"""Compute the residue contacts between polar/apolar/charged residues.
Args :
Args:
pdb_data (list(byte) or str): pdb data or pdb filename
chain1 (str): First chain ID. Defaults to 'A'
chain2 (str): Second chain ID. Defaults to 'B'
Expand Down
Loading

0 comments on commit df76e63

Please sign in to comment.