Mercurial > repos > jpayne > seqsero2s
comparison patch_stringmlst.sh @ 9:4c4899031795 draft
planemo upload commit fcafae43456eb929e62b5c879ac954f75745bbf8
| author | galaxytrakr |
|---|---|
| date | Fri, 15 May 2026 11:44:48 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 8:e3b5ed54af18 | 9:4c4899031795 |
|---|---|
| 1 #!/usr/bin/env bash | |
| 2 | |
| 3 # patch stringMLST.py log path: replace dbPrefix reference with cwd. | |
| 4 # patches all occurrences (at line 1464 and predict section at line 1478). | |
| 5 | |
| 6 set -euo pipefail | |
| 7 | |
| 8 STRINGMLST="$PREFIX/bin/stringMLST.py" | |
| 9 | |
| 10 if [ ! -f "$STRINGMLST" ]; then | |
| 11 echo "SKIP: $STRINGMLST not found" | |
| 12 exit 0 | |
| 13 fi | |
| 14 | |
| 15 python3 << 'PATCH_WITH_PY' | |
| 16 import os | |
| 17 | |
| 18 p = os.path.join(os.environ["PREFIX"], "bin", "stringMLST.py") | |
| 19 with open(p) as f: | |
| 20 lines = f.readlines() | |
| 21 | |
| 22 original = " log = dbPrefix+'.log'\n" | |
| 23 commented = " # log = dbPrefix+'.log'\n" | |
| 24 replacement = ' log = os.path.join(os.getcwd(), "kmer.log")\n' | |
| 25 | |
| 26 # Count occurrences BEFORE modifying | |
| 27 occurrences = lines.count(original) | |
| 28 | |
| 29 if occurrences == 0: | |
| 30 print("SKIP: stringMLST.py has 0 occurrences, expected at least 1") | |
| 31 exit(0) | |
| 32 | |
| 33 out = [] | |
| 34 for line in lines: | |
| 35 if line.rstrip("\n") == original.rstrip("\n"): | |
| 36 out.append(commented) | |
| 37 out.append(replacement) | |
| 38 else: | |
| 39 out.append(line) | |
| 40 | |
| 41 with open(p, "w") as f: | |
| 42 f.writelines(out) | |
| 43 | |
| 44 print("PATCHED: stringMLST.py log path fixed (%d occurrences)" % occurrences) | |
| 45 PATCH_WITH_PY |
