getrpf 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. getrpf-0.4.0/LICENSE +21 -0
  2. getrpf-0.4.0/PKG-INFO +597 -0
  3. getrpf-0.4.0/README.md +541 -0
  4. getrpf-0.4.0/pyproject.toml +114 -0
  5. getrpf-0.4.0/setup.cfg +4 -0
  6. getrpf-0.4.0/src/getRPF/__init__.py +7 -0
  7. getrpf-0.4.0/src/getRPF/architectures/__init__.py +0 -0
  8. getrpf-0.4.0/src/getRPF/architectures/arabidopsis_thaliana_timeseries.yaml +27 -0
  9. getrpf-0.4.0/src/getRPF/architectures/comprehensive_adapter_check.yaml +50 -0
  10. getrpf-0.4.0/src/getRPF/architectures/ena_riboseq_standard.yaml +24 -0
  11. getrpf-0.4.0/src/getRPF/architectures/err605046_stau1_riboseq.yaml +28 -0
  12. getrpf-0.4.0/src/getRPF/architectures/generic_umi_protocol.yaml +24 -0
  13. getrpf-0.4.0/src/getRPF/architectures/ingolia_2009.yaml +19 -0
  14. getrpf-0.4.0/src/getRPF/architectures/mcglincy_ingolia_2017.yaml +41 -0
  15. getrpf-0.4.0/src/getRPF/architectures/observed_atgtacac_3p_adapter.yaml +33 -0
  16. getrpf-0.4.0/src/getRPF/architectures/observed_ctgtaggc_3p_adapter.yaml +39 -0
  17. getrpf-0.4.0/src/getRPF/architectures/observed_ctgtaggc_variant_3p_adapter.yaml +33 -0
  18. getrpf-0.4.0/src/getRPF/architectures/observed_dual_ligation_adapter_pair.yaml +44 -0
  19. getrpf-0.4.0/src/getRPF/architectures/observed_ingolia_variant_atct_adapter.yaml +32 -0
  20. getrpf-0.4.0/src/getRPF/architectures/observed_nextera_template_switch_6n_adapter.yaml +35 -0
  21. getrpf-0.4.0/src/getRPF/architectures/observed_polya_a10_tail.yaml +39 -0
  22. getrpf-0.4.0/src/getRPF/architectures/observed_protocols_README.md +13 -0
  23. getrpf-0.4.0/src/getRPF/architectures/observed_small_rna_composite_3p_adapter.yaml +39 -0
  24. getrpf-0.4.0/src/getRPF/architectures/observed_small_rna_tgga18_adapter.yaml +33 -0
  25. getrpf-0.4.0/src/getRPF/architectures/observed_small_rna_truseq_composite_adapter.yaml +39 -0
  26. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_18nt_3p_adapter.yaml +31 -0
  27. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_21nt_3p_adapter.yaml +39 -0
  28. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_26nt_3p_adapter.yaml +30 -0
  29. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_core_tcgt_adapter.yaml +31 -0
  30. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_full_34nt_3p_adapter.yaml +35 -0
  31. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_prefixed_aagat_adapter.yaml +31 -0
  32. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_short_agatcggag_adapter.yaml +39 -0
  33. getrpf-0.4.0/src/getRPF/architectures/observed_truseq_variant_atcgtatgcc_adapter.yaml +34 -0
  34. getrpf-0.4.0/src/getRPF/architectures/preprocessed_with_adapter_contamination.yaml +19 -0
  35. getrpf-0.4.0/src/getRPF/architectures/riboflow_template_switch.yaml +32 -0
  36. getrpf-0.4.0/src/getRPF/architectures/tcp_seq_se100.yaml +33 -0
  37. getrpf-0.4.0/src/getRPF/cli.py +1124 -0
  38. getrpf-0.4.0/src/getRPF/core/__init__.py +21 -0
  39. getrpf-0.4.0/src/getRPF/core/apply.py +152 -0
  40. getrpf-0.4.0/src/getRPF/core/checkers.py +564 -0
  41. getrpf-0.4.0/src/getRPF/core/handlers.py +459 -0
  42. getrpf-0.4.0/src/getRPF/core/pipeline.py +237 -0
  43. getrpf-0.4.0/src/getRPF/core/processors/__init__.py +12 -0
  44. getrpf-0.4.0/src/getRPF/core/processors/adapter.py +238 -0
  45. getrpf-0.4.0/src/getRPF/core/processors/alignment.py +629 -0
  46. getrpf-0.4.0/src/getRPF/core/processors/alignment_extractor.py +1401 -0
  47. getrpf-0.4.0/src/getRPF/core/processors/boundary.py +352 -0
  48. getrpf-0.4.0/src/getRPF/core/processors/check.py +241 -0
  49. getrpf-0.4.0/src/getRPF/core/processors/collapsed.py +346 -0
  50. getrpf-0.4.0/src/getRPF/core/processors/consensus.py +98 -0
  51. getrpf-0.4.0/src/getRPF/core/processors/identity_screen.py +226 -0
  52. getrpf-0.4.0/src/getRPF/core/processors/matcher.py +215 -0
  53. getrpf-0.4.0/src/getRPF/core/processors/reporting.py +188 -0
  54. getrpf-0.4.0/src/getRPF/core/processors/rpf_extractor.py +1131 -0
  55. getrpf-0.4.0/src/getRPF/core/processors/segmenter.py +329 -0
  56. getrpf-0.4.0/src/getRPF/core/processors/signals.py +261 -0
  57. getrpf-0.4.0/src/getRPF/core/processors/sketch.py +253 -0
  58. getrpf-0.4.0/src/getRPF/core/processors/types.py +350 -0
  59. getrpf-0.4.0/src/getRPF/core/release.py +286 -0
  60. getrpf-0.4.0/src/getRPF/core/samplesheet.py +192 -0
  61. getrpf-0.4.0/src/getRPF/core/seqspec_generator.py +936 -0
  62. getrpf-0.4.0/src/getRPF/core/seqspec_loader.py +326 -0
  63. getrpf-0.4.0/src/getRPF/core/structure/__init__.py +34 -0
  64. getrpf-0.4.0/src/getRPF/core/structure/align.py +391 -0
  65. getrpf-0.4.0/src/getRPF/core/structure/anchors.py +549 -0
  66. getrpf-0.4.0/src/getRPF/core/structure/assemble.py +322 -0
  67. getrpf-0.4.0/src/getRPF/core/structure/benchmark.py +234 -0
  68. getrpf-0.4.0/src/getRPF/core/structure/config.py +217 -0
  69. getrpf-0.4.0/src/getRPF/core/structure/model.py +146 -0
  70. getrpf-0.4.0/src/getRPF/core/structure/observe.py +143 -0
  71. getrpf-0.4.0/src/getRPF/core/structure/pileup.py +679 -0
  72. getrpf-0.4.0/src/getRPF/core/structure/report.py +159 -0
  73. getrpf-0.4.0/src/getRPF/core/structure/seqspec_io.py +314 -0
  74. getrpf-0.4.0/src/getRPF/core/structure/transform.py +347 -0
  75. getrpf-0.4.0/src/getRPF/core/structure/workflow.py +160 -0
  76. getrpf-0.4.0/src/getRPF/duckdb/ingest.py +351 -0
  77. getrpf-0.4.0/src/getRPF/utils/__init__.py +19 -0
  78. getrpf-0.4.0/src/getRPF/utils/file_utils.py +93 -0
  79. getrpf-0.4.0/src/getRPF/utils/logging.py +63 -0
  80. getrpf-0.4.0/src/getRPF/utils/validation.py +64 -0
  81. getrpf-0.4.0/src/getRPF/viz/__init__.py +1 -0
  82. getrpf-0.4.0/src/getRPF/viz/hmm_plot.py +196 -0
  83. getrpf-0.4.0/src/getRPF/viz/softclip_plot.py +286 -0
  84. getrpf-0.4.0/src/getrpf.egg-info/PKG-INFO +597 -0
  85. getrpf-0.4.0/src/getrpf.egg-info/SOURCES.txt +88 -0
  86. getrpf-0.4.0/src/getrpf.egg-info/dependency_links.txt +1 -0
  87. getrpf-0.4.0/src/getrpf.egg-info/entry_points.txt +2 -0
  88. getrpf-0.4.0/src/getrpf.egg-info/requires.txt +18 -0
  89. getrpf-0.4.0/src/getrpf.egg-info/top_level.txt +1 -0
  90. getrpf-0.4.0/tests/test_cli.py +275 -0
getrpf-0.4.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jack Tierney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
getrpf-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,597 @@
1
+ Metadata-Version: 2.4
2
+ Name: getrpf
3
+ Version: 0.4.0
4
+ Summary: A tool for analyzing Ribosome Protected Fragments (RPFs) from Ribo-seq experiments
5
+ Author-email: Jack Tierney <jackcurragh@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 Jack Tierney
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: bioinformatics,ribo-seq,RPF,sequence-analysis
29
+ Classifier: Development Status :: 3 - Alpha
30
+ Classifier: Intended Audience :: Science/Research
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Requires-Python: >=3.10
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE
39
+ Requires-Dist: click>=8.0.0
40
+ Requires-Dist: biopython>=1.79
41
+ Requires-Dist: numpy>=1.21.0
42
+ Requires-Dist: pyyaml>=6.0
43
+ Requires-Dist: pysam>=0.19.0
44
+ Requires-Dist: matplotlib>=3.7
45
+ Requires-Dist: duckdb>=0.9
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
48
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
49
+ Requires-Dist: black>=22.0.0; extra == "dev"
50
+ Requires-Dist: mypy>=0.900; extra == "dev"
51
+ Requires-Dist: ruff>=0.0.270; extra == "dev"
52
+ Provides-Extra: docs
53
+ Requires-Dist: sphinx>=4.0.0; extra == "docs"
54
+ Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
55
+ Dynamic: license-file
56
+
57
+ # getRPF - Automated Ribosome Protected Fragment Analysis
58
+
59
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
60
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
61
+
62
+ getRPF extracts ribosome-protected fragments (RPFs) from Ribo-seq reads. It detects read architectures, trims technical sequence, checks input quality, and reports the decisions made during extraction.
63
+
64
+ ## Key features
65
+
66
+ - Architecture detection using known protocols, observed patterns, and de novo segmentation
67
+ - Quality checks with categorized failure reports
68
+ - Loading custom protocols from seqspec files
69
+ - Extraction reports containing counts, read-length distributions, and trimming decisions
70
+ - FASTQ, FASTA, and collapsed-read input
71
+
72
+ ## Table of contents
73
+
74
+ - [Installation](#installation)
75
+ - [Quick Start](#quick-start)
76
+ - [Commands Overview](#commands-overview)
77
+ - [User Workflows](#user-workflows)
78
+ - [Input/Output Formats](#inputoutput-formats)
79
+ - [Advanced Usage](#advanced-usage)
80
+ - [Troubleshooting](#troubleshooting)
81
+ - [Contributing](#contributing)
82
+
83
+ ## Installation
84
+
85
+ ### Prerequisites
86
+
87
+ - Python 3.10 or higher
88
+ - Optional: STAR aligner for alignment-based quality checks
89
+ - Optional: conda/mamba for environment management
90
+
91
+ ### Install from Source
92
+
93
+ ```bash
94
+ # Clone the repository
95
+ git clone https://github.com/JackCurragh/get-RPF.git
96
+ cd getRPF
97
+
98
+ # Install in development mode
99
+ pip install -e .
100
+
101
+ # Or install with all dependencies
102
+ pip install -e .[dev,docs]
103
+ ```
104
+
105
+ ### Using conda/mamba
106
+
107
+ ```bash
108
+ # Create environment with required dependencies
109
+ conda create -n getrf python=3.10
110
+ conda activate getrf
111
+
112
+ # Install from source
113
+ pip install -e .
114
+ ```
115
+
116
+ ## Quick start
117
+
118
+ ### 1. Basic RPF Extraction
119
+
120
+ Extract RPFs using built-in architecture database:
121
+
122
+ ```bash
123
+ # Extract from FASTQ file
124
+ getRPF extract-rpf input_reads.fastq output_rpfs.fastq -f fastq
125
+
126
+ # Extract with detailed report in CSV format
127
+ getRPF extract-rpf input_reads.fastq output_rpfs.fastq -f fastq --output-format csv
128
+ ```
129
+
130
+ ### 2. Quality Assessment
131
+
132
+ Check if your data is clean and ready for analysis:
133
+
134
+ ```bash
135
+ # Basic cleanliness check with categorized failure reporting
136
+ getRPF check-cleanliness sample.fastq -f fastq -o reports/
137
+
138
+ # Result examples:
139
+ # CLEAN: sample.fastq passed all cleanliness checks
140
+ # NEEDS_SEQSPEC: Primary failure: end_bias
141
+ ```
142
+
143
+ ### 3. Novel Protocol Support
144
+
145
+ Load custom protocols from seqspec files:
146
+
147
+ ```bash
148
+ # Create directory with your seqspec files
149
+ mkdir my_protocols/
150
+ # Add your protocol.yaml files to my_protocols/
151
+
152
+ # Extract using novel protocols
153
+ getRPF extract-rpf input_reads.fastq output_rpfs.fastq -f fastq --seqspec-dir my_protocols/
154
+ ```
155
+
156
+
157
+
158
+ ### 4. Architecture Detection & Reporting
159
+
160
+ Designed for automated processing with "clean/fail" logic, but generates interactive reports for **post-hoc investigation**:
161
+
162
+ ```bash
163
+ # Run automated detection
164
+ getRPF detect-architecture input.fastq output.fastq --generate-seqspec
165
+
166
+ # View report for detailed investigation: output.report.html
167
+ # Features for post-hoc analysis:
168
+ # - Interactive signal plots to verify UMI/Adapter boundaries
169
+ # - Decision trace to understand why a specific architecture was inferred
170
+ ```
171
+
172
+ ## Commands overview
173
+
174
+ getRPF provides commands for extraction, quality assessment, architecture detection, and adapter analysis.
175
+
176
+
177
+ | Command | Purpose | Use Case |
178
+ |---------|---------|----------|
179
+ | `extract-rpf` | **Main extraction workflow** | Core RPF isolation from raw reads |
180
+ | `check-cleanliness` | **Quality assessment with categorization** | Scale to thousands of samples |
181
+ | `check` | Basic quality analysis | Simple quality metrics |
182
+ | `detect-adapter` | Adapter sequence detection | Contamination analysis |
183
+ | `align-detect` | STAR alignment + feature detection | Alignment-based quality checks |
184
+
185
+ ## User workflows
186
+
187
+ ### Workflow 1: Single Clean Sample
188
+
189
+ For samples that pass quality checks:
190
+
191
+ ```bash
192
+ # 1. Check sample quality
193
+ getRPF check-cleanliness sample.fastq -f fastq -o reports/
194
+ # Result: ✅ CLEAN
195
+
196
+ # 2. Extract RPFs directly
197
+ getRPF extract-rpf sample.fastq rpfs.fastq -f fastq --generate-seqspec
198
+
199
+ # 3. Outputs:
200
+ # - rpfs.fastq (clean RPF sequences)
201
+ # - rpfs.seqspec.yaml (detected architecture)
202
+ # - rpfs.extraction_report.json (statistics)
203
+ ```
204
+
205
+ ### Workflow 2: Batch quality screening
206
+
207
+ Process a directory of samples:
208
+
209
+ ```bash
210
+ # 1. Batch quality screening
211
+ for sample in samples/*.fastq; do
212
+ getRPF check-cleanliness "$sample" -f fastq -o quality_reports/
213
+ done
214
+
215
+ # 2. Results automatically categorized:
216
+ # - Clean samples: Ready for extraction
217
+ # - length_distribution_failures/: Need protocol-specific seqspecs
218
+ # - end_bias_failures/: Need bias-aware seqspecs
219
+ # - low_complexity_failures/: Need adapter contamination removal
220
+ ```
221
+
222
+ ### Workflow 3: Novel Protocol Integration
223
+
224
+ When you have custom/novel protocols:
225
+
226
+ ```bash
227
+ # 1. Create seqspec files for your protocols
228
+ # Example: my_lab_protocol.yaml
229
+ cat > my_protocols/custom_protocol.yaml << EOF
230
+ assay_id: custom_protocol_2024
231
+ name: Custom Lab Protocol
232
+ sequence_spec:
233
+ - region_id: umi
234
+ region_type: umi
235
+ sequence: NNNNNN
236
+ min_len: 6
237
+ max_len: 6
238
+ - region_id: rpf
239
+ region_type: cdna
240
+ min_len: 26
241
+ max_len: 34
242
+ - region_id: adapter
243
+ region_type: adapter
244
+ sequence: AGATCGGAAGAG
245
+ min_len: 12
246
+ max_len: 12
247
+ EOF
248
+
249
+ # 2. Use custom protocols for extraction
250
+ getRPF extract-rpf input.fastq output.fastq -f fastq --seqspec-dir my_protocols/
251
+
252
+ # 3. System automatically detects and uses your custom protocol
253
+ ```
254
+
255
+ ### Workflow 4: Comprehensive Analysis Pipeline
256
+
257
+ Full analysis with all features:
258
+
259
+ ```bash
260
+ #!/bin/bash
261
+ # Complete getRPF analysis pipeline
262
+
263
+ INPUT_FILE="sample.fastq"
264
+ OUTPUT_DIR="analysis_results"
265
+ mkdir -p "$OUTPUT_DIR"
266
+
267
+ echo "=== getRPF Analysis Pipeline ==="
268
+
269
+ # Step 1: Quality Assessment
270
+ echo "1. Checking sample cleanliness..."
271
+ getRPF check-cleanliness "$INPUT_FILE" -f fastq -o "$OUTPUT_DIR/quality/"
272
+
273
+ # Step 2: Extract RPFs with seqspec generation
274
+ echo "2. Extracting RPFs..."
275
+ getRPF extract-rpf "$INPUT_FILE" "$OUTPUT_DIR/clean_rpfs.fastq" \
276
+ -f fastq --generate-seqspec --output-format json
277
+
278
+ # Step 3: Adapter Analysis
279
+ echo "3. Analyzing adapter contamination..."
280
+ getRPF detect-adapter "$INPUT_FILE" -f fastq \
281
+ -a "AGATCGGAAGAGCACACGTCT" -o "$OUTPUT_DIR/adapter_report.txt"
282
+
283
+ # Step 4: Alignment-based validation (if STAR index available)
284
+ if [ -d "/path/to/star/index" ]; then
285
+ echo "4. Alignment validation..."
286
+ getRPF align-detect "$OUTPUT_DIR/clean_rpfs.fastq" \
287
+ -s "/path/to/star/index" -f fastq -o "$OUTPUT_DIR/alignment_report.json"
288
+ fi
289
+
290
+ echo "=== Analysis Complete ==="
291
+ echo "Results in: $OUTPUT_DIR/"
292
+ ```
293
+
294
+ ## Input and output formats
295
+
296
+ ### Supported Input Formats
297
+
298
+ | Format | Extension | Description | Usage |
299
+ |--------|-----------|-------------|--------|
300
+ | **FASTQ** | `.fastq`, `.fq` | Standard format with quality scores | Most common, recommended |
301
+ | **FASTA** | `.fasta`, `.fa` | Sequences only, no quality | When quality not needed |
302
+ | **Collapsed** | `.fasta`, `.fa` | Deduplicated with counts in headers | Memory-efficient for large datasets |
303
+
304
+ ### Input Format Examples
305
+
306
+ **FASTQ Format:**
307
+ ```
308
+ @read_1
309
+ ATGCGATCGCTAGCGATCGCTAGCAGATCGGAAGAG
310
+ +
311
+ IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
312
+ ```
313
+
314
+ **Collapsed FASTA Format:**
315
+ ```
316
+ >read_1_count_150
317
+ ATGCGATCGCTAGCGATCGCTAGC
318
+ >read_2_count_200
319
+ GCGATCGCTAGCGATCGCTAGCA
320
+ ```
321
+
322
+ ### Output Files
323
+
324
+ The main output files are:
325
+
326
+ ```
327
+ analysis_results/
328
+ ├── clean_rpfs.fastq # Extracted RPF sequences
329
+ ├── clean_rpfs.seqspec.yaml # Architecture specification
330
+ ├── clean_rpfs.extraction_report.json # Detailed extraction statistics
331
+ ├── quality/
332
+ │ └── sample_cleanliness_report.txt # Quality assessment results
333
+ └── adapter_report.txt # Adapter contamination analysis
334
+ ```
335
+
336
+ ## Advanced usage
337
+
338
+ ### Custom Architecture Databases
339
+
340
+ Load your own architecture definitions:
341
+
342
+ ```bash
343
+ # Using JSON architecture database
344
+ getRPF extract-rpf input.fastq output.fastq -f fastq --architecture-db my_architectures.json
345
+
346
+ # Using seqspec directory (recommended)
347
+ getRPF extract-rpf input.fastq output.fastq -f fastq --seqspec-dir protocols/
348
+ ```
349
+
350
+ ### Performance Optimization
351
+
352
+ For large datasets:
353
+
354
+ ```bash
355
+ # Limit reads for testing
356
+ getRPF extract-rpf input.fastq output.fastq -f fastq --max-reads 10000
357
+
358
+ # Process collapsed format for memory efficiency
359
+ getRPF extract-rpf collapsed.fasta output.fastq -f collapsed
360
+
361
+ # Parallel processing example
362
+ parallel -j 8 getRPF extract-rpf {} {.}_rpfs.fastq -f fastq ::: samples/*.fastq
363
+ ```
364
+
365
+ ### Integration with Other Tools
366
+
367
+ The output can be passed to standard bioinformatics tools, for example:
368
+
369
+ ```bash
370
+ # Combine with cutadapt for pre-processing
371
+ cutadapt -a AGATCGGAAGAG -o preprocessed.fastq input.fastq
372
+ getRPF extract-rpf preprocessed.fastq rpfs.fastq -f fastq
373
+
374
+ # Chain with downstream analysis
375
+ getRPF extract-rpf input.fastq rpfs.fastq -f fastq
376
+ bowtie2 -x genome_index -U rpfs.fastq -S aligned.sam
377
+
378
+ # Quality control with FastQC
379
+ getRPF extract-rpf input.fastq rpfs.fastq -f fastq
380
+ fastqc rpfs.fastq
381
+ ```
382
+
383
+ ## Quality assessment details
384
+
385
+ The cleanliness checks cover:
386
+
387
+ ### Cleanliness Criteria (All Must Pass)
388
+
389
+ 1. **Length Distribution**: Reads within expected RPF size range (26-35 nt)
390
+ 2. **Information Content**: Uniform complexity across read positions (Shannon entropy)
391
+ 3. **End Bias**: No excessive nucleotide bias at 5' or 3' ends
392
+ 4. **Base Composition**: No extreme positional nucleotide bias
393
+ 5. **GC Content**: Within expected range for ribosomal sequences
394
+
395
+ ### Failure Categorization
396
+
397
+ Failed samples are automatically categorized for efficient batch processing:
398
+
399
+ - **`length_distribution_failures/`**: Wrong size distribution → Find protocol-specific seqspecs
400
+ - **`end_bias_failures/`**: 5'/3' nucleotide bias → Protocol has adapter sequences
401
+ - **`low_complexity_failures/`**: Repetitive sequences → Contamination or degradation
402
+ - **`base_composition_failures/`**: Positional bias → Systematic sequencing artifacts
403
+
404
+ ## seqspec integration
405
+
406
+ Custom protocols can be described with the standard seqspec format:
407
+
408
+ ### Creating seqspec Files
409
+
410
+ ```yaml
411
+ # example_protocol.yaml
412
+ assay_id: lab_protocol_2024
413
+ name: "Custom Ribosome Profiling Protocol"
414
+ description: "Lab-specific protocol with unique barcode structure"
415
+ seqspec_version: 0.3.0
416
+
417
+ sequence_spec:
418
+ - region_id: umi
419
+ region_type: umi
420
+ sequence: NNNNNN
421
+ min_len: 6
422
+ max_len: 6
423
+
424
+ - region_id: sample_barcode
425
+ region_type: barcode
426
+ sequence: NNNNNNNN
427
+ min_len: 8
428
+ max_len: 8
429
+
430
+ - region_id: ribosome_protected_fragment
431
+ region_type: cdna
432
+ min_len: 26
433
+ max_len: 34
434
+
435
+ - region_id: adapter
436
+ region_type: adapter
437
+ sequence: AGATCGGAAGAGCACACGTCT
438
+ min_len: 21
439
+ max_len: 21
440
+ ```
441
+
442
+ ### Using seqspec Protocols
443
+
444
+ ```bash
445
+ # Load all protocols from directory
446
+ getRPF extract-rpf input.fastq output.fastq -f fastq --seqspec-dir my_protocols/
447
+
448
+ # System automatically:
449
+ # 1. Loads all .yaml files in directory
450
+ # 2. Creates detection profiles for each protocol
451
+ # 3. Matches input reads against all protocols
452
+ # 4. Uses best-matching protocol for extraction
453
+ ```
454
+
455
+ ## Troubleshooting
456
+
457
+ ### Common Issues
458
+
459
+ **Issue**: `pysam not available - soft-clipping analysis will be disabled`
460
+ ```bash
461
+ # Solution: Install pysam
462
+ pip install pysam>=0.19.0
463
+ ```
464
+
465
+ **Issue**: `No architecture detected`
466
+ ```bash
467
+ # Solutions:
468
+ # 1. Check if your protocol is in built-in database
469
+ getRPF extract-rpf --help
470
+
471
+ # 2. Create seqspec file for your protocol
472
+ getRPF extract-rpf input.fastq output.fastq -f fastq --seqspec-dir my_protocols/
473
+
474
+ # 3. Use de novo detection (automatic fallback)
475
+ ```
476
+
477
+ **Issue**: Sample fails cleanliness checks
478
+ ```bash
479
+ # Check specific failure type
480
+ getRPF check-cleanliness sample.fastq -f fastq -o reports/
481
+ cat reports/sample_cleanliness_report.txt
482
+
483
+ # Address by failure category:
484
+ # - length_distribution: Need protocol-specific extraction
485
+ # - end_bias: Adapter contamination, create seqspec
486
+ # - low_complexity: Pre-filter with cutadapt
487
+ ```
488
+
489
+ ### Performance Issues
490
+
491
+ **Large files taking too long:**
492
+ ```bash
493
+ # Use collapsed format to reduce memory usage
494
+ # Test with limited reads first
495
+ getRPF extract-rpf input.fastq output.fastq -f fastq --max-reads 10000
496
+
497
+ # Process in parallel
498
+ parallel -j 4 getRPF extract-rpf {} {.}_rpfs.fastq -f fastq ::: *.fastq
499
+ ```
500
+
501
+ **Memory usage too high:**
502
+ ```bash
503
+ # Convert to collapsed format first
504
+ # Use streaming processing for large datasets
505
+ getRPF extract-rpf input.fasta output.fastq -f collapsed
506
+ ```
507
+
508
+ ## Output interpretation
509
+
510
+ ### Extraction Report Example
511
+
512
+ ```json
513
+ {
514
+ "extraction_statistics": {
515
+ "input_reads": 50000,
516
+ "extracted_rpfs": 45230,
517
+ "extraction_rate": 0.9046,
518
+ "mean_rpf_length": 28.4
519
+ },
520
+ "architecture_detection": {
521
+ "method": "pattern_matching",
522
+ "matched_architecture": "mcglincy_2017",
523
+ "confidence": 0.95,
524
+ "lab_source": "McGlincy Lab"
525
+ },
526
+ "quality_metrics": {
527
+ "length_distribution_valid": true,
528
+ "adapter_contamination_rate": 0.02,
529
+ "mean_quality_score": 35.2
530
+ }
531
+ }
532
+ ```
533
+
534
+ ### Cleanliness Report Example
535
+
536
+ ```
537
+ === RPF Data Check Results ===
538
+
539
+ Sample Status: CLEAN
540
+
541
+ Check Summary:
542
+ length_distribution [PASS]
543
+ information_content [PASS]
544
+ end_bias [PASS]
545
+ base_composition [PASS]
546
+ gc_content [PASS]
547
+ ```
548
+
549
+ ## Contributing
550
+
551
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
552
+
553
+ ### Development Setup
554
+
555
+ ```bash
556
+ git clone https://github.com/JackCurragh/get-RPF.git
557
+ cd getRPF
558
+ pip install -e .[dev]
559
+
560
+ # Run tests
561
+ pytest tests/
562
+
563
+ # Code formatting
564
+ black src/ tests/
565
+ isort src/ tests/
566
+
567
+ # Type checking
568
+ mypy src/
569
+ ```
570
+
571
+ ## License
572
+
573
+ This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details.
574
+
575
+ ## Citation
576
+
577
+ If you use getRPF in your research, please cite:
578
+
579
+ ```bibtex
580
+ @software{getRPF,
581
+ title={getRPF: Automated Ribosome Protected Fragment Analysis},
582
+ author={Curragh, Jack},
583
+ year={2024},
584
+ url={https://github.com/JackCurragh/get-RPF}
585
+ }
586
+ ```
587
+
588
+ ## Links
589
+
590
+ - **Documentation**: [Full documentation](https://getRPF.readthedocs.io)
591
+ - **Bug reports**: [GitHub Issues](https://github.com/JackCurragh/get-RPF/issues)
592
+ - **seqspec Format**: [Lior Pachter Lab](https://pachterlab.github.io/seqspec/)
593
+ - **Ribo-seq Resources**: [Ribo-seq.org](https://ribo-seq.org)
594
+
595
+ ---
596
+
597
+ **getRPF** is maintained as part of the Ribo-seq analysis workflow developed by the Ensembl genebuild team.