# joseph-ellaway/ramachandran_plotter architecture

> Architecture diagram of the GitHub repository joseph-ellaway/ramachandran_plotter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joseph-ellaway/ramachandran_plotter
- Repository: https://github.com/joseph-ellaway/ramachandran_plotter

## Overview

##### Project type and purpose
- This is an open-source, command-line Python tool for calculating dihedral (phi/psi) angles from PDB files and rendering Ramachandran plots.
- It reads a user-supplied PDB, computes angles, overlays them on a high-resolution background (Top8000 dataset), and outputs PNG/SVG/PDF figures and (optionally) a CSV of angles.

##### File structure
- Top level:
- DihedralCalculator.py – logic to compute phi/psi angles
- PlotterFunctions.py – routines to build contour backgrounds and scatter plots
- RamaArgumentParser.py – CLI argument parsing and validation
- RamachandranPlotter.py – orchestrator/main script
- Top8000_DihedralAngles.csv.gz – reference data for background contours
- example_data/ – sample PDB input
- example_plot/ – sample output images
- Ramachandran_Plotter.ipynb – exploratory notebook
- Support:
- __pycache__ for compiled bytecode
- .github for issue templates
- LICENSE, README

##### README for additional insights
- Workflow: parse arguments → load PDB via Biopython → calculate dihedrals → optionally save CSV → generate background contours (Pandas, SciPy) → scatter data points (Matplotlib, OpenCV) → write plot.
- External dependencies: Numpy, Pandas, Matplotlib, SciPy, OpenCV, Biopython, Argparse, OS.

##### Detailed coverage
- You capture every script (even the example notebook if relevant).
- Don’t over-complicate—stick to one page showing all major modules, data flows, and external resources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    CLIP["CLI Front-End\n(RamaArgumentParser.py)"]:::frontend
    CLIP -->|parses args| Main

    %% Orchestration
    Main["Main Controller\n(RamachandranPlotter.py)"]:::frontend

    %% Data Processing Layer
    Main -->|loads PDB| PLoader
    PLoader["PDB Loader\n(Biopython)"]:::processing
    PLoader -->|coordinates| Calc
    Calc["Dihedral Calculator\n(DihedralCalculator.py)"]:::processing
    Calc -->|angles DF| DM
    DM["Data Manager\n(Pandas DataFrame\noptional CSV)"]:::processing
    DM -->|--save_csv| CSV
    CSV["CSV Writer\n(optional)"]:::resource

    %% Plotting Layer
    DM -->|angles + ref| Plotter
    Ref["Reference Data Store\n(Top8000_DihedralAngles.csv.gz)"]:::resource
    Ref --> Plotter
    Plotter["Plot Generator\n(PlotterFunctions.py)"]:::plotting
    Plotter --> Fig
    Fig["Figure Object\n(Matplotlib/OpenCV)"]:::plotting

    %% Output Layer
    Fig --> Writer
    Writer["File Writer\n(OS operations)"]:::processing
    Writer -->|writes| Out["Output Sink\n(example_plot/)"]:::resource

    %% Exploratory Notebook
    Notebook["Exploratory Notebook\n(Ramachandran_Plotter.ipynb)"]:::frontend
    Notebook --> Main
    Notebook --> Calc
    Notebook --> Plotter

    %% Click Events
    click CLIP "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/RamaArgumentParser.py"
    click Main "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/RamachandranPlotter.py"
    click Calc "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/DihedralCalculator.py"
    click DM "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/RamachandranPlotter.py"
    click Plotter "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/PlotterFunctions.py"
    click Ref "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/Top8000_DihedralAngles.csv.gz"
    click Out "https://github.com/joseph-ellaway/ramachandran_plotter/tree/main/example_plot/"
    click Notebook "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/Ramachandran_Plotter.ipynb"
    click PLoader "https://github.com/joseph-ellaway/ramachandran_plotter/blob/main/RamachandranPlotter.py"

    %% Styling
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#006064;
    classDef processing fill:#e8f5e9,stroke:#1b5e20,color:#1b5e20;
    classDef plotting fill:#fff3e0,stroke:#e65100,color:#e65100;
    classDef resource fill:#eeeeee,stroke:#424242,color:#424242;
```
