Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow .ent & .ent.gz file extensions #82

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion biopandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mail@sebastianraschka.com>"
8 changes: 5 additions & 3 deletions biopandas/pdb/pandas_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions biopandas/pdb/tests/test_read_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 19 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down