# barrydigby/pycircdb architecture

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

- Interactive diagram: https://gitdiagram.com/barrydigby/pycircdb
- Repository: https://github.com/barrydigby/pycircdb

## Overview

##### Main components
- Core Application (pycircdb Package): This is the heart of the system. It includes the main executable (__main__.py) and the central module (pycircdb.py). It orchestrates operations.
- Utilities Module: Found under “pycircdb/utils”, these submodules handle tasks such as:
– Configuration management (config.py and config_defaults.yaml).
– Data ingestion (ingest.py and the “ingest2” subfolder where ingestion for circRNAs, miRNAs, and mRNAs are further defined).
– Data filtering (filter_circrnas.py, filter_genes.py, filter_mirnas.py).
– Annotation (annotate.py) and reporting (report.py).
– Helpers and parameter validation (helpers.py, parameter_check.py).
– Building complex networks (build_network.py) and logging (log.py and simple_log.py).
– Test utilities (test_helpers.py)
- Test & Sample Data Layer: Represented by the “test_data” folder with various sample and test input files (e.g., CSV, TXT, FASTA files). This is crucial for development, testing, and validation.
- Setup and Deployment: The presence of “setup.py” and configuration files (.gitignore, update_gitignore.sh) indicates standard packaging and deployment practices.

##### Relationships and Interactions
- The Core Application calls upon various Utilities for parsing input files, validating parameters, and building intermediary data representations.
- The ingestion modules read in large datasets referenced in the README (e.g., circ2disease, circatlas, circbank, etc.)—each of which could be conceptualized as separate “external” data sources.
- The configuration module loads defaults and user-specified parameters that drive the ingestion and filtering process.
- Output from these modules flows into reporting and network-building routines which may then be rendered and visualized (using d3example.py or notebooks).
- Testing and schema viewing (view_schema.py) provide feedback loops during development.

##### Architectural Patterns and Design Principles
- Modular Design: The project is organized into a core package and distinct utility modules, demonstrating separation of concerns.
- Pipeline/Workflow Pattern: Data flows through ingestion, filtering, annotation, reporting, and visualization.
- Config-Driven Behavior: The use of a YAML configuration file hints at an architecture where behavior can be modified by changing external files.
- Reusability and Extensibility: Multiple “ingest” modules and the existence of helper scripts suggest that new data sources or processing modules can be added as independent components.

##### Relevant Technologies and Frameworks
- Python as the primary programming language.
- YAML for configuration.
- Jupyter Notebooks for interactive analysis.
- Dask (as hinted by dask_shit.ipynb and checkpoint names) to parallelize or handle large data workflows.
- Possibly D3.js (via d3example.py) for producing web-based visualizations of network data.
- Packaging tools (setup.py) for distribution and installation.

##### Essential Elements
- “Configuration Manager” (config.py and config_defaults.yaml).
- “Data Ingestion & Parsing” components (ingest.py, ingest2 submodules).
- “Filtering/Validation” components (filter_circrnas.py, filter_genes.py, filter_mirnas.py, parameter_check.py).
- “Annotation & Reporting” (annotate.py, report.py).
- “Network Construction” (build_network.py).
- “Logging & Helpers” (log.py, simple_log.py, helpers.py).
- “Visualization/Interactive Analysis” (d3example.py, notebooks, view_schema.py).
- “Test Data & External Databases” layer (test_data, external reference files as described).
- From External Data Sources -> Data Ingestion.
- From Configuration Manager into every processing module (ensuring configuration is applied).
- From Ingestion and Filtering -> Annotation & Reporting.
- From Reporting -> Visualization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application
    subgraph "Core Application (pycircdb)"
        coreMain["Executable: __main__.py"]:::core
        corePycircbd["Orchestrator: pycircdb.py"]:::core
    end

    %% Configuration Management
    subgraph "Configuration Management"
        config["Config Manager: config.py"]:::util
        configDefaults["Default Config: config_defaults.yaml"]:::util
    end

    %% Data Ingestion
    subgraph "Data Ingestion"
        ingest["Ingestion Base: ingest.py"]:::util
        ingestCircrna["Ingest circRNA: ingest_circrna.py"]:::util
        ingestMirna["Ingest miRNA: ingest_mirna.py"]:::util
        ingestMrna["Ingest mRNA: ingest_mrna.py"]:::util
    end

    %% Data Filtering/Validation
    subgraph "Data Filtering/Validation"
        filterCircrnas["Filter circRNAs: filter_circrnas.py"]:::util
        filterGenes["Filter Genes: filter_genes.py"]:::util
        filterMirnas["Filter miRNAs: filter_mirnas.py"]:::util
        parameterCheck["Parameter Check: parameter_check.py"]:::util
    end

    %% Annotation & Reporting
    subgraph "Annotation & Reporting"
        annotate["Annotation: annotate.py"]:::util
        report["Reporting: report.py"]:::util
    end

    %% Network Construction
    subgraph "Network Construction"
        buildNetwork["Build Network: build_network.py"]:::util
    end

    %% Logging & Helpers
    subgraph "Logging & Helpers"
        logNode["Logging: log.py"]:::util
        simpleLog["Simple Log: simple_log.py"]:::util
        helpersNode["Helpers: helpers.py"]:::util
        testHelpers["Test Helpers: test_helpers.py"]:::util
    end

    %% Visualization/Interactive Analysis
    subgraph "Visualization/Interactive Analysis"
        d3example["Visualization Script: d3example.py"]:::util
        notebookNode["Notebook: dask_shit.ipynb"]:::util
        viewSchema["Schema Viewer: view_schema.py"]:::util
    end

    %% Test Data & Sample Inputs
    subgraph "Test Data & Sample Inputs"
        testData["Test Data"]:::external
    end

    %% Setup & Deployment
    subgraph "Setup & Deployment"
        setupNode["Setup: setup.py"]:::external
        gitIgnore["Git Ignore: .gitignore"]:::external
        updateGit["Update Git Ignore: update_gitignore.sh"]:::external
    end

    %% Data Flow Connections
    corePycircbd -->|"initializes"| config
    corePycircbd -->|"triggers"| ingest
    corePycircbd -->|"coordinates"| filterCircrnas
    corePycircbd -->|"orchestrates"| annotate
    corePycircbd -->|"invokes"| buildNetwork
    corePycircbd -->|"launches"| d3example

    config -->|"feeds"| ingest
    config -->|"guides"| filterCircrnas

    testData -->|"provides raw data to"| ingest

    ingest -->|"executes specialized tasks"| ingestCircrna
    ingest -->|"executes specialized tasks"| ingestMirna
    ingest -->|"executes specialized tasks"| ingestMrna

    ingest -->|"transmits data to"| filterCircrnas

    filterCircrnas -->|"filters data and passes to"| annotate
    filterGenes -->|"supports filtering"| annotate
    filterMirnas -->|"supports filtering"| annotate
    parameterCheck -->|"validates parameters for"| annotate

    annotate -->|"generates output for"| report

    report -->|"supplies results to"| buildNetwork
    report -->|"supplies results to"| d3example
    report -->|"supplies results to"| notebookNode
    report -->|"supplies results to"| viewSchema

    %% Styles
    classDef core fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef util fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef external fill:#cce5ff,stroke:#333,stroke-width:2px;

    %% Click Events
    click coreMain "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/__main__.py"
    click corePycircbd "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/pycircdb.py"

    click config "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/config.py"
    click configDefaults "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/config_defaults.yaml"

    click ingest "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/ingest.py"
    click ingestCircrna "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/ingest2/ingest_circrna.py"
    click ingestMirna "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/ingest2/ingest_mirna.py"
    click ingestMrna "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/ingest2/ingest_mrna.py"

    click filterCircrnas "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/filter_circrnas.py"
    click filterGenes "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/filter_genes.py"
    click filterMirnas "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/filter_mirnas.py"
    click parameterCheck "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/parameter_check.py"

    click annotate "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/annotate.py"
    click report "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/report.py"

    click buildNetwork "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/build_network.py"

    click logNode "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/log.py"
    click simpleLog "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/simple_log.py"
    click helpersNode "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/helpers.py"
    click testHelpers "https://github.com/barrydigby/pycircdb/blob/main/pycircdb/utils/test_helpers.py"

    click d3example "https://github.com/barrydigby/pycircdb/blob/main/d3example.py"
    click notebookNode "https://github.com/barrydigby/pycircdb/blob/main/dask_shit.ipynb"
    click viewSchema "https://github.com/barrydigby/pycircdb/blob/main/view_schema.py"

    click testData "https://github.com/barrydigby/pycircdb/tree/main/test_data"

    click setupNode "https://github.com/barrydigby/pycircdb/blob/main/setup.py"
    click gitIgnore "https://github.com/barrydigby/pycircdb/blob/main/.gitignore"
    click updateGit "https://github.com/barrydigby/pycircdb/blob/main/update_gitignore.sh"
```
