# novonordisk-research/pepfunn architecture

> Architecture diagram of the GitHub repository novonordisk-research/pepfunn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/novonordisk-research/pepfunn
- Repository: https://github.com/novonordisk-research/pepfunn

## Overview

##### Main Components
- Core Library (Domain Module) – The heart of the project lies in the “src/pepfunn” directory. Here you have multiple modules:
▪ library.py – for designing or generating peptide libraries.
▪ sequence.py – for peptide sequence manipulation.
▪ pairs.py – for handling matched pairs analysis.
▪ similarity.py – for calculating sequence or molecular similarity.
▪ clustering.py – for clustering algorithms applied to peptide molecules.
▪ data subfolder – containing reference/prerequisite data files (e.g., monomers.sdf, property.txt, etc.) used by the analysis modules.

- Interactive Notebooks – The “notebooks” folder contains Jupyter scripts that demo each main functionality. They can be illustrated as a user interface layer where researchers experiment with analysis workflows and generate outputs (figures, logs, etc.) which are then compared by the end-user.

- Unit Testing – The “tests” folder (and the standalone test.py) represents a testing layer verifying each module’s functionality. This shows a commitment to quality and a solid test orchestration point.

- External Dependencies – The README and third_party_licenses indicate important third-party tools such as RDKit and BioPython. Include a block showing “External Libraries/Third-Party Tools” with directional connections to the Core Library (indicating dependency).

##### Representing Relationships and Interactions
- Flow from Data to Processing Modules: Show that the data files (input data such as sequences, properties, and molecular information) feed into the core classes of the “pepfunn” package.
- User/Researcher Interaction: Connect the Notebooks (as a demonstration layer) to the core modules, indicating that they call functions from library, sequence, pairs, similarity, and clustering.
- Testing as an Isolated Check: Represent the tests suite as an independent block that interacts with each main module’s unit functionalities.

##### Highlighting Architectural Patterns and Design Principles
- Modular Design: Emphasize the separation of concerns by showing that each functionality (e.g., clustering, library generation) has its own module.
- Testing and Validation: The tests block reinforces that modularity supports direct unit testing, a best practice in modern Python packages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Subgraph
    subgraph "Core Library (pepfunn)"
        Core["pepfunn Core"]:::core
        Lib["Library (library.py)"]:::core
        Seq["Sequence (sequence.py)"]:::core
        Pair["Pairs (pairs.py)"]:::core
        Sim["Similarity (similarity.py)"]:::core
        Clust["Clustering (clustering.py)"]:::core
        Data["Data Files (data)"]:::core
    end

    %% Interactive Notebooks Subgraph
    subgraph "Interactive Notebooks"
        Notebooks["Notebooks"]:::notebooks
        GenLib["Generate Libraries Notebook"]:::notebooks
        AnalyzeSeq["Analyze Sequences Notebook"]:::notebooks
    end

    %% Unit Testing Subgraph
    subgraph "Unit Testing"
        TestsDir["Tests Directory"]:::tests
        TestScript["Standalone Test Script (test.py)"]:::tests
        TestClust["Test Clustering (tests/test_clustering.py)"]:::tests
        TestLib["Test Library (tests/test_library.py)"]:::tests
        TestPair["Test Pairs (tests/test_pairs.py)"]:::tests
        TestSeq["Test Sequence (tests/test_sequence.py)"]:::tests
        TestSim["Test Similarity (tests/test_similarity.py)"]:::tests
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies/Third-Party Tools"
        ExtDeps["Third-Party Licenses"]:::external
    end

    %% Packaging & Distribution Subgraph
    subgraph "Packaging & Distribution"
        Setup["setup.py"]:::packaging
        Req["requirements.txt"]:::packaging
    end

    %% Internal relationships inside Core Library
    Core --> Lib
    Core --> Seq
    Core --> Pair
    Core --> Sim
    Core --> Clust

    %% Data Files feeding into each core module
    Data --> Lib
    Data --> Seq
    Data --> Pair
    Data --> Sim
    Data --> Clust

    %% Notebooks flow and internal relations
    Notebooks --> GenLib
    Notebooks --> AnalyzeSeq
    %% Notebooks using core functionalities
    Notebooks --> Core

    %% Testing relationships: tests running against specific modules
    TestsDir --> Core
    TestLib --> Lib
    TestSeq --> Seq
    TestPair --> Pair
    TestClust --> Clust
    TestSim --> Sim
    TestScript --> Core

    %% External dependencies feeding into selected core modules
    ExtDeps --> Seq
    ExtDeps --> Sim
    ExtDeps --> Clust

    %% Packaging & Distribution used for building the core package
    Setup --> Core
    Req --> Core

    %% Click Events
    click Core "https://github.com/novonordisk-research/pepfunn/tree/main/src/pepfunn"
    click Lib "https://github.com/novonordisk-research/pepfunn/blob/main/src/pepfunn/library.py"
    click Seq "https://github.com/novonordisk-research/pepfunn/blob/main/src/pepfunn/sequence.py"
    click Pair "https://github.com/novonordisk-research/pepfunn/blob/main/src/pepfunn/pairs.py"
    click Sim "https://github.com/novonordisk-research/pepfunn/blob/main/src/pepfunn/similarity.py"
    click Clust "https://github.com/novonordisk-research/pepfunn/blob/main/src/pepfunn/clustering.py"
    click Data "https://github.com/novonordisk-research/pepfunn/tree/main/src/pepfunn/data"
    click Notebooks "https://github.com/novonordisk-research/pepfunn/tree/main/notebooks"
    click GenLib "https://github.com/novonordisk-research/pepfunn/blob/main/notebooks/1-generate_libraries.ipynb"
    click AnalyzeSeq "https://github.com/novonordisk-research/pepfunn/blob/main/notebooks/2-analyze_sequences.ipynb"
    click TestsDir "https://github.com/novonordisk-research/pepfunn/tree/main/tests"
    click TestScript "https://github.com/novonordisk-research/pepfunn/blob/main/test.py"
    click TestClust "https://github.com/novonordisk-research/pepfunn/blob/main/tests/test_clustering.py"
    click TestLib "https://github.com/novonordisk-research/pepfunn/blob/main/tests/test_library.py"
    click TestPair "https://github.com/novonordisk-research/pepfunn/blob/main/tests/test_pairs.py"
    click TestSeq "https://github.com/novonordisk-research/pepfunn/blob/main/tests/test_sequence.py"
    click TestSim "https://github.com/novonordisk-research/pepfunn/blob/main/tests/test_similarity.py"
    click ExtDeps "https://github.com/novonordisk-research/pepfunn/tree/main/third_party_licenses"
    click Setup "https://github.com/novonordisk-research/pepfunn/blob/main/setup.py"
    click Req "https://github.com/novonordisk-research/pepfunn/blob/main/requirements.txt"

    %% Class definitions for styling
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef notebooks fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef tests fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef packaging fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
```
