Skip to content

Commit b395c5a

Browse files
committed
modify
1 parent b4e4693 commit b395c5a

12 files changed

Lines changed: 361 additions & 2 deletions

.claude/context/DATA_CATALOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# DATA CATALOG
2+
3+
<!-- Track data assets: raw inputs, intermediates, outputs -->
4+
<!-- Format: Name, Type (raw/intermediate/output), Path, Description, Status (active/deprecated) -->
5+
6+
## Pipeline Databases
7+
- **viroprofiler-db** | raw | `$HOME/viroprofiler/` | All reference databases (CheckV, VirSorter2, DRAM, iPHoP, VIBRANT, vRefSeq, Kraken2, PHAMB, EggNOG) | active
8+
9+
## Test Data
10+
- **test-samplesheet** | raw | `conf/test.config` references GitHub-hosted test data | 5 minimal samples for CI testing | active
11+
- **stub-test-data** | raw | `tests/data/` | Minimal FASTQ.GZ + FASTA for Nextflow `-stub` CI testing (no databases needed); samplesheet uses `${STUB_R1_PATH}`/`${STUB_R2_PATH}` envsubst tokens | active

.claude/context/DECISIONS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# DECISIONS
2+
3+
<!-- Format: DEC-NNN, Date, Decision, Chosen Option, Rejected Alternatives, Rationale -->
4+
<!-- Newest entries at top -->
5+
6+
## DEC-001
7+
**Date:** 2026-04-09
8+
**Decision:** Unified development branch strategy
9+
**Chosen Option:** Single `dev_ru` branch based on origin/dev, rebased onto main
10+
**Rejected Alternatives:** Keep multiple dev branches (dev, se, dev-update_ncbi_taxa); merge all into main directly
11+
**Rationale:** Multiple divergent branches caused confusion. origin/dev was the most complete development line. Local dev had no unique content not already in origin/dev. Consolidating to dev_ru with periodic rebase onto main prevents future divergence.

.claude/context/ERRORS_LEARNED.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# ERRORS LEARNED
2+
3+
<!-- Format: EL-NNN, Date, Context, Error/Symptom, Root Cause, Fix, Prevention Rule, Tag, Reusability -->
4+
<!-- Newest entries at top -->
5+
6+
## EL-009
7+
**Date:** 2026-04-09
8+
**Context:** Dockerfile viroprofiler-geneannot — COPY + dynamic path
9+
**Error/Symptom:** `COPY ./path/file /opt/conda/lib/python3.10/site-packages/pkg/` — Dockerfile `COPY` instruction does not support shell variable expansion, so hardcoded Python version paths will break when conda resolves a different version.
10+
**Root Cause:** Docker `COPY` destination is evaluated at build time without shell; cannot use `$(...)` expansion.
11+
**Fix:** `COPY ./path/file /tmp/file` then `RUN SITE_PKGS=$(python3 -c "import site; print(site.getsitepackages()[0])") && cp /tmp/file $SITE_PKGS/pkg/`
12+
**Prevention Rule:** Never use Python version paths in Dockerfile `COPY` destinations; always COPY to `/tmp/` first, then use a `RUN` layer with `site.getsitepackages()` to move to the correct location.
13+
**Tag:** docker, python, path, COPY
14+
**Reusability:** high
15+
16+
## EL-008
17+
**Date:** 2026-04-09
18+
**Context:** bin/parse_mmseqsTaxa.py — column selection after commented-out initialization
19+
**Error/Symptom:** `df_formatted[['contig_id', ..., 'Strain']]` raises `KeyError: 'Strain'` at runtime when `dbsource == "ICTV"`. No error at import time.
20+
**Root Cause:** The code block that populates the `'Strain'` column (lines 24-30) was commented out, but the column reference in the selector (line 79) was not updated to match.
21+
**Fix:** Remove `'Strain'` from the column selector in line 79 (or restore the extraction logic if Strain is needed).
22+
**Prevention Rule:** When commenting out initialization logic that creates a new column/variable, grep for all downstream references and update or remove them atomically.
23+
**Tag:** python, pandas, commented-code
24+
**Reusability:** high
25+
26+
## EL-007
27+
**Date:** 2026-04-09
28+
**Context:** VIRSORTER2 process stub block
29+
**Error/Symptom:** VIRSORTER2 script uses `ln -s out_vs2/for-dramv/file .` to create top-level symlinks. In stub mode, the source directory doesn't exist, so `ln -s` would fail.
30+
**Root Cause:** Symlinks require source files to exist; in stub mode there are no real tool outputs
31+
**Fix:** Create actual files directly at the expected paths (`cp` instead of `ln -s`) in the stub block
32+
**Prevention Rule:** In Nextflow stub blocks, replace `ln -s` with direct file creation (`cp` or `printf`) — symlinks require source files that don't exist in stub context
33+
**Tag:** nextflow, stub, symlink
34+
**Reusability:** high
35+
36+
## EL-006
37+
**Date:** 2026-04-09
38+
**Context:** VIBRANT process stub + VIRCONTIGS_PRE dependency
39+
**Error/Symptom:** VIBRANT emits `path("VIBRANT_*")` (entire directory), but VIRCONTIGS_PRE directly accesses `${vibrant_dir}/VIBRANT_phages_contigs/contigs.phages_combined.fna` at line 144. A stub that only `touch`es top-level files would make this downstream access fail.
40+
**Root Cause:** Directory emit hides the fact that downstream processes access specific deep paths inside the emitted directory
41+
**Fix:** Stub block must replicate the complete directory structure with all files that downstream processes actually access
42+
**Prevention Rule:** When a process emits a directory, grep all downstream process scripts for paths into that directory — stub must create every accessed path
43+
**Tag:** nextflow, stub, directory-emit, vibrant
44+
**Reusability:** high
45+
46+
## EL-005
47+
**Date:** 2026-04-09
48+
**Context:** Dockerfile for viroprofiler-binning
49+
**Error/Symptom:** `python3.1` in site-packages path — clearly a typo (should be 3.10 or 3.11)
50+
**Root Cause:** Hardcoded Python version path instead of dynamic detection
51+
**Fix:** Use `$(python3 -c "import site; print(site.getsitepackages()[0])")` for dynamic path
52+
**Prevention Rule:** Never hardcode Python version paths in Dockerfiles; always use dynamic detection via `site.getsitepackages()`
53+
**Tag:** docker, python, path
54+
**Reusability:** high
55+
56+
## EL-004
57+
**Date:** 2026-04-09
58+
**Context:** bin/normalize_abundance.py
59+
**Error/Symptom:** `df.applymap()` will fail with pandas >= 2.1.0
60+
**Root Cause:** API deprecated in pandas 2.0, removed in 2.1
61+
**Fix:** Replace `applymap` with `map` (DataFrame.map was added as replacement)
62+
**Prevention Rule:** Check pandas deprecation warnings when using DataFrame methods; `applymap` -> `map`, `append` -> `concat`
63+
**Tag:** python, pandas, deprecation
64+
**Reusability:** high
65+
66+
## EL-003
67+
**Date:** 2026-04-09
68+
**Context:** modules/local/abundance.nf MAPPING2CONTIGS2
69+
**Error/Symptom:** Pipeline would crash on single-end data — `illumina[1]` index out of bounds
70+
**Root Cause:** Defined SE/PE variable but hardcoded PE syntax in the actual command
71+
**Fix:** Use the prepared `$illumina_reads` variable instead of hardcoded `-1 ${illumina[0]} -2 ${illumina[1]}`
72+
**Prevention Rule:** When adding SE support to Nextflow processes, always verify the script block uses the conditional variable, not just the def line
73+
**Tag:** nextflow, single-end, bowtie2
74+
**Reusability:** high
75+
76+
## EL-002
77+
**Date:** 2026-04-09
78+
**Context:** modules/local/binning.nf VAMB process
79+
**Error/Symptom:** `VAMB.out.vamb_clusters_ch` would fail — no named emit exists
80+
**Root Cause:** VAMB outputs defined without `emit:` names, but subworkflow references named emit
81+
**Fix:** Add `emit: vamb_clusters_ch` to the output declaration
82+
**Prevention Rule:** When referencing process outputs by name (`.out.name`), always verify the process has a matching `emit:` declaration
83+
**Tag:** nextflow, emit, channel
84+
**Reusability:** high
85+
86+
## EL-001
87+
**Date:** 2026-04-09
88+
**Context:** workflows/viroprofiler.nf BRACKEN call
89+
**Error/Symptom:** Groovy syntax error — unquoted string interpolation in function argument
90+
**Root Cause:** `${params.db}/kraken2` passed without quotes — Groovy interprets this as code, not a string
91+
**Fix:** Wrap in quotes: `"${params.db}/kraken2"`
92+
**Prevention Rule:** In Nextflow/Groovy, always quote string interpolations when passing paths as process arguments
93+
**Tag:** nextflow, groovy, syntax
94+
**Reusability:** high
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ERRORS LEARNED ARCHIVE
2+
3+
<!-- Archived low-reusability entries moved here when ERRORS_LEARNED.md exceeds 30 entries -->

.claude/context/PLAN.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# PLAN
2+
3+
## Session S-2026-04-09-001
4+
**Date:** 2026-04-09
5+
**Objective:** Branch consolidation and project setup
6+
7+
### Tasks
8+
- [x] Analyze branch structure and divergence (2026-04-09)
9+
- [x] Create unified dev_ru branch from origin/dev (2026-04-09)
10+
- [x] Merge origin/se into dev_ru (2026-04-09)
11+
- [x] Squash 20 commits into 1 on dev_ru (2026-04-09)
12+
- [x] Rebase dev_ru onto latest main (2026-04-09)
13+
- [x] Delete stale remote branches (origin/dev, origin/se, origin/dev-update_ncbi_taxa) (2026-04-09)
14+
- [x] Delete local dev branch (2026-04-09)
15+
- [x] Create CLAUDE.md (2026-04-09)
16+
- [x] Initialize pm context system (2026-04-09)
17+
- [x] Full pipeline audit — identified 4 CRITICAL, 5 HIGH, 4 MEDIUM, 3 LOW issues (2026-04-09)
18+
- [x] Fix all CRITICAL issues: BRACKEN syntax, VAMB emit, VRHYME container/sed, TODO cleanup (2026-04-09)
19+
- [x] Fix all HIGH issues: SE mapping, contig_anno clustering, Python regex/pandas (2026-04-09)
20+
- [x] Fix MEDIUM issues: manifest version, process resources, viewer container tag (2026-04-09)
21+
- [x] Fix Dockerfile: binning Python path (2026-04-09)
22+
- [x] Fix remaining Dockerfiles with hardcoded Python paths (geneannot, replicyc, taxa) — dynamic site.getsitepackages() (2026-04-09)
23+
- [ ] Re-enable Docker CI workflow (.github/workflows/docker.yml)
24+
- [ ] Commit and push all fixes to dev_ru
25+
- [ ] Run test profile to validate pipeline
26+
- [x] Design and implement Nextflow stub testing framework (2026-04-09)
27+
- [x] Add stub blocks to all 45 processes (39 local + 6 nf-core) (2026-04-09)
28+
- [x] Create test infrastructure: tests/data/, conf/test_stub.config, .github/workflows/stub_test.yml (2026-04-09)
29+
- [x] Validate stub tests locally: VIROPROFILER 25/25 ✔, CONTIGANNO 15/15 ✔ (2026-04-09)
30+
- [x] Apply /simplify review fixes: correct stub bugs (abricate filenames/header, abundance CONTIGINDEX versions.yml, VIRSORTER2 creation order); split CI into 2 parallel jobs; replace sed with envsubst; re-validated 25/25 + 15/15 ✔ (2026-04-09)
31+
- [x] Full pipeline improvement audit — generated 18-item suggestions doc (CRITICAL/HIGH/MEDIUM/LOW) (2026-04-09)
32+
- [x] Fix BUG-001: parse_mmseqsTaxa.py Strain KeyError crash on ICTV database (2026-04-09)
33+
- [x] Fix BUG-002: CHECKV while loop `sleep 1` debug residue (2026-04-09)
34+
- [x] Fix BUG-003 + DOCKER-002: taxa Dockerfile — dynamic Python path + remove redundant ASan MMseqs2 source build (2026-04-09)
35+
- [x] Fix SCRIPT-001: normalize_abundance.py vectorized coverage fraction filter (50× speedup) (2026-04-09)
36+
- [x] Fix SCRIPT-002: parse_mmseqsTaxa.py log unclassified contig count (2026-04-09)
37+
- [x] Fix CONFIG-001: max_cpus 1→16, max_memory 8→128 GB, max_time 12→120 h (2026-04-09)
38+
39+
### Blockers
40+
- None
41+
42+
---
43+
44+
## Session S-2026-04-09-002
45+
**Date:** 2026-04-09
46+
**Objective:** Docker CI 恢复、剩余改进项、commit & push
47+
48+
### Tasks
49+
- [ ] Re-enable Docker CI workflow (.github/workflows/docker.yml) — 取消注释全部 11 个镜像构建条目
50+
- [ ] Commit and push all fixes to dev_ru
51+
- [ ] LOGIC-001: 确认 contig_anno.nf 是否需要补全 RESULTS_TSE 调用(或更新文档说明其局限)
52+
- [ ] CONFIG-002: 审查 WorkflowMain.groovy / WorkflowViroprofiler.groovy 中被注释的参数验证逻辑,决定是否恢复
53+
- [ ] DOCKER-003: viroprofiler-virsorter2 Dockerfile 取消注释 micromamba clean 行
54+
- [ ] CI-002: 考虑添加 .github/workflows/lint.yml(nf-core lint + ruff check bin/)
55+
- [ ] Run test profile to validate pipeline
56+
57+
### Blockers
58+
- None

.claude/context/PLAN_ARCHIVE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PLAN ARCHIVE
2+
3+
<!-- Archived sessions moved here when PLAN.md exceeds 3 active sessions -->

.claude/context/ROADMAP.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ROADMAP
2+
3+
## Validated
4+
<!-- Methods and approaches confirmed to work well -->
5+
- Systematic pipeline audit (3 parallel Explore agents: workflow syntax, containers/scripts, cross-references) — effective for catching CRITICAL/HIGH bugs before runtime
6+
- Nextflow stub mode (`-stub` flag) with POSIX-only stub blocks — validates full pipeline topology (channel connections, emit names, output file glob matching) in ~3 minutes without any databases or containers; VIROPROFILER: 25 processes, CONTIGANNO: 15 processes, both pass cleanly
7+
8+
## Pending
9+
<!-- Methods to evaluate in future sessions -->
10+
- Single-end reads support (merged from origin/se, needs testing)
11+
- Contig annotation workflow (contig_anno.nf, needs validation)
12+
13+
## Rejected
14+
<!-- Methods tried and abandoned, with reasons -->
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ViroProfiler Data Workflow Rules
2+
3+
## Pipeline Type
4+
- Nextflow DSL2 bioinformatics pipeline for viral metagenomics
5+
6+
## Database Directory
7+
- Default: `$HOME/viroprofiler/`
8+
- Subdirectories per tool: `checkv/`, `virsorter2/`, `dram/`, `iphop/`, `vibrant/`, `vrefseq/`, `kraken2/`, `phamb/`, `eggnog/`
9+
- Setup via `--mode setup`
10+
11+
## Container Images
12+
- Published under `denglab/` on Docker Hub
13+
- 11 functional groups defined in `conf/modules.config`
14+
- Built from `docker/` subdirectories
15+
16+
## Output Structure
17+
- Default output dir: `output/`
18+
- Each process publishes to `{outdir}/{process_name_lowercase}/`
19+
- Pipeline info: `{outdir}/pipeline_info/`
20+
21+
## Branch Convention
22+
- `main` — stable releases only
23+
- `dev_ru` — active development, rebase onto main periodically

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"SessionStart": [
4+
{
5+
"matcher": "",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "if [ -f .claude/context/PLAN.md ]; then echo '[PM] Project context detected.'; fi; if [ -f .claude/context/MANUSCRIPT_PIPELINE.json ]; then phase=$(python3 -c \"import json; d=json.load(open('.claude/context/MANUSCRIPT_PIPELINE.json')); print(f'Phase {d.get(\\\"current_phase\\\",0)}/6')\" 2>/dev/null || echo 'unknown'); echo \"[MP] Manuscript pipeline active ($phase).\"; fi; if [ -f .claude/context/PLAN.md ]; then echo 'Run /pm sync for full status.'; fi"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

.claude/settings.local.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/allen/.configure/.claude/settings.local.json

0 commit comments

Comments
 (0)