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

Add PandasPdb.read_pdb_from_list method + unit test #72

Merged
merged 3 commits into from
Oct 22, 2020
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
18 changes: 18 additions & 0 deletions biopandas/pdb/pandas_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ def read_pdb(self, path):
self.header, self.code = self._parse_header_code()
return self

def read_pdb_from_list(self, pdb_lines):
"""Reads PDB file from a list into DataFrames

Attributes
----------
pdb_lines : list
A list of lines containing the pdb file contents.

Returns
---------
self

"""
self.pdb_text = ''.join(pdb_lines)
self._df = self._construct_df(pdb_lines)
self.header, self.code = self._parse_header_code()
return self

def fetch_pdb(self, pdb_code):
"""Fetches PDB file contents from the Protein Databank at rcsb.org.

Expand Down
11 changes: 11 additions & 0 deletions biopandas/pdb/tests/test_read_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ def test_read_pdb():
assert ppdb.pdb_path == TESTDATA_FILENAME


def test_read_pdb_from_list():
"""Test public read_pdb_from_list"""

for pdb_text, code in zip([three_eiy, four_eiy], ['3eiy', '4eiy']):
ppdb = PandasPdb()
ppdb.read_pdb_from_list(pdb_text.splitlines(True))
assert ppdb.pdb_text == pdb_text
assert ppdb.code == code
assert ppdb.pdb_path == ''


def test_anisou_input_handling():
"""Test public read_pdb"""
ppdb = PandasPdb()
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/api_subpackages/biopandas.mol2.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biopandas version: 0.2.6
biopandas version: 0.2.7
## PandasMol2

*PandasMol2()*
Expand Down
18 changes: 17 additions & 1 deletion docs/sources/api_subpackages/biopandas.pdb.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biopandas version: 0.2.6
biopandas version: 0.2.7
## PandasPdb

*PandasPdb()*
Expand Down Expand Up @@ -229,6 +229,22 @@ self

<hr>

*read_pdb_from_list(pdb_lines)*

Reads PDB file from a list into DataFrames

**Attributes**

- `pdb_lines` : list

A list of lines containing the pdb file contents.

**Returns**

self

<hr>

*rmsd(df1, df2, s=None, invert=False)*

Compute the Root Mean Square Deviation between molecules.
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/api_subpackages/biopandas.testutils.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biopandas version: 0.2.6
biopandas version: 0.2.7
## assert_raises

*assert_raises(exception_type, message, func, *args, **kwargs)*
Expand Down
158 changes: 70 additions & 88 deletions docs/tutorials/Working_with_MOL2_Structures_in_DataFrames.ipynb

Large diffs are not rendered by default.

Loading