# gauravj49/gjsrmap architecture

> Architecture diagram of the GitHub repository gauravj49/gjsrmap, 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/gauravj49/gjsrmap
- Repository: https://github.com/gauravj49/gjsrmap

## Overview

##### Main Components
- Input Data & Reference Files:
– Represent the “input” directory which houses both sequence annotations (under input/annotation/rna_classes) and the reference genomes (under input/reference_genome/dna).
– Indicate that these files serve as both raw sequencing input (fastq files from the user, as indicated via usage instructions) and the custom reference sequences for mapping.
- Pre-processing Module:
– As described in the README (iteration 0), it includes quality control, adapter trimming, removal of low-quality reads, and reference-index building.
– Highlight that this step uses dependency tools (e.g., cutadapt) and scripts (e.g., the pre-processing portions of 00_gjsrmap_usage.sh).
- Iterative Mapping Modules:
– Iteration 1: Mapping filtered reads (16–33 bp) to microRNAs and piRNAs using bowtie.
– Iteration 2: Mapping reads >32 bp to other small RNAs (rRNA, snRNA, snoRNA, premiRNA, osncRNA, etc.).
– Iteration 3: Mapping of reads that remain unmapped to the species’ reference genome.
– Each iteration can be represented as a separate processing block or service.
- Counting and Summarization Module:
– Use components corresponding to the counting-distribution (e.g., get_counts_from_sam.py, scripts/distribute_counts_usage.sh).
– Include QC/summary report generation using FastQC, MultiQC, and plotting via matplotlib.
- Logging and Job Management:
– Note the use of detailed logging and job submission (for example, references like the test/job_submission.log and job directory handling indicated by the JID parameter).
- Helper Scripts / Indexing Tools:
– Include the indexing scripts (STAR_create_index.sh, bowtie_create_index.sh) as supportive components that prepare the data for mapping.

##### Relationships and Data Flow
- Finally, include a ‘Reporting’ unit that represents generated QC plots (FastQC, MultiQC, matplotlib-based summary plots) and logs.

##### Architectural Patterns and Principles
- Modularity: Emphasize that each mapping iteration and pre-processing step are separate modules/scripts, which promotes a modular design.
- Script-based Workflow Orchestration: Note that a wrapper script (e.g., 06_run_ncRNA_mapping_usage.sh) ties these modules together, so it should be represented as an orchestrator that initiates the pipeline with user-specified parameters.

##### Relevant Technologies and Dependencies
- The usage of Python scripts (ncRNA_mapping_summary.py, get_counts_from_sam.py, etc.) should be shown in the Processing or Summarization modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    T("Pipeline Orchestration\n(06_run_ncrna_mapping_usage.sh)"):::orchestrator

    subgraph "Input Data & Reference Files"
        B("Annotation Files"):::data
        C("Reference Genome Files"):::data
    end

    D("Pre-processing Module\n(Quality Control & Adapter Trimming\n00_gjsrmap_usage.sh)"):::process

    I("STAR Indexing Script\n(scripts/STAR_create_index.sh)"):::process
    J("Bowtie Indexing Script\n(scripts/bowtie_create_index.sh)"):::process

    K("Iterative Mapping Iteration 1\n(miRNA/piRNA mapping\n02.1_map_pimirna_bowtie_usage.sh)"):::process
    L("Iterative Mapping Iteration 2\n(Other small ncRNA mapping\n02.2_map_smncrna_bowtie_usage.sh)"):::process
    M("Iterative Mapping Iteration 3\n(Genome mapping of unmapped reads\n03_map_reads_to_genome_bowtie_usage.sh)"):::process

    N("Counting & Summarization Module\n(04_counts_summary_usage.sh)"):::process
    subgraph "Summarization Scripts"
        O("get_counts_from_sam.py"):::process
        P("distribute_counts_usage.sh"):::process
        Q("ncRNA_mapping_summary.py"):::process
    end

    R("QC Reporting & Logs\n(FastQC, MultiQC, matplotlib)"):::process
    S("Job Management & Logging\n(test/job_submission.log)"):::process

    X("cutadapt & bedtools"):::tool
    Y("Bowtie"):::tool
    Z("FastQC, MultiQC, samtools, matplotlib"):::tool

    T --> B
    T --> C
    B --> D
    C --> D
    I --- D
    J --- D

    D --> K
    D --> L

    K --> M
    L --> M

    M --> N
    N --> O
    N --> P
    N --> Q
    N --> R
    N --> S
    R --> S

    D --- X
    K --- Y
    L --- Y
    M --- Y
    R --- Z

    classDef data fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef process fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef orchestrator fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef tool fill:#FFA07A,stroke:#333,stroke-width:2px;

    click B "https://github.com/gauravj49/gjsrmap/tree/master/input/annotation"
    click C "https://github.com/gauravj49/gjsrmap/tree/master/input/reference_genome/dna"
    click D "https://github.com/gauravj49/gjsrmap/blob/master/00_gjsrmap_usage.sh"
    click I "https://github.com/gauravj49/gjsrmap/blob/master/scripts/STAR_create_index.sh"
    click J "https://github.com/gauravj49/gjsrmap/blob/master/scripts/bowtie_create_index.sh"
    click K "https://github.com/gauravj49/gjsrmap/blob/master/02.1_map_pimirna_bowtie_usage.sh"
    click L "https://github.com/gauravj49/gjsrmap/blob/master/02.2_map_smncrna_bowtie_usage.sh"
    click M "https://github.com/gauravj49/gjsrmap/blob/master/03_map_reads_to_genome_bowtie_usage.sh"
    click N "https://github.com/gauravj49/gjsrmap/blob/master/04_counts_summary_usage.sh"
    click O "https://github.com/gauravj49/gjsrmap/blob/master/scripts/get_counts_from_sam.py"
    click P "https://github.com/gauravj49/gjsrmap/blob/master/scripts/distribute_counts_usage.sh"
    click Q "https://github.com/gauravj49/gjsrmap/blob/master/scripts/ncRNA_mapping_summary.py"
    click S "https://github.com/gauravj49/gjsrmap/blob/master/test/job_submission.log"
    click T "https://github.com/gauravj49/gjsrmap/blob/master/06_run_ncRNA_mapping_usage.sh"
```
