Skip to content

Commit

Permalink
fix required resname (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
pegerto authored Sep 24, 2024
1 parent adc3378 commit 25e7a2a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The rules for this file:
* YYYY-MM-DD date format (following ISO 8601)
* accompany each entry with github issue/PR number (Issue #xyz)
-->
## 0.2.7
* [Fix] Acess resname safely and test agains DCD

## 0.2.0
* [New] Include segmentid for freesasa calculation.
Expand Down
8 changes: 7 additions & 1 deletion mdakit_sasa/analysis/sasaanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Union, TYPE_CHECKING

from MDAnalysis.analysis.base import AnalysisBase
from MDAnalysis.exceptions import NoDataError
import numpy as np
import freesasa
import os
Expand Down Expand Up @@ -90,7 +91,12 @@ def _single_frame(self):
# FreeSasa structure accepts PDBS if not available requires to reconstruct the structure using `addAtom`
for a in self.atomgroup:
x,y,z = a.position
structure.addAtom(a.type.rjust(2), a.resname, a.resnum.item(), a.segid, x, y, z)
try:
resname = a.resname
except NoDataError:
resname = 'ANY' # Default classifier value

structure.addAtom(a.type.rjust(2), resname, a.resnum.item(), a.segid, x, y, z)

# Define 1 cpu for windows avoid freesasa code to calculate it.
parametes = freesasa.Parameters()
Expand Down
9 changes: 5 additions & 4 deletions mdakit_sasa/tests/analysis/test_sasaanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ def test_residue_sasa_calculation_results(self, analysis):
assert analysis.results['residue_area'].shape == (3,25)

@pytest.mark.parametrize(
"pdb_file_name, res_numbers",
"filename, res_numbers",
[
('134L.pdb', 201)
('134L.pdb', 201),
('image_vf.data', 1)
]
)
def test(self, pdb_file_name, res_numbers):
u = mda.Universe(PARENT / 'data' / pdb_file_name)
def test(self, filename, res_numbers):
u = mda.Universe(PARENT / 'data' / filename)
analysis = SASAAnalysis(u)
analysis.run()
assert(len(analysis.results.residue_area[0]) == res_numbers)
Expand Down
48 changes: 48 additions & 0 deletions mdakit_sasa/tests/data/image_vf.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
LAMMPS data file via write_data, version 30 Jul 2021, timestep = 0

7 atoms
2 atom types
1 bonds
1 bond types

0 10 xlo xhi
0 10 ylo yhi
0 10 zlo zhi

Masses

1 1
2 1

Pair Coeffs # lj/cut

1 1 1
2 1 1

Bond Coeffs # harmonic

1 1000 1

Atoms # full

4 0 2 0 5.891131260960588 3.398519062578611 0.23689615365476138 0 0 0
1 0 1 0 4.999443228802319 5.0001459354508775 5.5008776144874 0 0 0
2 0 1 0 5.000001730605194 4.999999546244266 4.500875455656523 0 0 0
6 0 2 0 8.27919675422795 8.459848309149896 4.670531882285388 0 0 0
3 0 2 0 3.362012829847722 5.522388563244657 8.669485965475673 0 0 0
5 0 2 0 6.586761886625301 3.97905466100164 9.576146361865367 0 0 0
7 0 2 0 7.621069760835089 6.390558075605001 9.73656065860773 0 0 0

Velocities

4 -0.07044405565641114 0.22797649438575432 0.9964537327696037
1 1.6773916431557685 0.920692478778414 -2.57312540408295
2 0.6247600152168848 1.0635940922731792 -0.09111771815842719
6 0.28742689473258004 -0.5462919186206593 -1.8993269764408356
3 -0.9529069979679257 -0.9763723022827592 3.1367559503110862
5 -0.7649018752874791 -2.004540572487937 0.652141765065628
7 -0.8013256241934161 1.3149417279540099 -0.22178134946410677

Bonds

1 1 1 2

0 comments on commit 25e7a2a

Please sign in to comment.