Skip to content
Draft
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
37 changes: 22 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
build
dist
test*
tmp*
*.log
*.zip
*.txt
# Build artifacts
build/
dist/
*.egg-info/

# Python cache
__pycache__/
*.pyc
*.pkl
*.txt
__pycache__
data
*.csv
notebooks
*.egg-info
2024-05-09

# Runtime and temporary files
tmp*/
*.log

# BMRB data and pipeline output (large, local-only)
data/

# Local working directories
docs/
notebooks/

# Test scripts (local integration tests, not part of package)
test/

92 changes: 92 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "trizod"
version = "0.0.1"
description = "Modern disorder scores for BMRB data"
readme = "README.md"
requires-python = ">=3.9"
license = {text = "AGPL-3.0"}
authors = [
{name = "Markus Haak", email = "markus.haak@tum.de"},
{name = "Tobias Senoner", email = "tobias.senoner@tum.de"}
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Intended Audience :: Science/Research",
]
dependencies = [
"pandas",
"numpy",
"matplotlib",
"tqdm",
"pandarallel",
"pynmrstar",
"scipy",
]

[project.urls]
Repository = "https://github.com/MarkusHaak/trizod"

[project.scripts]
trizod = "trizod.trizod:main"

[tool.hatch.build.targets.wheel]
packages = ["trizod"]

[tool.hatch.build.targets.wheel.force-include]
"trizod/potenci/data" = "trizod/potenci/data"

[dependency-groups]
dev = [
"ruff",
]

[tool.ruff]
line-length = 100
indent-width = 4

# Exclude legacy code and generated files
exclude = [
"trizod/potenci/legacy",
"test",
"__pycache__",
"*.pyc",
".git",
".venv",
"build",
"dist",
]

[tool.ruff.lint]
# Enable recommended rules for scientific Python code
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
]

# Ignore specific rules that are too strict for scientific code
ignore = [
"E501", # Line too long (handled by formatter)
"N803", # Argument name should be lowercase (scientific conventions)
"N806", # Variable in function should be lowercase (scientific conventions)
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

41 changes: 0 additions & 41 deletions setup.py

This file was deleted.

83 changes: 61 additions & 22 deletions test/test_cache_equality.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,88 @@
import os,sys
import argparse
import logging
import os

import numpy as np
import pandas as pd
import argparse

from trizod.constants import BBATNS


def parse_args():
parser = argparse.ArgumentParser(description='')
parser = argparse.ArgumentParser(description="")

parser.add_argument('cache_dir',
help='Cache directory that shall be tested.')
parser.add_argument('cache_comp',
help='Cache directory to compare against.')
parser.add_argument("cache_dir", help="Cache directory that shall be tested.")
parser.add_argument("cache_comp", help="Cache directory to compare against.")

args = parser.parse_args()
return args


def main():
cache_files = {f for f in os.listdir(os.path.join(args.cache_dir, 'wSCS')) if os.path.isfile(os.path.join(args.cache_dir, 'wSCS', f)) and f.endswith('.npz')}
comp_files = {f for f in os.listdir(os.path.join(args.cache_comp, 'wSCS')) if os.path.isfile(os.path.join(args.cache_comp, 'wSCS', f)) and f.endswith('.npz')}
cache_files = {
f
for f in os.listdir(os.path.join(args.cache_dir, "wSCS"))
if os.path.isfile(os.path.join(args.cache_dir, "wSCS", f)) and f.endswith(".npz")
}
comp_files = {
f
for f in os.listdir(os.path.join(args.cache_comp, "wSCS"))
if os.path.isfile(os.path.join(args.cache_comp, "wSCS", f)) and f.endswith(".npz")
}
common_files = list(cache_files & comp_files)
common_files.sort()
print(len(common_files))
res = []
for fn in common_files:
with open(os.path.join(args.cache_dir, 'wSCS', fn), 'rb') as f1, open(os.path.join(args.cache_comp, 'wSCS', fn), 'rb') as f2:
with open(os.path.join(args.cache_dir, "wSCS", fn), "rb") as f1, open(
os.path.join(args.cache_comp, "wSCS", fn), "rb"
) as f2:
z = np.load(f1)
shw, ashwi, cmp_mask, olf, offf, shw0, ashwi0, ol0, off0 = z['shw'], z['ashwi'], z['cmp_mask'], z['olf'], z['offf'], z['shw0'], z['ashwi0'], z['ol0'], z['off0']
offf, off0 = {at:off for at,off in zip(BBATNS, offf)}, {at:off for at,off in zip(BBATNS, off0)}

z = np.load(f2)
shw_, ashwi_, cmp_mask_, olf_, offf_, shw0_, ashwi0_, ol0_, off0_ = z['shw'], z['ashwi'], z['cmp_mask'], z['olf'], z['offf'], z['shw0'], z['ashwi0'], z['ol0'], z['off0']
offf_, off0_ = {at:off for at,off in zip(BBATNS, offf_)}, {at:off for at,off in zip(BBATNS, off0_)}
shw, ashwi, cmp_mask, olf, offf, shw0, ashwi0, ol0, off0 = (
z["shw"],
z["ashwi"],
z["cmp_mask"],
z["olf"],
z["offf"],
z["shw0"],
z["ashwi0"],
z["ol0"],
z["off0"],
)
offf, off0 = (
{at: off for at, off in zip(BBATNS, offf)},
{at: off for at, off in zip(BBATNS, off0)},
)

z = np.load(f2)
shw_, ashwi_, cmp_mask_, olf_, offf_, shw0_, ashwi0_, ol0_, off0_ = (
z["shw"],
z["ashwi"],
z["cmp_mask"],
z["olf"],
z["offf"],
z["shw0"],
z["ashwi0"],
z["ol0"],
z["off0"],
)
offf_, off0_ = (
{at: off for at, off in zip(BBATNS, offf_)},
{at: off for at, off in zip(BBATNS, off0_)},
)
if ashwi.shape != ashwi_.shape:
res.append("shape mismatch")
continue
if not np.allclose(ashwi, ashwi_):
res.append('not close')
res.append("not close")
continue
res.append('close')
df = pd.DataFrame(res, columns=['result'], index=common_files)
res.append("close")
df = pd.DataFrame(res, columns=["result"], index=common_files)
breakpoint()

if __name__ == '__main__':

if __name__ == "__main__":
level = logging.INFO
logging.basicConfig(level=level, format=f'%(levelname)s : %(message)s')
logging.basicConfig(level=level, format=f"%(levelname)s : %(message)s")
args = parse_args()
main()
main()
4 changes: 3 additions & 1 deletion trizod/bmrb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .bmrb import BmrbEntry, get_valid_bbshifts
from .bmrb import BmrbEntry, get_valid_bbshifts

__all__ = ["BmrbEntry", "get_valid_bbshifts"]
Loading