Skip to content

Commit

Permalink
passes own tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hypnopump committed May 16, 2021
1 parent 847df56 commit 24a7b5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions mp_nerf/kb_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,11 @@ def make_torsion_mask(aa, fill=False):
""" Gives the dihedral of the bond originating each atom. """
mask = np.zeros(14)
# backbone
if aa == "_":
return aa

# sidechain
for i, torsion in enumerate(SC_BUILD_INFO[aa]['torsion-vals']):
if fill:
mask[4+i] = MP2SC_INFO[aa][ SC_BUILD_INFO[aa]["atom-names"] ]["bond_dihedral"]
mask[4+i] = MP2SC_INFO[aa][ SC_BUILD_INFO[aa]["atom-names"][i] ]["bond_dihedral"]
else:
# https://github.com/jonathanking/sidechainnet/blob/master/sidechainnet/structure/StructureBuilder.py#L372
# 999 is an anotation -- change later
Expand Down
9 changes: 7 additions & 2 deletions tests/tes_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import numpy as np
import torch

from mp_nerf import *
from mp_nerf.utils import *
from mp_nerf.kb_proteins import *
from mp_nerf.proteins import *

def test_nerf_and_dihedral():
# create points
a = torch.tensor([1,2,3]).float()
Expand All @@ -26,5 +31,5 @@ def test_nerf_and_dihedral():
# reconstruct
# doesnt work because the scn angle was not measured correctly
# so the method corrects that incorrection
assert (nerf_torch(a, b, c, l, theta, chi - np.pi) - torch.tensor([1,0,6])).sum().abs() < 0.1
assert get_dihedral_torch(a, b, c, d).item() == chi
assert (mp_nerf_torch(a, b, c, l, theta, chi - np.pi) - torch.tensor([1,0,6])).sum().abs() < 0.1
assert get_dihedral(a, b, c, d).item() == chi

0 comments on commit 24a7b5e

Please sign in to comment.