Skip to content

Commit 17257e7

Browse files
committed
added: roundtrip test, test for output-tsv
1 parent 1bc3c53 commit 17257e7

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.github/workflows/csubst-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ jobs:
8080
MPLBACKEND: Agg
8181
run: bash ci/csubst_commands.sh
8282

83+
- name: Validate outputs (schema-lite)
84+
shell: bash -l {0}
85+
run: python ci/check_csubst_outputs.py

ci/check_csubst_outputs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
import glob, sys, os
3+
4+
def check_tsv(path):
5+
with open(path, "r", encoding="utf-8", errors="ignore") as f:
6+
lines = [l.rstrip("\n") for l in f]
7+
assert len(lines) >= 2, f"{path}: 行数が少なすぎます"
8+
header = lines[0].split("\t")
9+
assert len(header) >= 2, f"{path}: タブ区切りのヘッダがありません"
10+
# 代表的なメトリクス名の痕跡(将来名前が変わっても緩めに)
11+
if os.path.basename(path).startswith("csubst_cb_stats"):
12+
assert any(("omegaC" in h) or ("OCN" in h) or ("OCS" in h) for h in header), \
13+
f"{path}: 代表メトリクス列が見当たりません"
14+
15+
def main():
16+
tsvs = sorted(glob.glob("csubst_*.tsv"))
17+
if not tsvs:
18+
print("WARN: csubst_*.tsv がありません(前段で生成できていればOKのはず)")
19+
sys.exit(0)
20+
for t in tsvs:
21+
check_tsv(t)
22+
print(f"OK: {t}")
23+
# IQ-TREE中間の存在も最終確認
24+
for req in ["alignment.fa.state", "alignment.fa.rate"]:
25+
assert os.path.exists(req) and os.path.getsize(req) > 0, f"{req}: 見つからない/空です"
26+
print("OK: IQ-TREE intermediates present")
27+
28+
if __name__ == "__main__":
29+
main()

ci/csubst_commands.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,36 @@ cp -v site.log "$ART" || true
120120

121121
echo "OK: site finished (verified by logs and IQ-TREE intermediates)"
122122

123+
# --- round-trip: simulate の出力を analyze へ ---
124+
MARKER=$(mktemp); sleep 1; touch "$MARKER"
125+
126+
env PYTHONOPTIMIZE=1 csubst simulate \
127+
--alignment_file alignment.fa \
128+
--rooted_tree_file tree.nwk \
129+
--foreground foreground.txt \
130+
--threads 1
131+
132+
SIM_ALN="$(find . -maxdepth 1 -type f \( -name "*.fa" -o -name "*.fasta" -o -name "*.phy" \) -newer "$MARKER" | head -n1)"
133+
[ -s "${SIM_ALN:-}" ] || { echo "ERROR: simulate 出力の配列ファイルが見つかりません"; exit 1; }
134+
135+
MARKER2=$(mktemp); sleep 1; touch "$MARKER2"
136+
env PYTHONOPTIMIZE=1 OMP_NUM_THREADS=1 csubst analyze \
137+
--alignment_file "$SIM_ALN" \
138+
--rooted_tree_file tree.nwk \
139+
--foreground foreground.txt \
140+
--threads 1
141+
142+
NEW_TSV2=($(find . -maxdepth 1 -type f -name "csubst_*.tsv" -newer "$MARKER2" -print))
143+
[ ${#NEW_TSV2[@]} -ge 1 ] || { echo "ERROR: simulate→analyze で TSV が生成されていません"; exit 1; }
144+
echo "OK: round-trip simulate→analyze(created): ${NEW_TSV2[*]}"
145+
123146
echo "Command tests OK"
147+
148+
{
149+
echo "# csubst CI Summary"
150+
echo
151+
echo "## Generated files"
152+
ls -lh | sed 's/^/- /'
153+
} > summary.md
154+
155+
cp -v summary.md "$ART" || true

0 commit comments

Comments
 (0)