File size: 1,455 Bytes
a3f3d91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Module for simple AGGRESCAN3D method."""

from __future__ import annotations
import pathlib
from aggrescan import analysis
from aggrescan.aggrescan_3d import Residue


def run_aggrescan3d(
    structure_path: str,
    distance: float = 10,
) -> list[Residue]:
    """Run AGGRESCAN3D on the input structure.

    Args:
        structure_path: Path to pdb structure.
        distance: Radius around the central atom within which atoms are included in the
        aggrescan3d score calculation.

    Returns:
        List of aggrescan3D `Residue` objects.
        `Residue` objects have the following attributes:
        - chain: Chain ID.
        - rsa: Relative surface area. Value in range [0, 100].
        - score: Aggrescan3D score.
        - resi: Residue index.
        - resn: One letter residue type.
        - coords: Tuple of (x, y, z) coordinates.

    """
    struct_path = pathlib.Path(structure_path)
    # Check if structure exists. If it doesn't, it only gets caught by freeSASA and it
    # throws a confusing error message.
    if not struct_path.exists():
        raise RuntimeError(f"Structure '{structure_path}' does not exist.")
    config = {
        "distance": distance,
        "naccess": False,
        "ph": False,
    }
    analysis._run_free_sasa(target=structure_path, agg=".")
    residues: list[Residue] = analysis._run_aggrescan(
        target=structure_path, working_dir=".", config=config,
    )
    return residues