Skip to content

Commit ca501ea

Browse files
committed
Fix help-path robustness in remaining core skills
1 parent 7d5fb6b commit ca501ea

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

skills/design-thermostable-mutations/scripts/design_thermostable_mutations.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import sys
1515
from typing import Dict, Iterable, List, Set, Tuple
1616

17-
from Bio import SeqIO
18-
from Bio.SeqUtils.ProtParam import ProteinAnalysis
19-
2017
VALID_AA = set("ACDEFGHIKLMNPQRSTVWY")
2118
AMBIGUOUS_AA = set("BZXJUO")
2219

@@ -46,6 +43,16 @@
4643
MUTATION_RE = re.compile(r"^([A-Z])(\d+)([A-Z])$")
4744

4845

46+
def try_import_biopython():
47+
try:
48+
from Bio import SeqIO as _seqio
49+
from Bio.SeqUtils.ProtParam import ProteinAnalysis as _protein_analysis
50+
return _seqio, _protein_analysis
51+
except ImportError:
52+
print("ERROR: biopython is not installed. Install with: pip install biopython", file=sys.stderr)
53+
sys.exit(1)
54+
55+
4956
def normalize_sequence(seq: str) -> str:
5057
return seq.replace("\n", "").replace("\r", "").replace(" ", "").upper()
5158

@@ -59,7 +66,8 @@ def validate_sequence(seq: str) -> Tuple[bool, bool]:
5966

6067

6168
def read_fasta(path: str, record_id: str | None) -> Tuple[str, str]:
62-
parser = SeqIO.parse(path, "fasta")
69+
seqio, _ = try_import_biopython()
70+
parser = seqio.parse(path, "fasta")
6371

6472
if record_id:
6573
for rec in parser:
@@ -156,7 +164,8 @@ def is_conservative_substitution(wt: str, mut: str) -> bool:
156164

157165

158166
def predict_thermostability_score(sequence: str) -> Dict[str, object]:
159-
protein = ProteinAnalysis(sequence)
167+
_, protein_analysis = try_import_biopython()
168+
protein = protein_analysis(sequence)
160169
aa_raw = protein.amino_acids_percent
161170
aa = {
162171
residue: (value / 100.0 if value > 1.0 else value)

skills/structured-intelligence-skill-creator/scripts/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ the repository's canonical scaffold script.
1010
EOF
1111
}
1212

13+
if [[ $# -eq 1 && ( "$1" == "-h" || "$1" == "--help" ) ]]; then
14+
usage
15+
exit 0
16+
fi
17+
1318
if [[ $# -lt 1 || $# -gt 2 ]]; then
1419
usage
1520
exit 1

0 commit comments

Comments
 (0)