# Computational Biophysics

> Calculate protein dihedral angle (phi/psi) from atomic coordinates using the torsion formula. Use when computing backbone dihedral angles from atomic positions or validating protein geometry.

- **Type:** Skill
- **Install:** `agentstack add skill-xushuwenn-redact-computational-biophysics`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [XuShuwenn](https://agentstack.voostack.com/s/xushuwenn)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [XuShuwenn](https://github.com/XuShuwenn)
- **Source:** https://github.com/XuShuwenn/RedAct/tree/main/captracebench/tasks/computational-biophysics-dihedral/environment/skills/computational-biophysics

## Install

```sh
agentstack add skill-xushuwenn-redact-computational-biophysics
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Computational Biophysics: Protein Dihedral Angle

## Overview

Given four atoms defining a protein backbone dihedral angle (N-CA-C-N'), calculate the dihedral angle in degrees using the torsion formula.

## Dihedral Angle Formula

The dihedral angle is the angle between two planes:
- Plane 1: defined by atoms (N, CA, C)
- Plane 2: defined by atoms (CA, C, N')

Using vector cross products and dot product:

```
b1 = CA - N
b2 = C - CA
b3 = N' - C

# Normal to plane 1
n1 = cross(b1, b2)

# Normal to plane 2
n2 = cross(b2, b3)

# Torsion angle
m1 = cross(n1, n2)
x = dot(m1, b2 / |b2|)
y = dot(n1, n2)

angle = atan2(x, y)
degrees = angle * 180 / pi
```

Range: -180 to +180 degrees.

## Calculation

```python
import math

def parse_coords(lines, indices):
    return [tuple(map(float, lines[i].strip().split())) for i in indices]

def vec_sub(a, b):
    return (a[0]-b[0], a[1]-b[1], a[2]-b[2])

def cross(u, v):
    return (
        u[1]*v[2] - u[2]*v[1],
        u[2]*v[0] - u[0]*v[2],
        u[0]*v[1] - u[1]*v[0]
    )

def dot(u, v):
    return u[0]*v[0] + u[1]*v[1] + u[2]*v[2]

def norm(v):
    return math.sqrt(v[0]**2 + v[1]**2 + v[2]**2)

def dihedral(p0, p1, p2, p3):
    b1 = vec_sub(p1, p0)
    b2 = vec_sub(p2, p1)
    b3 = vec_sub(p3, p2)
    n1 = cross(b1, b2)
    n2 = cross(b2, b3)
    m1 = cross(n1, b2)
    x = dot(m1, (b2[0]/norm(b2), b2[1]/norm(b2), b2[2]/norm(b2)))
    y = dot(n1, n2)
    return math.degrees(math.atan2(x, y))

# Read input
with open("/root/input.txt") as f:
    lines = f.read().strip().split("\n")

p0, p1, p2, p3 = parse_coords(lines, [0, 1, 2, 3])

angle = dihedral(p0, p1, p2, p3)

# Output
with open("/root/output.txt", "w") as f:
    f.write(f"Dihedral angle: {angle:.2f} degrees\n")
```

## Output Format

```
Dihedral angle: XXX.XX degrees
```

Round to 2 decimal places. Range: -180 to +180 degrees.

## Key Reference

- Dihedral angle between planes (N, CA, C) and (CA, C, N')
- Use torsion formula with cross products and atan2
- Output in degrees

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [XuShuwenn](https://github.com/XuShuwenn)
- **Source:** [XuShuwenn/RedAct](https://github.com/XuShuwenn/RedAct)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-xushuwenn-redact-computational-biophysics
- Seller: https://agentstack.voostack.com/s/xushuwenn
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
