From 03a24370b02f80b3e3cff1cd3db32a1030844ccb Mon Sep 17 00:00:00 2001 From: rasbt Date: Tue, 6 Apr 2021 21:46:02 -0500 Subject: [PATCH] allow .ent & .ent.gz file extensions --- biopandas/__init__.py | 2 +- biopandas/pdb/pandas_pdb.py | 8 +++++--- biopandas/pdb/tests/test_read_pdb.py | 4 ++-- docs/CHANGELOG.md | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/biopandas/__init__.py b/biopandas/__init__.py index e0d1220..e95eebc 100644 --- a/biopandas/__init__.py +++ b/biopandas/__init__.py @@ -24,5 +24,5 @@ # 'X.Y.dev0' is the canonical version of 'X.Y.dev' # -__version__ = '0.2.8' +__version__ = '0.2.9dev' __author__ = "Sebastian Raschka " diff --git a/biopandas/pdb/pandas_pdb.py b/biopandas/pdb/pandas_pdb.py index 99b1f9e..05dea3d 100644 --- a/biopandas/pdb/pandas_pdb.py +++ b/biopandas/pdb/pandas_pdb.py @@ -263,14 +263,16 @@ def _init_get_dict(): def _read_pdb(path): """Read PDB file from local drive.""" r_mode = 'r' - if path.endswith('.pdb'): + if path.endswith(('.pdb', '.ent')): openf = open - elif path.endswith('pdb.gz'): + elif path.endswith(('pdb.gz', '.ent.gz')): r_mode = 'rb' openf = gzip.open else: + allowed_formats = ", ".join(('.pdb', '.pdb.gz', '.ent', '.ent.gz')) raise ValueError( - 'Wrong file format; allowed file formats are .pdb and .pdb.gz.' + ('Wrong file format; allowed file formats are %s' + % allowed_formats) ) with openf(path, r_mode) as f: diff --git a/biopandas/pdb/tests/test_read_pdb.py b/biopandas/pdb/tests/test_read_pdb.py index c1b7eb4..cec1e85 100644 --- a/biopandas/pdb/tests/test_read_pdb.py +++ b/biopandas/pdb/tests/test_read_pdb.py @@ -61,8 +61,8 @@ def test__read_pdb_raises(): """Test private _read_pdb: Test if ValueError is raised for wrong file formats.""" - expect = ('Wrong file format; allowed file formats' - ' are .pdb and .pdb.gz.') + expect = ('Wrong file format; allowed file formats are ' + '.pdb, .pdb.gz, .ent, .ent.gz') def run_code_1(): PandasPdb()._read_pdb("protein.mol2") diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 84236cf..6d9bd9d 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,25 @@ The CHANGELOG for the current development version is available at [https://github.com/rasbt/biopandas/blob/master/docs/sources/CHANGELOG.md](https://github.com/rasbt/biopandas/blob/master/docs/sources/CHANGELOG.md). +### 0.2.9 (TBD) + +##### Downloads + +- - +- - + +##### New Features + +- - + +##### Changes + +- Now also allow `.ent` and `.ent.gz` file endings for PDB files. (via PR [82](https://github.com/rasbt/biopandas/pull/82/files) + +##### Bug Fixes + +- - + ### 0.2.8 (03-30-2021) ##### Downloads