-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvanced_usage.py
More file actions
120 lines (92 loc) · 3.16 KB
/
advanced_usage.py
File metadata and controls
120 lines (92 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
"""
Advanced usage examples for UMI RNA Simulator
Demonstrates using real gene annotations (GTF) and genomic sequences (FASTA).
"""
from umi_simulator import BulkRNAUMISimulator
def bacterial_genome():
"""Example with bacterial genome (small, fast test)"""
print("Example 1: Bacterial Genome (CP003773 - Mycoplasma)")
print("-" * 60)
gtf_file = "tests/data/CP003773.gtf"
fasta_file = "tests/data/CP003773.fasta"
if not os.path.exists(gtf_file) or not os.path.exists(fasta_file):
print("ERROR: Test files not found in tests/data/")
print("Please ensure test data is available.")
return
simulator = BulkRNAUMISimulator(
gtf_file=gtf_file,
fasta_file=fasta_file,
total_molecules=5000,
pcr_cycles=10,
pcr_efficiency=0.7,
random_seed=42
)
simulator.run_simulation(output_prefix="output/bacterial")
def mouse_chromosome():
"""Example with mouse chromosome 19"""
print("\nExample 2: Mouse Chromosome 19")
print("-" * 60)
gtf_file = "tests/data/GRCm39_chr19.gtf"
fasta_file = "tests/data/GRCm39_chr19.fasta"
if not os.path.exists(gtf_file) or not os.path.exists(fasta_file):
print("ERROR: Mouse chr19 files not found")
print("Run: cd tests/integration && bash extract_chr19_mouse.sh")
return
simulator = BulkRNAUMISimulator(
gtf_file=gtf_file,
fasta_file=fasta_file,
total_molecules=20000,
paired_end=True,
fragment_length=300,
read_length=75,
pcr_cycles=10,
pcr_efficiency=0.7,
random_seed=42
)
simulator.run_simulation(output_prefix="output/mouse_chr19")
def custom_parameters():
"""Example with custom sequencing parameters"""
print("\nExample 3: Custom Sequencing Parameters")
print("-" * 60)
simulator = BulkRNAUMISimulator(
n_genes=500,
total_molecules=10000,
umi_length=12,
read_length=150,
sequencing_error_rate=0.005, # 0.5% error rate
umi_error_rate=0.01, # 1% UMI error rate
pcr_cycles=12,
pcr_efficiency=0.75,
random_seed=42
)
simulator.run_simulation(output_prefix="output/custom_params")
def inline_umi():
"""Example with UMI in sequence instead of header"""
print("\nExample 4: UMI In Sequence (inline)")
print("-" * 60)
print("UMI prepended to read sequence (matches some real protocols)\n")
simulator = BulkRNAUMISimulator(
n_genes=500,
total_molecules=5000,
umi_length=10,
read_length=150,
umi_in_sequence=True, # UMI in sequence, not header
pcr_cycles=8,
random_seed=42
)
simulator.run_simulation(output_prefix="output/inline_umi")
print("\nNote: Total read length = 150bp (10bp UMI + 140bp cDNA)")
if __name__ == '__main__':
import os
os.makedirs('output', exist_ok=True)
print("="*70)
print("UMI RNA Simulator - Advanced Examples")
print("="*70)
bacterial_genome()
mouse_chromosome()
custom_parameters()
inline_umi()
print("\n" + "="*70)
print("All examples completed!")
print("="*70)