File size: 2,630 Bytes
6f32cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Exact recipe for this dataset. Every stage is deterministic (pinned OpenGenome2 revision, fixed seed and rate) and
# resumable (finished shards are skipped), so running all stages from scratch reproduces the files bit for bit.
#
# Usage (from the dataset root):  bash scripts/build.sh [stage ...]   stages: euk rest valid finalize stats baseline readme
#   default: all stages in that order. Env: PY (python, default python3), WORKERS (default 14).
#
# Two train passes, because the eukaryotic genomes were sampled before a bug in the window rule was found:
#   euk   ncbi_eukaryotic_genomes with --rule length_weighted: a window of length L is kept with probability
#         rate * L / 16384. Windows are 16384 bases except the last of each segment, so the realized rate is
#         0.964 x rate, slightly lower for segment ends (records are ~20 Mb, segments end at tags/contig breaks).
#   rest  every other subset with --rule per_base (each window kept with probability `rate`, any length).
# Both passes use the same seed, rate, window and held-out species (1%), so heldout/ is built by both.
set -euo pipefail
cd "$(dirname "$0")/.."
PY="${PY:-python3}"
W="${WORKERS:-14}"
RATE=0.001309946368700675
COMMON=(--seed 0 --window 16384 --holdout 0.01 --rate "$RATE" --workers "$W" --out .)
REST=(metagenomes eukaryotic_genic_windows gtdb_v220_imgpr gtdb_v220_stitched mrna imgvr_untagged
      mrna_splice_promoter ncrna organelle imgpr promoters)
STAGES=("$@")
[ ${#STAGES[@]} -gt 0 ] || STAGES=(euk rest valid finalize stats baseline readme)

for stage in "${STAGES[@]}"; do
  echo "== $stage $(date)"
  case "$stage" in
    euk)  "$PY" scripts/og2subset.py sample --split train --subsets ncbi_eukaryotic_genomes --rule length_weighted \
            "${COMMON[@]}" --plan plan_train_eukaryotic.json ;;
    rest) "$PY" scripts/og2subset.py sample --split train --subsets "${REST[@]}" --rule per_base \
            "${COMMON[@]}" --plan plan_train_rest.json ;;
    valid) "$PY" scripts/og2subset.py sample --split valid --target-tokens 100e6 --rule per_base --seed 0 \
            --window 16384 --workers "$W" --out . --plan plan_valid.json ;;
    finalize) for s in train heldout valid; do "$PY" scripts/og2subset.py finalize --split "$s" --out .; done ;;
    stats) "$PY" scripts/og2stats.py --root . --workers "$W" ;;
    baseline) "$PY" scripts/og2baseline.py --root . --workers "$W" ;;
    readme) if [ -f scripts/make_readme.py ]; then "$PY" scripts/make_readme.py --root .; else echo "skip: no make_readme.py"; fi ;;
    *) echo "unknown stage $stage"; exit 1 ;;
  esac
done
echo "== done $(date)"