Skip to content

Commit fd0572e

Browse files
authored
Merge pull request #317 from debbiemarkslab/pdb_and_setup_fixes
Pdb and setup fixes
2 parents 7568749 + f272939 commit fd0572e

8 files changed

Lines changed: 103 additions & 153 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ jobs:
2727
conda info -a
2828
conda create -q -n test-environment python=${{ matrix.python-version }} numpy scipy numba pandas matplotlib
2929
source activate test-environment
30-
- name: Run setup.py
30+
- name: Install Hatch
31+
uses: pypa/hatch@install
32+
- name: Build and install package
3133
run: |
32-
pip install build
33-
python setup.py sdist --formats=zip -k
34-
python -m build
35-
find ./dist -iname "*.zip" -print0 | xargs -0 pip install
34+
hatch build
35+
find ./dist -iname "*.tar.gz" -print0 | xargs -0 pip install
3636
pip install codecov
3737
- name: Download test files
3838
run: |

.github/workflows/build_test_and_push.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ jobs:
2828
conda info -a
2929
conda create -q -n test-environment python=${{ matrix.python-version }} numpy scipy numba pandas matplotlib
3030
source activate test-environment
31-
- name: Run setup.py
31+
- name: Install Hatch
32+
uses: pypa/hatch@install
33+
- name: Build and install package
3234
run: |
33-
python setup.py sdist --formats=zip -k
34-
find ./dist -iname "*.zip" -print0 | xargs -0 pip install
35+
hatch build
36+
find ./dist -iname "*.tar.gz" -print0 | xargs -0 pip install
3537
pip install codecov
3638
- name: Download test files
3739
run: |
@@ -42,14 +44,8 @@ jobs:
4244
with:
4345
run: coverage run -m unittest discover -s test -p "Test*.py"
4446
working-directory: ./ #optional
45-
- name: Publish evcouplings to test PyPI
46-
if: startsWith(github.ref, 'refs/tags')
47-
uses: pypa/gh-action-pypi-publish@master
48-
with:
49-
password: ${{ secrets.PYPI_ACCESS_TOKEN_TEST }}
50-
repository_url: https://test.pypi.org/legacy/
5147
- name: Publish evcouplings to PyPI
52-
if: startsWith(github.ref, 'refs/tags')
53-
uses: pypa/gh-action-pypi-publish@master
48+
uses: pypa/gh-action-pypi-publish@v1.9.0
5449
with:
50+
user: __token__
5551
password: ${{ secrets.PYPI_ACCESS_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ __pycache__
55
*.ipynb_checkpoints*
66
notebooks_dev/*
77
evcouplings.egg-info/*
8+
/dist/

MANIFEST.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

evcouplings/compare/pdb.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ def __init__(self, filehandle, keep_full_data=False):
470470
"_atom_site.pdbx_formal_charge": "charge",
471471
}
472472

473-
HELIX_TARGET_COLS = {
473+
# full list of conf types: https://mmcif.wwpdb.org/dictionaries/mmcif_ma.dic/Items/_struct_conf_type.id.html;
474+
# mapping between file types: https://manpages.debian.org/unstable/dssp/mkdssp.1.en.html
475+
CONF_TARGET_COLS = {
474476
"_struct_conf.conf_type_id": "conformation_type",
475477
"_struct_conf.id": "id",
476478
# label_asym_id and label_seq_id are sufficient for merging to atom table;
@@ -508,11 +510,15 @@ def __init__(self, filehandle, keep_full_data=False):
508510
# decode information into dataframe with BioPython helper method; note this section may not be
509511
# present if no helices exist in the structure
510512
try:
511-
self.helix_table = pd.DataFrame({
512-
name: _decode(data[source_column]) for source_column, name in HELIX_TARGET_COLS.items()
513-
})
513+
self.conf_table = pd.DataFrame({
514+
name: _decode(data[source_column]) for source_column, name in CONF_TARGET_COLS.items()
515+
}).query(
516+
# there are a handful of PDB entries that have (probably wrong) secondary structure assignments
517+
# extending over more than one segment (e.g. 2bp7, 2wjv), drop these rather than raising an error
518+
"beg_label_asym_id == end_label_asym_id"
519+
)
514520
except KeyError:
515-
self.helix_table = None
521+
self.conf_table = None
516522

517523
# decode information into dataframe with BioPython helper method; note this section may not be
518524
# present if no sheets exist in the structure
@@ -526,16 +532,23 @@ def __init__(self, filehandle, keep_full_data=False):
526532
# create secondary structure table for merging to chain tables
527533
# (will only contain helix/H and strand/E, coil/C will need to be filled in)
528534
sse_raw = []
529-
for sse_type, sse_table in [
530-
("H", self.helix_table),
531-
("E", self.sheet_table)
535+
for sse_type, sse_table, sse_filter in [
536+
("H", self.conf_table, "HELX"),
537+
("E", self.sheet_table, None),
538+
# also retrieve beta strands/bridges from conf_table if available
539+
("E", self.conf_table, "STRN"),
532540
]:
533541
# skip if secondary structure element not present in PDB file at all
534542
if sse_table is None:
535543
continue
536544

545+
# filter table down to relevant entries for current secondary structure type
546+
if sse_filter is not None:
547+
sse_table = sse_table.query(
548+
f"conformation_type.str.startswith('{sse_filter}')"
549+
)
550+
537551
for _, row in sse_table.iterrows():
538-
assert row.beg_label_asym_id == row.end_label_asym_id
539552
for seq_id in range(row.beg_label_seq_id, row.end_label_seq_id + 1):
540553
sse_raw.append({
541554
"label_asym_id": row.beg_label_asym_id,
@@ -694,7 +707,7 @@ def get_chain(self, chain, model=0, is_author_id=True):
694707
# create coordinate ID from author residue ID + insertion code
695708
# (this should be unique and circumvents issues from 0 seqres values if selecting based on author chain ID)
696709
coord_id=lambda df: df.auth_seq_id.astype(str) + df.insertion_code,
697-
seqres_id=lambda df: df.label_seq_id.astype(str).replace("0", np.nan),
710+
seqres_id=lambda df: df.label_seq_id.astype(str).replace("0", pd.NA).replace("", pd.NA),
698711
one_letter_code=lambda df: df.label_comp_id.map(AA3_to_AA1, na_action="ignore"),
699712
# note that MSE will now be labeled as HETATM, which was not the case with MMTF
700713
hetatm=lambda df: df.record_type == "HETATM",
@@ -720,12 +733,13 @@ def get_chain(self, chain, model=0, is_author_id=True):
720733
how="left"
721734
)
722735
else:
736+
# initialize to pd.NA instead of np.nan or warning about assigning str to float64 column appears
723737
res_sse = res.assign(
724-
sec_struct_3state=np.nan
738+
sec_struct_3state=pd.NA
725739
)
726740

727741
res_sse.loc[
728-
res_sse.sec_struct_3state.isnull() & (res_sse.label_seq_id > 0),
742+
res_sse.sec_struct_3state.isnull() & res_sse.seqres_id.notnull(),
729743
"sec_struct_3state"
730744
] = "C"
731745

pyproject.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "evcouplings"
7+
version = "0.2.1"
8+
description = "A Framework for evolutionary couplings analysis"
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [
12+
{ name = "Thomas Hopf", email = "thomas.hopf@gmail.com" },
13+
]
14+
keywords = [
15+
"analysis",
16+
"couplings",
17+
"evolutionary",
18+
]
19+
classifiers = [
20+
"Development Status :: 4 - Beta",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: MIT License",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Topic :: Scientific/Engineering :: Bio-Informatics",
27+
]
28+
dependencies = [
29+
"billiard",
30+
"biopython>=1.84",
31+
"bokeh",
32+
"click",
33+
"filelock",
34+
"jinja2",
35+
"matplotlib",
36+
"msgpack",
37+
"numba",
38+
"numpy",
39+
"pandas",
40+
"psutil",
41+
"requests",
42+
"ruamel.yaml<0.18",
43+
"scikit-learn",
44+
"scipy",
45+
"seaborn",
46+
"setuptools>=18.2",
47+
]
48+
49+
[project.scripts]
50+
evcouplings = "evcouplings.utils.app:app"
51+
evcouplings_dbupdate = "evcouplings.utils.update_database:app"
52+
evcouplings_runcfg = "evcouplings.utils.pipeline:app"
53+
evcouplings_summarize = "evcouplings.utils.summarize:app"
54+
55+
[project.urls]
56+
Homepage = "https://github.com/debbiemarkslab/EVcouplings"
57+
58+
[tool.hatch.version]
59+
path = "evcouplings/__init__.py"
60+
61+
[tool.hatch.build.targets.sdist]
62+
include = [
63+
"/evcouplings",
64+
]

requirements.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)