Skip to content

Commit 942e7a9

Browse files
committed
Add genome module documentation: introduce genome statistics, feature detection, and comparative analysis tools; migrate genome-level analysis features from the sequence module.
1 parent 310d881 commit 942e7a9

6 files changed

Lines changed: 416 additions & 175 deletions

File tree

docs/en/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jsrc <module> <subcommand> --help
3636
| module | description |
3737
|---|---|
3838
| `seq` | Sequence extraction, renaming, translation, QC, k-mer, window |
39+
| `genome` | Genome statistics, feature detection, comparative/evolutionary analysis |
3940
| `plot` | Gene/exon/chromosome/domain and utility visualizations |
4041
| `analyze` | Phylogeny, motif, consensus, SNP/INDEL, QC |
4142
| `gs` | Genomic selection dataset build/split/train workflows |
@@ -51,6 +52,7 @@ jsrc <module> <subcommand> --help
5152
## Modules
5253

5354
- [Sequence Module](./module-seq.md)
55+
- [Genome Module](./module-genome.md)
5456
- [Analyze Module](./module-analyze.md)
5557
- [Plot Module](./module-plot.md)
5658
- [GS Module](./module-gs.md)

docs/en/module-genome.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# jsrc genome
2+
3+
Genome-level analysis tools. `jsrc genome` covers genome statistics, feature detection, comparative analysis, evolutionary analysis, and annotation utilities.
4+
5+
## cpg
6+
7+
CpG islands are genomic regions with high CpG dinucleotide density and GC content, typically located near gene promoters and associated with gene regulation. This command predicts CpG islands using the classic sliding window method (Gardiner-Garden & Frommer 1987).
8+
9+
A window is considered a candidate CpG island if GC% ≥ 50% and observed/expected CpG ratio ≥ 0.6. Adjacent qualifying windows are merged, and regions shorter than `--min-len` are filtered out.
10+
11+
```bash
12+
jsrc genome cpg -fa genome.fa
13+
jsrc genome cpg -fa genome.fa --window 200 --min-len 200 --min-gc 55 --json
14+
```
15+
16+
## orf
17+
18+
ORF finding is the first step in gene prediction for unannotated sequences. Given a FASTA file, this command scans for open reading frames from ATG to stop codons, reporting coordinates, length, frame, and translated protein sequence.
19+
20+
By default, only frame 1 is searched, reporting ORFs ≥ 100 nt. Use `--all-frames` to search all three forward frames, `--min-len` to adjust length threshold, and `--top N` to keep only the longest N ORFs per sequence.
21+
22+
```bash
23+
jsrc genome orf -fa genome.fa --min-len 300 --all-frames
24+
jsrc genome orf -fa contigs.fa --top 5 --json
25+
```
26+
27+
## promoter
28+
29+
When studying gene regulation, you often need to examine promoter regions. For example, to check if several genes have a transcription factor binding site in their upstream 2kb region, you first need to extract these regions in batch.
30+
31+
This command does exactly that: given a genome, GFF, and gene ID list, it automatically calculates coordinates and extracts upstream/downstream sequences.
32+
33+
Example input (`genes.txt`):
34+
35+
```txt
36+
GENE001
37+
GENE002
38+
GENE003
39+
```
40+
41+
By default, it extracts 2000bp upstream and 0bp downstream. You can adjust with `-up` and `-down`.
42+
43+
```bash
44+
jsrc genome promoter -fa genome.fa -gff genes.gff -ids genes.txt -o promoters.fa -up 1500 -down 500
45+
```
46+
47+
If your GFF uses a different feature label than `gene` (e.g., `mRNA`), set `-feature` accordingly.
48+
49+
## repeat
50+
51+
Find simple sequence repeats (SSR / microsatellites / STR) in genomic sequences. Scans for tandem repeat motifs within specified unit length range and minimum repeat count.
52+
53+
Default settings search for mono- to hexa-nucleotide repeats (unit length 1–6) with at least 3 repetitions. Commonly used for microsatellite marker development and repeat annotation.
54+
55+
```bash
56+
jsrc genome repeat -fa genome.fa
57+
jsrc genome repeat -fa genome.fa --min-unit 2 --max-unit 4 --min-reps 5 --json
58+
```
59+
60+
## island
61+
62+
Genomic island detection identifies regions with deviant GC content that may indicate horizontal gene transfer, pathogenicity islands, or other foreign DNA. This command uses a sliding window approach to scan for GC content anomalies.
63+
64+
Windows exceeding the GC threshold are marked as candidate islands. Adjacent candidate windows are merged into a single island. Use `--min-length` to filter out short regions.
65+
66+
```bash
67+
jsrc genome island -fa genome.fa
68+
jsrc genome island -fa genome.fa --window 5000 --step 1000 --gc-threshold 0.6 --min-length 10000 --json
69+
```
70+
71+
## palindrome
72+
73+
Palindromic sequences (inverted repeats) are often associated with transposons, restriction enzyme recognition sites, and hairpin structures. This command finds palindromic structures in sequences.
74+
75+
A palindrome consists of two reverse-complementary arms separated by a gap. You can set arm length range (`--min-arm`, `--max-arm`) and maximum gap length (`--max-gap`).
76+
77+
```bash
78+
jsrc genome palindrome -fa genome.fa
79+
jsrc genome palindrome -fa genome.fa --min-arm 8 --max-arm 30 --max-gap 20 --top 100 --json
80+
```
81+
82+
## stats
83+
84+
Basic genome assembly quality metrics. This command calculates N50/L50, total length, sequence count, gap statistics, and GC content.
85+
86+
N50 is the weighted median length—sort all sequences by length, sum from longest to shortest, and N50 is the length when cumulative sum reaches half the total. L50 is the number of sequences needed to reach N50. Higher values indicate better assembly contiguity.
87+
88+
```bash
89+
jsrc genome stats -fa assembly.fa
90+
jsrc genome stats -fa assembly.fa --json
91+
```
92+
93+
## gc-skew
94+
95+
Cumulative GC skew analysis is used to predict replication origin (oriC) and terminus (ter) in bacterial genomes. GC skew is defined as (G-C)/(G+C), typically showing a distinct minimum near the replication origin.
96+
97+
This command calculates sliding window cumulative GC skew, outputting position and cumulative skew for each window. Visualize with plotting tools to find the curve's lowest point.
98+
99+
```bash
100+
jsrc genome gc-skew -fa genome.fa
101+
jsrc genome gc-skew -fa genome.fa --window 10000 --step 5000 --json
102+
```
103+
104+
## window
105+
106+
Sliding window GC and AT skew analysis. This command calculates GC content, GC skew, and AT skew for each window at specified window size and step.
107+
108+
GC skew = (G-C)/(G+C), AT skew = (A-T)/(A+T). These metrics reveal local compositional features and replication bias.
109+
110+
```bash
111+
jsrc genome window -fa genome.fa
112+
jsrc genome window -fa genome.fa --window 50000 --step 10000 --json
113+
```
114+
115+
## codon
116+
117+
Codon usage frequency and RSCU (Relative Synonymous Codon Usage) analysis. Input CDS sequences in FASTA format to count codon occurrences and calculate RSCU.
118+
119+
RSCU = observed frequency / expected frequency (assuming uniform synonymous codon usage). RSCU > 1 indicates higher-than-average usage, < 1 indicates lower.
120+
121+
Optional features:
122+
- `--cai`: Calculate CAI (Codon Adaptation Index), requires reference gene set (typically highly expressed genes)
123+
- `--enc`: Calculate ENC (Effective Number of Codons), range 20-61, lower values indicate stronger codon bias
124+
125+
```bash
126+
jsrc genome codon -fa cds.fa --top 20
127+
jsrc genome codon -fa cds.fa --cai highly_expressed.fa --enc --json
128+
```
129+
130+
## distance
131+
132+
Calculate pairwise genetic distances in multiple sequence alignments. Supports four distance models:
133+
134+
- **hamming**: Hamming distance, number of differing sites
135+
- **p**: p-distance, proportion of differing sites
136+
- **jc**: Jukes-Cantor distance, corrects for multiple substitutions
137+
- **k2p**: Kimura 2-parameter distance, distinguishes transitions and transversions
138+
139+
Input must be aligned sequences (equal length).
140+
141+
```bash
142+
jsrc genome distance -fa aligned.fa --method p
143+
jsrc genome distance -fa aligned.fa --method k2p --json
144+
```
145+
146+
## kaks
147+
148+
Calculate Ka/Ks ratio for two aligned CDS sequences. Ka is the nonsynonymous substitution rate, Ks is the synonymous substitution rate, and Ka/Ks (ω) reflects selection pressure:
149+
150+
- ω < 1: purifying selection (negative selection)
151+
- ω = 1: neutral evolution
152+
- ω > 1: positive selection
153+
154+
Input must be exactly two aligned CDS sequences with length divisible by 3.
155+
156+
```bash
157+
jsrc genome kaks -fa aligned_cds.fa
158+
jsrc genome kaks -fa aligned_cds.fa --json
159+
```
160+
161+
## density
162+
163+
Calculate gene or feature density distribution along the genome. This command reads genome FASTA and GFF annotation, counting features in sliding windows and calculating density (features per kb) and coverage.
164+
165+
Use `--feature-type` to specify which feature type to count (e.g., gene, CDS, exon). Useful for visualizing uneven gene distribution.
166+
167+
```bash
168+
jsrc genome density -fa genome.fa -gff genes.gff
169+
jsrc genome density -fa genome.fa -gff genes.gff --feature-type CDS --window 20000 --step 10000 --json
170+
```
171+
172+
## motif-scan
173+
174+
Scan genomes for DNA motifs. Supports IUPAC degenerate base codes (R=A/G, Y=C/T, N=any, etc.) and allows mismatches.
175+
176+
Commonly used for transcription factor binding site prediction, restriction enzyme site finding, etc.
177+
178+
```bash
179+
jsrc genome motif-scan -fa genome.fa -m TATAAA
180+
jsrc genome motif-scan -fa genome.fa -m GCRWTG --mismatch 1 --top 50 --json
181+
```
182+
183+
## ani
184+
185+
k-mer-based Average Nucleotide Identity (ANI) calculation. ANI is a standard metric for measuring genome similarity, commonly used for species delineation (ANI > 95% typically indicates same species).
186+
187+
This command uses Jaccard similarity (shared k-mers / total k-mers) as an ANI approximation, requiring no sequence alignment and running fast.
188+
189+
```bash
190+
jsrc genome ani -fa genome1.fa genome2.fa
191+
jsrc genome ani -fa genome1.fa genome2.fa -k 21 --json
192+
```
193+
194+
## compare
195+
196+
Genome comparison and difference statistics based on global alignment. Uses the edlib library for efficient global alignment, calculating edit distance, identity, and difference sites.
197+
198+
**Note**: This command requires edlib: `pip install edlib`
199+
200+
```bash
201+
jsrc genome compare -fa genome1.fa genome2.fa
202+
jsrc genome compare -fa genome1.fa genome2.fa --json
203+
```

docs/en/module-seq.md

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# jsrc seq
22

3-
Sequence manipulation is the most routine task in bioinformatics. `jsrc seq` covers extraction, renaming, translation, promoter extraction, QC, codon usage, k-mer profiling, Entrez fetching, restriction digestion, sliding-window analysis, ORF finding, CpG island prediction, primer analysis, tandem repeat finding, sequence complexity, and MSA entropy.
3+
Sequence manipulation is the most routine task in bioinformatics. `jsrc seq` covers extraction, renaming, translation, QC, k-mer profiling, Entrez fetching, restriction digestion, sequence complexity, and MSA entropy.
4+
5+
Genome-level analysis features (such as ORF finding, CpG island prediction, promoter extraction, tandem repeats, codon usage, sliding-window analysis, etc.) have been moved to the [genome module](./module-genome.md).
46

57
## extract
68

@@ -54,28 +56,6 @@ When doing cross-species comparison or looking for protein domains, what you act
5456
jsrc seq translate -fa genome.fa -gff genes.gff -id ID -o proteins.fa
5557
```
5658

57-
## promoter
58-
59-
Studying gene regulation often means looking at promoter regions. Say you want to check whether a transcription factor binding site exists 2kb upstream of a set of genes — you need to extract those regions in bulk first.
60-
61-
This command does exactly that. Given genome, GFF, and gene IDs, it automatically calculates coordinates and extracts flanking sequences.
62-
63-
Example input (`genes.txt`):
64-
65-
```txt
66-
GENE001
67-
GENE002
68-
GENE003
69-
```
70-
71-
Default is 2000bp upstream, 0bp downstream. Adjust with `-up` and `-down`.
72-
73-
```bash
74-
jsrc seq promoter -fa genome.fa -gff genes.gff -ids genes.txt -o promoters.fa -up 1500 -down 500
75-
```
76-
77-
If your GFF uses a different feature label (some datasets use `mRNA` instead of `gene`), set `-feature` accordingly.
78-
7959
## qc
8060

8161
I always check data quality before diving into large-scale analysis. This command is for a quick health check — it won't replace FastQC's deep reports, but it's fast and gives you the essentials in one go.
@@ -87,16 +67,6 @@ jsrc seq qc -fa assembly.fa
8767
jsrc seq qc -fq r1.fq.gz r2.fq.gz -gs 520000000 --json
8868
```
8969

90-
## codon
91-
92-
Codon bias is an interesting angle. Different species, and even different genes within the same genome, display distinct codon usage patterns — shaped by selection pressure, mutation bias, and tRNA abundance.
93-
94-
This command calculates codon usage frequencies from CDS FASTA. It counts each codon and computes RSCU (Relative Synonymous Codon Usage). Shows the top 20 by default; increase with `--top`.
95-
96-
```bash
97-
jsrc seq codon -fa cds.fa --top 20 --json
98-
```
99-
10070
## kmer
10171

10272
k-mer is one of the most fundamental yet powerful features in sequence analysis. It's useful for assessing sequence complexity, generating genomic fingerprints, and quickly comparing similarity between samples.
@@ -130,60 +100,6 @@ jsrc seq digest -fa plasmid.fa -e EcoRI,HindIII --circular --json
130100
jsrc seq digest -fa seq.fa -e EcoRI --min-size 50
131101
```
132102

133-
## window
134-
135-
Sliding-window analysis solves a common problem: global GC content is an average, but genomic GC distribution is uneven — high near CpG islands, low near centromeres. This command looks at these variations window by window.
136-
137-
Specify window size and step, and the program slides along the sequence, computing GC content and GC skew ((G-C)/(G+C)) in each window. By default it uses the longest sequence in the FASTA; target a specific sequence with `-id`. `--head` limits output to the first N windows.
138-
139-
```bash
140-
jsrc seq window -fa genome.fa -w 100000 -s 20000 --head 20
141-
jsrc seq window -fa genome.fa -id chr1 -w 1000 -s 200 --json
142-
```
143-
144-
## orf
145-
146-
ORF finding is the first step in gene prediction from unannotated sequences. Given a FASTA file, this command scans for ATG-to-stop codon open reading frames and reports their coordinates, length, frame, and translated protein sequence.
147-
148-
By default it searches frame 1 only and reports ORFs ≥ 100 nt. Use `--all-frames` to search all three forward frames, and `--min-len` to adjust the length cutoff. `--top N` keeps only the N longest ORFs per sequence.
149-
150-
```bash
151-
jsrc seq orf -fa genome.fa --min-len 300 --all-frames
152-
jsrc seq orf -fa contigs.fa --top 5 --json
153-
```
154-
155-
## cpg
156-
157-
CpG islands are genomic regions with elevated CpG dinucleotide density and GC content, typically found near gene promoters and associated with gene regulation. This command predicts them using the classical sliding-window approach (Gardiner-Garden & Frommer 1987).
158-
159-
A window is considered a CpG island candidate if GC% ≥ 50% and observed/expected CpG ratio ≥ 0.6. Adjacent qualifying windows are merged; merged regions shorter than `--min-len` are dropped.
160-
161-
```bash
162-
jsrc seq cpg -fa genome.fa
163-
jsrc seq cpg -fa genome.fa --window 200 --min-len 200 --min-gc 55 --json
164-
```
165-
166-
## primer
167-
168-
Evaluates primer sequences for Tm, GC content, GC clamp, and hairpin risk. Two Tm models are provided: Wallace rule (fast estimate for short oligos) and the nearest-neighbor thermodynamic model (SantaLucia 1998, more accurate).
169-
170-
Input is a FASTA file where each record is one primer sequence. `--conc` sets the primer concentration for the nearest-neighbor calculation (default 250 nM).
171-
172-
```bash
173-
jsrc seq primer -fa primers.fa
174-
jsrc seq primer -fa primers.fa --conc 500 --json
175-
```
176-
177-
## repeat
178-
179-
Finds simple sequence repeats (SSRs / microsatellites / STRs) in genomic sequences. Scans for tandemly repeated motifs of specified unit length range with a minimum number of repeat copies.
180-
181-
Default settings find mono- through hexanucleotide repeats (unit length 1–6) with at least 3 copies. Useful for microsatellite marker development and repeat annotation.
182-
183-
```bash
184-
jsrc seq repeat -fa genome.fa
185-
jsrc seq repeat -fa genome.fa --min-unit 2 --max-unit 4 --min-reps 5 --json
186-
```
187103

188104
## complexity
189105

docs/zh/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jsrc <module> <subcommand> --help
3636
| 模块 | 说明 |
3737
|---|---|
3838
| `seq` | 序列提取、重命名、翻译、QC、k-mer、滑窗分析 |
39+
| `genome` | 基因组统计、特征检测、比较分析、进化分析 |
3940
| `plot` | 基因/外显子/染色体/结构域等可视化 |
4041
| `analyze` | 系统发育、motif、一致序列、SNP/INDEL、QC |
4142
| `gs` | 基因组选择数据构建、划分与训练流程 |
@@ -51,6 +52,7 @@ jsrc <module> <subcommand> --help
5152
## 模块文档
5253

5354
- [序列模块](./module-seq.md)
55+
- [基因组模块](./module-genome.md)
5456
- [分析模块](./module-analyze.md)
5557
- [绘图模块](./module-plot.md)
5658
- [GS 模块](./module-gs.md)

0 commit comments

Comments
 (0)