Skip to content

Commit

Permalink
Minor changes and added missing tests for the RSA functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
biomadeira committed Sep 26, 2017
1 parent 19c722f commit ac74dd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions prointvar/dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from prointvar.pdbx import PDBXreader
from prointvar.pdbx import PDBXwriter

from prointvar.utils import compute_rsa
from prointvar.utils import get_rsa
from prointvar.utils import get_rsa_class
from prointvar.utils import row_selector
from prointvar.utils import lazy_file_remover
Expand Down Expand Up @@ -272,8 +272,8 @@ def add_dssp_rsa(data, method="Sander"):
table = data
rsas = []
for i in table.index:
rsas.append(compute_rsa(table.loc[i, "ACC"], table.loc[i, "AA"],
method=method))
rsas.append(get_rsa(table.loc[i, "ACC"], table.loc[i, "AA"],
method=method))
table["RSA"] = rsas
return table

Expand Down
2 changes: 1 addition & 1 deletion prointvar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def get_rsa_class(rsa):
return rsa_class


def compute_rsa(acc, resname, method="Sander"):
def get_rsa(acc, resname, method="Sander"):
"""
Computes Relative Solvent Accessibility (RSA) from an input
DSSP ACC value, and according to ASA standard values.
Expand Down
22 changes: 22 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from prointvar.utils import get_start_end_ranges_consecutive_ints
from prointvar.utils import constrain_column_types
from prointvar.utils import exclude_columns
from prointvar.utils import get_rsa
from prointvar.utils import get_rsa_class

from prointvar.config import config as c

Expand Down Expand Up @@ -159,6 +161,8 @@ def setUp(self):
{'label': '5', 'value': 5, 'type': 0.32}])
self.constrain_column_types = constrain_column_types
self.exclude_columns = exclude_columns
self.get_rsa = get_rsa
self.get_rsa_class = get_rsa_class

logging.disable(logging.DEBUG)

Expand Down Expand Up @@ -194,6 +198,8 @@ def tearDown(self):
self.mock_df = None
self.constrain_column_types = None
self.exclude_columns = None
self.get_rsa = None
self.get_rsa_class = None

logging.disable(logging.NOTSET)

Expand Down Expand Up @@ -542,6 +548,22 @@ def test_exclude_columns(self):
self.assertEqual(len(self.mock_df.columns), 2)
self.assertNotIn("type", self.mock_df)

def test_get_rsa(self):
rsa = self.get_rsa(10.0, "A", method="Sander")
self.assertEqual(9.434, rsa)
rsa = self.get_rsa(20.0, "A", method="Miller")
self.assertEqual(17.699, rsa)
rsa = self.get_rsa(30.0, "A", method="Wilke")
self.assertEqual(23.256, rsa)

def test_get_rsa_class(self):
rsa_class = self.get_rsa_class(25.5)
self.assertEqual('Surface', rsa_class)
rsa_class = self.get_rsa_class(7.5)
self.assertEqual('Part. Exposed', rsa_class)
rsa_class = self.get_rsa_class(1.5)
self.assertEqual('Core', rsa_class)


if __name__ == '__main__':
logging.basicConfig(stream=sys.stderr)
Expand Down

0 comments on commit ac74dd2

Please sign in to comment.