Skip to content

Commit

Permalink
Removed unused files incl. the older bio3d R script; Ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JHKru committed Sep 23, 2024
1 parent 6ba376e commit d5ab251
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14,271 deletions.
305 changes: 0 additions & 305 deletions 1l2y.pdb

This file was deleted.

13,861 changes: 0 additions & 13,861 deletions 7cal.pdb

This file was deleted.

7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ via *pip*:
$ git clone https://github.com/biotite-dev/springcraft.git
$ pip install ./springcraft
A development conda environment with all required dependencies for testing
can be installed from `environment.yml`

Scripts to generate reference files for tests are stored in tests/data;
a separate environment to rerun these locally can be found in `test_create_data_env.yml`.
BioPhysConnectoR has to be installed separately.

Example
=======

Expand Down
File renamed without changes.
75 changes: 0 additions & 75 deletions tests/data/hessian_calpha_sdENM_pfENM_bio3d.R

This file was deleted.

13 changes: 5 additions & 8 deletions tests/data/test_data_prep_prody_bio3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
FETCH_PDB_IDS = ["1l2y", "7cal"]

for pdb_fetch_id in FETCH_PDB_IDS:
in_pdb = pdb.PDBFile.read(
rcsb.fetch(pdb_fetch_id, format="pdb", overwrite=True)
)
in_pdb = pdb.PDBFile.read(rcsb.fetch(pdb_fetch_id, format="pdb", overwrite=True))
in_struc = in_pdb.get_structure(model=1)
# NOTE: Deprecated filter function -> Older Biotite version
protein = in_struc[struc.filter_amino_acids(in_struc)]

outpdb = pdb.PDBFile()
pdb.set_structure(outpdb, protein)
outpdb.write(pdb_fetch_id + ".pdb")
Expand All @@ -33,6 +31,7 @@
# Sequence funtion in R
r_seq = robjects.r["seq"]


# Convert AtomArray into bio3d-PDB objects
def aarray_to_bio3d(aarray):
coords = aarray.coord
Expand Down Expand Up @@ -98,6 +97,7 @@ def aarray_to_bio3d(aarray):

return pdb_bio3d


## Test data-generating functions
# -> Enforce consistent naming of output .csv
def prody_enm_nma(enm_type, structure_path, cutoff_list, output_markers="all"):
Expand Down Expand Up @@ -216,10 +216,7 @@ def bio3d_anm_nma(structure_path, bio3d_ff, output_markers="all"):
# Structure I/O w. biotite
in_struc = bstio.load_structure(structure_path, model=1)
ca = in_struc[
(
(struc.filter_canonical_amino_acids(in_struc))
& (in_struc.atom_name == "CA")
)
((struc.filter_canonical_amino_acids(in_struc)) & (in_struc.atom_name == "CA"))
]

for o in outputs:
Expand Down
34 changes: 13 additions & 21 deletions tests/test_anm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def test_mass_weights_simple():
assert not np.allclose(different_anm.hessian, ref_anm.hessian)


@pytest.mark.parametrize(
"file_path", glob.glob(join(data_dir(), "*.pdb"))
)
@pytest.mark.parametrize("file_path", glob.glob(join(data_dir(), "*.pdb")))
def test_compare_eigenvals_BiophysConnectoR(file_path):
"""
Compare non-mass-weighted eigenvalues with those computed with
Expand Down Expand Up @@ -86,11 +84,10 @@ def test_compare_eigenvals_BiophysConnectoR(file_path):


@pytest.mark.parametrize(
"file_path, ff_name",
itertools.product(
glob.glob(join(data_dir(), "*.pdb")),
["Hinsen", "sdENM", "pfENM"]
)
"file_path, ff_name",
itertools.product(
glob.glob(join(data_dir(), "*.pdb")), ["Hinsen", "sdENM", "pfENM"]
),
)
def test_mass_weights_eigenvals(file_path, ff_name):
"""
Expand All @@ -110,25 +107,20 @@ def test_mass_weights_eigenvals(file_path, ff_name):
if ff_name == "sdENM":
ff = springcraft.TabulatedForceField.sd_enm(ca)
ff_bio3d_str = "sdenm"

# NOTE: Different chains are not correctly identified in bio3d
# -> Connect single chains with modified covalent contacts
# in springcraft
if struc.get_chain_count(ca) > 1:
after_chainbreak = struc.check_res_id_continuity(ca)
prior_chainbreak = after_chainbreak-1
contact_mod_pairs = np.array(
[prior_chainbreak, after_chainbreak]
).T
bonded_force_constant = 43.52*0.0083144621*300*10
prior_chainbreak = after_chainbreak - 1
contact_mod_pairs = np.array([prior_chainbreak, after_chainbreak]).T
bonded_force_constant = 43.52 * 0.0083144621 * 300 * 10
ff = springcraft.PatchedForceField(
ff,
contact_pair_off=contact_mod_pairs,
contact_pair_on=contact_mod_pairs,
force_constants=np.full(
len(contact_mod_pairs),
bonded_force_constant
)
ff,
contact_pair_off=contact_mod_pairs,
contact_pair_on=contact_mod_pairs,
force_constants=np.full(len(contact_mod_pairs), bonded_force_constant),
)
if ff_name == "pfENM":
ff = springcraft.ParameterFreeForceField()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def test_compare_with_biophysconnector_heterogenous(atoms_singlechain, ff_name):

if ff_name == "e_anm":
ff = springcraft.TabulatedForceField.e_anm(atoms_singlechain)
ref_file = "biophysconnector_anm_eanm_hessian_1l2y.csv.gz"
ref_file = "biophysconnector_anm_eanm_hessian_1l2y.csv.gz"
if ff_name == "e_anm_mj":
ff = springcraft.TabulatedForceField.e_anm_mj(atoms_singlechain)
ref_file = "biophysconnector_anm_eanm_mj_hessian_1l2y.csv"
Expand Down

0 comments on commit d5ab251

Please sign in to comment.