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

Skip empty features #140

Merged
merged 49 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e251f8d
Update README.md
LilySnow May 7, 2019
b8cb334
Update .gitignore
CunliangGeng Jul 8, 2019
7df93d1
Update issue templates
CunliangGeng Feb 20, 2020
caf5de5
Merge pull request #124 from DeepRank/CunliangGeng-patch-1
CunliangGeng Feb 20, 2020
476ad17
Update issue templates
CunliangGeng Feb 20, 2020
08d8d82
change to _close() for pdb2sql
NicoRenaud Mar 24, 2020
488377e
install align branch of pdb2sql
NicoRenaud Mar 24, 2020
f4e7b89
choose chains in interface align
NicoRenaud Mar 24, 2020
19a43bc
remove possible - in molname
NicoRenaud Mar 25, 2020
34c7979
export optional in DataGenerator
NicoRenaud Mar 25, 2020
970e17d
fixed data augmentation
NicoRenaud Mar 25, 2020
684ce11
Update generate_dataset.py
NicoRenaud Mar 25, 2020
4ff7834
call Rscript from plot_utils.py instead of r2py
LilySnow Mar 26, 2020
5c33022
change install for new pdb2sql
NicoRenaud Mar 31, 2020
6c77a0a
syntax
NicoRenaud Mar 31, 2020
fd01c21
align in doc
NicoRenaud Mar 31, 2020
31a6110
added test
NicoRenaud Mar 31, 2020
7504da7
fix typo
NicoRenaud Mar 31, 2020
5f68419
fix code reviews
NicoRenaud Mar 31, 2020
5a90e9c
doc for itnerface alignement
NicoRenaud Mar 31, 2020
0711263
Merge pull request #130 from DeepRank/align
NicoRenaud Mar 31, 2020
954a271
Merge branch 'master' into development
NicoRenaud Mar 31, 2020
97ea093
Merge pull request #131 from DeepRank/development
NicoRenaud Mar 31, 2020
7d7f5fc
versioning
NicoRenaud Mar 31, 2020
4a19926
fixed setup
NicoRenaud Mar 31, 2020
22fdb4f
add doi
NicoRenaud Mar 31, 2020
243a48d
Bump freesasa from 2.0.3.post7 to 2.0.5
dependabot-preview[bot] Apr 1, 2020
61728d3
Merge pull request #132 from DeepRank/dependabot/pip/freesasa-2.0.5
CunliangGeng Apr 1, 2020
cc4ce73
Update torch requirement from <1.4.0 to <1.5.0
dependabot-preview[bot] Apr 1, 2020
106d80f
remove torch version restriction
CunliangGeng Apr 1, 2020
a4d203f
Merge pull request #133 from DeepRank/dependabot/pip/torch-lt-1.5.0
CunliangGeng Apr 1, 2020
008852d
Merge pull request #134 from DeepRank/master
CunliangGeng Apr 1, 2020
74ba813
ignore build and dist
NicoRenaud Apr 2, 2020
4d1ffbd
Merge branch 'master' of https://github.com/DeepRank/deeprank
NicoRenaud Apr 2, 2020
47fc92b
added align existing pdb in hdf5
NicoRenaud Apr 3, 2020
f2d572b
removed NaivePSSM
NicoRenaud Apr 3, 2020
4485712
docstring of realign
NicoRenaud Apr 3, 2020
8bbf37d
removed mapped features
NicoRenaud Apr 3, 2020
eb7d6b5
Merge pull request #137 from DeepRank/realign_hdf5
NicoRenaud Apr 3, 2020
1e61cda
add ploting R code to util
LilySnow Apr 4, 2020
7e10e3f
do not crash when missing CA/CB atoms
NicoRenaud Apr 6, 2020
d278b9d
fixed error message
NicoRenaud Apr 6, 2020
0810416
fixed test generate
NicoRenaud Apr 6, 2020
373ccda
Merge pull request #141 from DeepRank/test_realign
NicoRenaud Apr 6, 2020
e3e50a7
Merge branch 'development' of https://github.com/DeepRank/deeprank in…
NicoRenaud Apr 6, 2020
79d4c15
fix tet generate
NicoRenaud Apr 6, 2020
1564d11
intoduced get_residue_center
NicoRenaud Apr 10, 2020
ffc29f4
clean up
NicoRenaud Apr 10, 2020
1c35cb7
fix import and uncomment tests
NicoRenaud Apr 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**Environment:**
- OS system:
- Version:
- Branch commit ID:
- Inputs:

**To Reproduce**
Steps/commands to reproduce the behaviour:
1.
2.
3.

**Expected Results**
A clear and concise description of what you expected to happen.

**Actual Results or Error Info**
If applicable, add screenshots to help explain your problem.

**Additional Context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Byte-compiled / optimized
*__pycache__*



# distribution
deeprank.egg-info
database*
dist
build

# specific architure files
deeprank/learn/arch_*
Expand Down Expand Up @@ -44,10 +48,15 @@ test/*.pdb
#docs/_static
#docs/_templates


# vscode setting
.vscode

.DS_Store
test/1AK4/atomic_features/test_1AK4_100w.dat
test/2OUL/atomic_features/test_2OUL_1.dat
test/atomic_pair_interaction.dat

# Mac OSX files
.DS_Store

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ before_install:
# Useful for debugging any issues with conda
- conda info -a

# python
# python
- conda install python=3.7

# install openmpi for mpi4py
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://secure.travis-ci.org/DeepRank/deeprank.svg?branch=master)](https://travis-ci.org/DeepRank/deeprank)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9252e59633cf46a7ada0c3c614c175ea)](https://www.codacy.com/app/NicoRenaud/deeprank?utm_source=github.com&utm_medium=referral&utm_content=DeepRank/deeprank&utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/DeepRank/deeprank/badge.svg?branch=master)](https://coveralls.io/github/DeepRank/deeprank?branch=master)
[![Documentation Status](https://readthedocs.org/projects/deeprank/badge/?version=latest)](http://deeprank.readthedocs.io/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/deeprank/badge/?version=latest)](http://deeprank.readthedocs.io/?badge=latest) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3735042.svg)](https://doi.org/10.5281/zenodo.3735042)

The documentation of the module can be found on readthedocs :
<http://deeprank.readthedocs.io/en/latest/>
Expand All @@ -16,12 +16,14 @@ The documentation of the module can be found on readthedocs :

Minimal information to install the module


- clone the repository `git clone https://github.com/DeepRank/deeprank.git`
- go there `cd deeprank`
- install the module `pip install -e ./`
- go int the test dir `cd test`
- run the test suite `pytest`


## 2 . 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 :
Expand Down
2 changes: 1 addition & 1 deletion deeprank/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.1'
__version__ = '0.1.0'
4 changes: 2 additions & 2 deletions deeprank/features/AtomicFeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, pdbfile, param_charge=None, param_vdw=None,
>>> atfeat.evaluate_pair_interaction(save_interactions=test_name)
>>>
>>> # close the db
>>> atfeat.sqldb.close()
>>> atfeat.sqldb._close()
"""

super().__init__("Atomic")
Expand Down Expand Up @@ -939,7 +939,7 @@ def __compute_feature__(pdb_data, featgrp, featgrp_raw):
atfeat.export_data_hdf5(featgrp_raw)

# close
atfeat.sqldb.close()
atfeat.sqldb._close()


########################################################################
Expand Down
16 changes: 6 additions & 10 deletions deeprank/features/BSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, pdb_data, chainA='A', chainB='B'):
>>> bsa = BSA('1AK4.pdb')
>>> bsa.get_structure()
>>> bsa.get_contact_residue_sasa()
>>> bsa.sql.close()
>>> bsa.sql._close()
"""
self.pdb_data = pdb_data
self.sql = pdb2sql.interface(pdb_data)
Expand Down Expand Up @@ -117,13 +117,9 @@ def get_contact_residue_sasa(self, cutoff=5.5):
# define the xyz key : (chain,x,y,z)
chain = {'A': 0, 'B': 1}[res[0]]

atcenter = 'CB'
if res[2] == 'GLY':
atcenter = 'CA'
xyz = self.sql.get(
'x,y,z', resSeq=res[1], chainID=res[0], name=atcenter)[0]
# xyz = np.mean(self.sql.get('x,y,z',resSeq=r[1],chainID=r[0]),0)
xyzkey = tuple([chain] + xyz)
# get the center
_, xyz = self.get_residue_center(self.sql, res=res)
xyzkey = tuple([chain] + xyz[0])

# put the data in dict
self.bsa_data[res] = [bsa]
Expand Down Expand Up @@ -156,7 +152,7 @@ def __compute_feature__(pdb_data, featgrp, featgrp_raw):
bsa.export_data_hdf5(featgrp_raw)

# close the file
bsa.sql.close()
bsa.sql._close()


########################################################################
Expand All @@ -177,7 +173,7 @@ def __compute_feature__(pdb_data, featgrp, featgrp_raw):
bsa = BSA(pdb_file)
bsa.get_structure()
bsa.get_contact_residue_sasa()
bsa.sql.close()
bsa.sql._close()

pprint(bsa.feature_data)
print()
Expand Down
121 changes: 96 additions & 25 deletions deeprank/features/FeatureClass.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import numpy as np


class FeatureClass(object):

def __init__(self, feature_type):
"""Master class from which all the other feature classes should be
derived.
"""Master class from which all the other feature classes should be derived.

Arguments
feature_type(str): 'Atomic' or 'Residue'

Notes:
Each subclass must compute:

- self.feature_data: dictionary of features in
Expand All @@ -28,22 +30,25 @@ def __init__(self, feature_type):
{'coulomb': data_dict_clb, 'vdwaals': data_dict_vdw}
data_dict_clb = {xyz_info: [values]}
xyz_info = (chainNum, x, y, z)

Args:
feature_type(str): 'Atomic' or 'Residue'
"""

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

def export_data_hdf5(self, featgrp):
"""Export the data in human readable format to HDF5's group.

- 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]}
"""Export the data in xyz-val format in an HDF5 file group.

Arguments:
featgrp {[hdf5_group]} -- The hdf5 group of the feature

Notes:
- 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 @@ -84,22 +89,14 @@ def export_data_hdf5(self, featgrp):
else:
featgrp.create_dataset(name + '_raw', data=ds)

########################################
#
# export the data in an HDF5 file group
# the format of the data is here
# PRO : fast when mapping
# CON : only usefull for deeprank
#
########################################


def export_dataxyz_hdf5(self, featgrp):
"""Export the data in xyz-val format in an HDF5 file group.

For atomic and residue the format of the data must be:
{(chainNum(0 or 1), x, y, z): [values]}
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 @@ -112,3 +109,77 @@ def export_dataxyz_hdf5(self, featgrp):
old[...] = ds
else:
featgrp.create_dataset(name, data=ds)

@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)
"""

# get all residues if None were provided
# [chainID, resName, resSeq]
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]

# 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',
chainID=r[0],
resSeq=r[1],
resName=r[2],
name=ctr)

elif ctr == 'mean':
xyz_res = [np.mean(sql.get('x,y,z',
chainID=r[0],
resSeq=r[1],
resName=r[2]),axis=0).tolist()]

else:
raise ValueError('Center %s not recognized' %c)

if len(xyz_res) == 0:
continue

elif len(xyz_res) == 1:
xyz.append(xyz_res[0])
break

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

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

return res, xyz

10 changes: 3 additions & 7 deletions deeprank/features/FullPSSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ def get_feature_value(self, cutoff=5.5):
sql = pdb2sql.interface(self.pdb_file)

# set achors for all residues and get their xyz
xyz_info = sql.get('chainID,resSeq,resName', name='CB')
xyz_info += sql.get('chainID,resSeq,resName', name='CA',
resName='GLY')

xyz = sql.get('x,y,z', name='CB')
xyz += sql.get('x,y,z', name='CA', resName='GLY')
xyz_info, xyz = self.get_residue_center(sql)

xyz_dict = {}
for pos, info in zip(xyz, xyz_info):
Expand All @@ -180,7 +175,7 @@ def get_feature_value(self, cutoff=5.5):
# get interface contact residues
# ctc_res = {"A":[chain 1 residues], "B": [chain2 residues]}
ctc_res = sql.get_contact_residues(cutoff=cutoff)
sql.close()
sql._close()
ctc_res = ctc_res["A"] + ctc_res["B"]

# handle with small interface or no interface
Expand Down Expand Up @@ -212,6 +207,7 @@ def get_feature_value(self, cutoff=5.5):
f"{self.mol_name}: The following interface residues have "
f" no pssm value:\n {ctc_res_wo_pssm}"
)

else:
ctc_res_with_pssm = ctc_res

Expand Down
Loading