-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arian Jamasb
committed
Jul 8, 2024
1 parent
21a6080
commit e3234f3
Showing
4 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
""" Class for working with Tripos MOL2 files""" | ||
|
||
# BioPandas | ||
# Author: Sebastian Raschka <[email protected]> | ||
# License: BSD 3 clause | ||
# Project Website: http://rasbt.github.io/biopandas/ | ||
# Code Repository: https://github.com/rasbt/biopandas | ||
|
||
import pandas as pd | ||
import numpy as np | ||
from .mol2_io import split_multimol2 | ||
import pandas as pd | ||
|
||
from .mol2_io import split_multimol2 | ||
|
||
COLUMN_NAMES = ( | ||
"atom_id", | ||
|
@@ -167,7 +168,9 @@ def read_mol2_from_list(self, mol2_lines, mol2_code, columns=None): | |
def _construct_df(self, mol2_lines, col_names, col_types): | ||
"""Construct DataFrames from list of PDB lines.""" | ||
return self._atomsection_to_pandas( | ||
self._get_atomsection(mol2_lines), col_names=col_names, col_types=col_types | ||
self._get_atomsection(mol2_lines), | ||
col_names=col_names, | ||
col_types=col_types, | ||
) | ||
|
||
@staticmethod | ||
|
@@ -195,7 +198,9 @@ def _get_atomsection(mol2_lst): | |
@staticmethod | ||
def _atomsection_to_pandas(mol2_atom_lst, col_names, col_types): | ||
|
||
df = pd.DataFrame([lst.split() for lst in mol2_atom_lst], columns=col_names) | ||
df = pd.DataFrame( | ||
[lst.split() for lst in mol2_atom_lst], columns=col_names | ||
) | ||
|
||
for i in range(df.shape[1]): | ||
df[col_names[i]] = df[col_names[i]].astype(col_types[i]) | ||
|
@@ -281,4 +286,6 @@ def distance_df(df, xyz=(0.00, 0.00, 0.00)): | |
""" | ||
|
||
return np.sqrt(np.sum(df[["x", "y", "z"]].subtract(xyz, axis=1) ** 2, axis=1)) | ||
return np.sqrt( | ||
np.sum(df[["x", "y", "z"]].subtract(xyz, axis=1) ** 2, axis=1) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
""" Utility function for reading Tripos MOL2 files from files""" | ||
|
||
# BioPandas | ||
# Author: Sebastian Raschka <[email protected]> | ||
# License: BSD 3 clause | ||
# Project Website: http://rasbt.github.io/biopandas/ | ||
# Code Repository: https://github.com/rasbt/biopandas | ||
|
||
import os | ||
|
||
from biopandas.mol2 import PandasMol2 | ||
from biopandas.mol2.mol2_io import split_multimol2 | ||
from biopandas.testutils import assert_raises | ||
|
@@ -48,7 +50,9 @@ def test_read_mol2_from_list(): | |
data_path = os.path.join(this_dir, "data", "40_mol2_files.mol2") | ||
mol2 = next(split_multimol2(data_path)) | ||
|
||
pdmol = PandasMol2().read_mol2_from_list(mol2_lines=mol2[1], mol2_code=mol2[0]) | ||
pdmol = PandasMol2().read_mol2_from_list( | ||
mol2_lines=mol2[1], mol2_code=mol2[0] | ||
) | ||
assert pdmol.df.shape == (65, 9) | ||
assert pdmol.code == "ZINC38611810" | ||
|
||
|