# twlab/teprof2paper architecture

> Architecture diagram of the GitHub repository twlab/teprof2paper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/twlab/teprof2paper
- Repository: https://github.com/twlab/teprof2paper
- Video tour (about a minute): https://gitdiagram.com/twlab/teprof2paper/video

## Overview

TEProF2 is a short-read RNA-seq analysis pipeline for finding transposable-element–gene fusion transcripts, assessing their treatment enrichment, and optionally predicting transcript-derived antigens. The documented workflow annotates assembled GTFs, estimates expression, aggregates samples, evaluates supporting reads, filters candidates, merges and re-annotates transcripts, then quantifies and summarizes expression. A reference-guided route reuses prior annotations or a custom transcript set. Translation is an additional downstream capability. The README documents these stages, but the available source excerpts do not show the runtime wiring between most scripts.

Main entry points: [`bin/rmskhg38_annotate_gtf_update_test_tpm.py`](https://github.com/twlab/teprof2paper/blob/main/bin/rmskhg38_annotate_gtf_update_test_tpm.py) (TE fusion annotator), [`bin/mergeAnnotationProcess.R`](https://github.com/twlab/teprof2paper/blob/main/bin/mergeAnnotationProcess.R) (Annotation merging), [`bin/stringtieExpressionFrac.py`](https://github.com/twlab/teprof2paper/blob/main/bin/stringtieExpressionFrac.py) (Transcript expression fractions), [`bin/commandsmax_speed.py`](https://github.com/twlab/teprof2paper/blob/main/bin/commandsmax_speed.py) (Read command generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_annotation["Fusion annotation"]
  node_reference["Reference annotations<br/>[genecode_to_dic.py]"]
  node_introns["Intron annotations"]
  node_te_annotator["TE fusion annotator"]
  node_te_annotator_cuff["Cufflinks annotator"]
  node_reference_guided["Reference-guided inputs"]
  node_annotation_merge["Annotation merging"]
end

subgraph group_evidence["Read evidence"]
  node_read_commands["Read command generation"]
  node_paired_read_counts["Paired-read counting"]
  node_single_read_commands["Single-read command generation"]
  node_single_read_counts["Single-read counting"]
  node_filter["Candidate filtering"]
end

subgraph group_expression["Expression analysis"]
  node_expression_fraction["Transcript expression fractions"]
  node_annotation_stats["Annotation statistics"]
  node_aggregate["Sample aggregation"]
  node_final_stats["Quantification summary"]
end

subgraph group_translation["Translation"]
  node_translation_one["Kozak translation<br/>[translationPart1.R]"]
  node_translation_two["Translation completion<br/>[translationPart2.R]"]
end

node_user(("Analyst"))
node_gtf["Assembled GTFs"]
node_samtools["samtools"]
node_stringtie["StringTie"]

node_user -->|"provides"| node_gtf
node_gtf -->|"annotated by"| node_te_annotator
node_gtf -->|"annotated by"| node_te_annotator_cuff
node_reference -.->|"guides annotation"| node_te_annotator
node_introns -.->|"supplies introns"| node_te_annotator
node_te_annotator -->|"feeds expression"| node_expression_fraction
node_te_annotator_cuff -.->|"feeds expression"| node_expression_fraction
node_expression_fraction -->|"processed across samples"| node_aggregate
node_aggregate -->|"defines candidates"| node_read_commands
node_read_commands -->|"queries alignments"| node_samtools
node_read_commands -->|"dispatches counts"| node_paired_read_counts
node_single_read_commands -->|"queries alignments"| node_samtools
node_single_read_commands -->|"dispatches counts"| node_single_read_counts
node_paired_read_counts -->|"provides read counts"| node_filter
node_single_read_counts -->|"provides read counts"| node_filter
node_filter -->|"filters candidates"| node_annotation_merge
node_reference_guided -->|"provides reference set"| node_annotation_merge
node_annotation_merge -->|"re-annotated"| node_te_annotator
node_annotation_merge -.->|"re-annotated"| node_te_annotator_cuff
node_te_annotator -->|"supplies annotations"| node_annotation_stats
node_annotation_stats -->|"maps expression"| node_final_stats
node_stringtie -->|"provides quantification"| node_expression_fraction
node_final_stats -->|"provides candidates"| node_translation_one
node_translation_one -->|"passes sequences"| node_translation_two

click node_reference "https://github.com/twlab/teprof2paper/blob/main/bin/genecode_to_dic.py"
click node_introns "https://github.com/twlab/teprof2paper/blob/main/bin/genecode_introns.py"
click node_te_annotator "https://github.com/twlab/teprof2paper/blob/main/bin/rmskhg38_annotate_gtf_update_test_tpm.py"
click node_te_annotator_cuff "https://github.com/twlab/teprof2paper/blob/main/bin/rmskhg38_annotate_gtf_update_test_tpm_cuff.py"
click node_reference_guided "https://github.com/twlab/teprof2paper/blob/main/bin/mergeAnnotationProcess_Ref.R"
click node_annotation_merge "https://github.com/twlab/teprof2paper/blob/main/bin/mergeAnnotationProcess.R"
click node_read_commands "https://github.com/twlab/teprof2paper/blob/main/bin/commandsmax_speed.py"
click node_paired_read_counts "https://github.com/twlab/teprof2paper/blob/main/bin/rmsk_annotate_bedpe_speed.py"
click node_single_read_commands "https://github.com/twlab/teprof2paper/blob/main/bin/commandsmax_speed_se.py"
click node_single_read_counts "https://github.com/twlab/teprof2paper/blob/main/bin/rmsk_annotate_bedse_speed.py"
click node_filter "https://github.com/twlab/teprof2paper/blob/main/bin/filterReadCandidates.R"
click node_expression_fraction "https://github.com/twlab/teprof2paper/blob/main/bin/stringtieExpressionFrac.py"
click node_annotation_stats "https://github.com/twlab/teprof2paper/blob/main/bin/annotationtpmprocess.py"
click node_aggregate "https://github.com/twlab/teprof2paper/blob/main/bin/aggregateProcessedAnnotation.R"
click node_final_stats "https://github.com/twlab/teprof2paper/blob/main/bin/finalStatisticsOutput.R"
click node_translation_one "https://github.com/twlab/teprof2paper/blob/main/bin/translationPart1.R"
click node_translation_two "https://github.com/twlab/teprof2paper/blob/main/bin/translationPart2.R"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_reference,node_introns,node_te_annotator,node_te_annotator_cuff,node_reference_guided,node_annotation_merge toneBlue
class node_read_commands,node_paired_read_counts,node_single_read_commands,node_single_read_counts,node_filter toneAmber
class node_expression_fraction,node_annotation_stats,node_aggregate,node_final_stats toneMint
class node_translation_one,node_translation_two toneRose
class node_user,node_gtf,node_samtools,node_stringtie toneIndigo
```

## Components

### Fusion annotation

- [Reference annotations](https://github.com/twlab/teprof2paper/blob/main/bin/genecode_to_dic.py): `bin/genecode_to_dic.py`
- [Intron annotations](https://github.com/twlab/teprof2paper/blob/main/bin/genecode_introns.py): `bin/genecode_introns.py`
- [TE fusion annotator](https://github.com/twlab/teprof2paper/blob/main/bin/rmskhg38_annotate_gtf_update_test_tpm.py): `bin/rmskhg38_annotate_gtf_update_test_tpm.py`
- [Cufflinks annotator](https://github.com/twlab/teprof2paper/blob/main/bin/rmskhg38_annotate_gtf_update_test_tpm_cuff.py): `bin/rmskhg38_annotate_gtf_update_test_tpm_cuff.py`
- [Reference-guided inputs](https://github.com/twlab/teprof2paper/blob/main/bin/mergeAnnotationProcess_Ref.R): `bin/mergeAnnotationProcess_Ref.R`
- [Annotation merging](https://github.com/twlab/teprof2paper/blob/main/bin/mergeAnnotationProcess.R): `bin/mergeAnnotationProcess.R`

### Read evidence

- [Read command generation](https://github.com/twlab/teprof2paper/blob/main/bin/commandsmax_speed.py): `bin/commandsmax_speed.py`
- [Paired-read counting](https://github.com/twlab/teprof2paper/blob/main/bin/rmsk_annotate_bedpe_speed.py): `bin/rmsk_annotate_bedpe_speed.py`
- [Single-read command generation](https://github.com/twlab/teprof2paper/blob/main/bin/commandsmax_speed_se.py): `bin/commandsmax_speed_se.py`
- [Single-read counting](https://github.com/twlab/teprof2paper/blob/main/bin/rmsk_annotate_bedse_speed.py): `bin/rmsk_annotate_bedse_speed.py`
- [Candidate filtering](https://github.com/twlab/teprof2paper/blob/main/bin/filterReadCandidates.R): `bin/filterReadCandidates.R`

### Expression analysis

- [Transcript expression fractions](https://github.com/twlab/teprof2paper/blob/main/bin/stringtieExpressionFrac.py): `bin/stringtieExpressionFrac.py`
- [Annotation statistics](https://github.com/twlab/teprof2paper/blob/main/bin/annotationtpmprocess.py): `bin/annotationtpmprocess.py`
- [Sample aggregation](https://github.com/twlab/teprof2paper/blob/main/bin/aggregateProcessedAnnotation.R): `bin/aggregateProcessedAnnotation.R`
- [Quantification summary](https://github.com/twlab/teprof2paper/blob/main/bin/finalStatisticsOutput.R): `bin/finalStatisticsOutput.R`

### Translation

- [Kozak translation](https://github.com/twlab/teprof2paper/blob/main/bin/translationPart1.R): `bin/translationPart1.R`
- [Translation completion](https://github.com/twlab/teprof2paper/blob/main/bin/translationPart2.R): `bin/translationPart2.R`

### Other components

- **Analyst**
- **Assembled GTFs**
- **samtools**
- **StringTie**

## Connections

- Analyst → Assembled GTFs: provides (evidence: `README.md`)
- Assembled GTFs → TE fusion annotator: annotated by (evidence: `README.md`)
- Assembled GTFs → Cufflinks annotator: annotated by (evidence: `README.md`)
- Reference annotations → TE fusion annotator: guides annotation
- Intron annotations → TE fusion annotator: supplies introns
- TE fusion annotator → Transcript expression fractions: feeds expression (evidence: `README.md`)
- Cufflinks annotator → Transcript expression fractions: feeds expression
- Transcript expression fractions → Sample aggregation: processed across samples (evidence: `README.md`)
- Sample aggregation → Read command generation: defines candidates (evidence: `README.md`)
- Read command generation → samtools: queries alignments (evidence: `README.md`)
- Read command generation → Paired-read counting: dispatches counts (evidence: `README.md`)
- Single-read command generation → samtools: queries alignments (evidence: `README.md`)
- Single-read command generation → Single-read counting: dispatches counts (evidence: `README.md`)
- Paired-read counting → Candidate filtering: provides read counts (evidence: `README.md`)
- Single-read counting → Candidate filtering: provides read counts (evidence: `README.md`)
- Candidate filtering → Annotation merging: filters candidates (evidence: `README.md`)
- Reference-guided inputs → Annotation merging: provides reference set (evidence: `README.md`)
- Annotation merging → TE fusion annotator: re-annotated (evidence: `README.md`)
- Annotation merging → Cufflinks annotator: re-annotated
- TE fusion annotator → Annotation statistics: supplies annotations (evidence: `README.md`)
- Annotation statistics → Quantification summary: maps expression (evidence: `README.md`)
- StringTie → Transcript expression fractions: provides quantification (evidence: `README.md`)
- Quantification summary → Kozak translation: provides candidates (evidence: `README.md`)
- Kozak translation → Translation completion: passes sequences (evidence: `README.md`)
