When to use
Use this skill when the user provides their own:
- clinical phenotypes / symptoms / diagnoses (free text, bullet lists, clinical note-like text), and/or
- drugs/medications (names, dosages, frequencies).
Examples that should trigger:
- “Symptoms: ataxia, seizures, developmental delay. Meds: levetiracetam 500 mg BID.”
- “I’m taking metformin 500mg daily and have fatigue, polyuria, blurry vision.”
When NOT to use
Do not use this skill when:
- The user asks general questions (e.g., “What is HPO?”, “What is a phenotype?”, “What is GLP-1?”).
- The user provides text that is not personal clinical information (news articles, academic paragraphs, code, etc.).
- The user asks you to interpret someone else’s private clinical record (PHI) without clear permission.
Safety & privacy
- Treat user input as potentially sensitive clinical information.
- Do not upload user text or extracted results anywhere (this skill is local-only).
- Before writing any input to disk, redact obvious identifiers:
- emails, phone numbers, street addresses
- MRN-like long numeric identifiers (e.g., 8+ digits)
- names when clearly presented as “Name: …”
- If the message appears to include highly identifying PHI (e.g., name + DOB + address, or name + MRN), pause and ask for confirmation to proceed, recommending the user remove identifiers first.
Requirements / setup
- Python:
python3 available on PATH.
- Network access (only for initial PhenoSnap download if missing).
- HPO OBO file:
- Default expected path:
{baseDir}/resources/hp.obo
- Override path via environment variable:
HPO_OBO_PATH
- This skill does not auto-download
hp.obo. You must supply it.
Recommended (best practice):
- Use a virtual environment (venv/conda) before running this skill, because it may install Python packages via
pip.
Inputs & outputs
- Input text file (redacted):
{baseDir}/artifacts/phenosnap_inputs/input_<YYYYMMDD_HHMMSS>.txt
- Output JSON file (timestamped):
{baseDir}/artifacts/phenosnap_outputs/phenotypes_<YYYYMMDD_HHMMSS>.json
- Third-party download cache:
{baseDir}/third_party/phenosnap_main.zip
{baseDir}/third_party/get-pip.py
Detection heuristic (activation check)
Trigger if the user message contains any of:
- phenotype cues:
symptom(s), phenotype(s), Dx, diagnosis, PMH, Hx, history of, or a symptom-like list
- medication cues:
meds, medications, taking, prescribed, plus patterns like:
- dosages:
\b\d+(\.\d+)?\s?(mg|mcg|g|ml|units)\b
- frequencies:
qd, q.d., bid, b.i.d., tid, t.i.d., qhs, qAM, qPM, daily, weekly
Do not trigger for purely informational questions without user-provided phenotype/medication content.
Procedure
0) Create required directories
Create if missing:
{baseDir}/PhenoSnap/
{baseDir}/artifacts/phenosnap_inputs/
{baseDir}/artifacts/phenosnap_outputs/
{baseDir}/resources/
{baseDir}/third_party/
1) Confirm / redact sensitive identifiers
- Scan the user message for identifiers (email/phone/address/MRN/name fields).
- If strongly identifying PHI is present (name + DOB/address/MRN):
- Ask the user to confirm proceeding and recommend removing identifiers.
- Produce a redacted version of the user text:
- Replace emails with
[REDACTED_EMAIL]
- Replace phone numbers with
[REDACTED_PHONE]
- Replace long numeric IDs with
[REDACTED_ID]
- Replace address-like patterns with
[REDACTED_ADDRESS]
- Replace explicit “Name: …” fields with
Name: [REDACTED_NAME]
2) Ensure PhenoSnap exists locally
Target location: {baseDir}/PhenoSnap/
2A) If {baseDir}/PhenoSnap/ exists and contains extract_phenotypes.py
Proceed to dependency self-test.
2B) If {baseDir}/PhenoSnap/ does NOT exist (or missing extract_phenotypes.py)
Prefer git; fallback to zip.
If git is available
Run:
git clone https://github.com/WGLab/PhenoSnap.git "{baseDir}/PhenoSnap"
If git is NOT available
Download zip:
- URL:
https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip
- Destination:
{baseDir}/third_party/phenosnap_main.zip
Download method (pick first available):
- If
curl exists:
curl -L "https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip" -o "{baseDir}/third_party/phenosnap_main.zip"
- Else on Windows PowerShell:
Invoke-WebRequest -Uri "https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip" -OutFile "{baseDir}/third_party/phenosnap_main.zip"
Unzip (choose by OS/tools):
- Windows PowerShell:
Expand-Archive -Path "{baseDir}/third_party/phenosnap_main.zip" -DestinationPath "{baseDir}/third_party/phenosnap_unzip" -Force
- macOS/Linux with unzip:
unzip -o "{baseDir}/third_party/phenosnap_main.zip" -d "{baseDir}/third_party/phenosnap_unzip"
If neither unzip nor Expand-Archive is available, use Python:
python3 -c "import zipfile; z=zipfile.ZipFile(r'{baseDir}/third_party/phenosnap_main.zip'); z.extractall(r'{baseDir}/third_party/phenosnap_unzip')"
Then rename/move the extracted folder to {baseDir}/PhenoSnap/:
- The extracted folder is typically
{baseDir}/third_party/phenosnap_unzip/PhenoSnap-main
- Move/rename to
{baseDir}/PhenoSnap/
Final check:
- Verify
{baseDir}/PhenoSnap/extract_phenotypes.py exists.
- If not found, stop and report the directory listing of
{baseDir}/PhenoSnap/ and {baseDir}/third_party/phenosnap_unzip/.
3) Dependency self-test and auto-install
Run from inside {baseDir}/PhenoSnap/.
3A) Smoke test importability
Run:
python3 -c "import importlib.util; spec=importlib.util.spec_from_file_location('extract_phenotypes','extract_phenotypes.py'); m=importlib.util.module_from_spec(spec); spec.loader.exec_module(m); print('ok')"
If it prints ok, proceed.
3B) If smoke test fails with missing module (ModuleNotFoundError / ImportError)
Step 1: Ensure pip exists for python3
Check:
If that fails, try:
python3 -m ensurepip --upgrade
Check again:
If still failing, bootstrap pip via get-pip.py:
- Download
https://bootstrap.pypa.io/get-pip.py to {baseDir}/third_party/get-pip.py
- with curl:
curl -L "https://bootstrap.pypa.io/get-pip.py" -o "{baseDir}/third_party/get-pip.py"
- or PowerShell:
Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile "{baseDir}/third_party/get-pip.py"
- Install:
python3 "{baseDir}/third_party/get-pip.py"
- Verify:
If pip still cannot be used, stop and report the error output.
Step 2: Install PhenoSnap dependencies
From {baseDir}/PhenoSnap/, run:
python3 -m pip install -r requirements.txt
Step 3: Re-run smoke test once
Re-run:
python3 -c "import importlib.util; spec=importlib.util.spec_from_file_location('extract_phenotypes','extract_phenotypes.py'); m=importlib.util.module_from_spec(spec); spec.loader.exec_module(m); print('ok')"
If still failing, stop and return:
- the missing module name (from error)
- the command output
- recommended fix (use a venv/conda env; verify python3/pip; rerun pip install)
4) Prepare HPO OBO path
Resolve HPO OBO path in this order:
- If env var
HPO_OBO_PATH is set and file exists, use that.
- Else use
{baseDir}/resources/hp.obo if it exists.
If the resolved file does not exist:
- Stop and tell the user to place
hp.obo at {baseDir}/resources/hp.obo or set HPO_OBO_PATH to its full path.
5) Write input file (redacted)
- Timestamp format:
YYYYMMDD_HHMMSS (local time).
- Write redacted user text to:
{baseDir}/artifacts/phenosnap_inputs/input_<TS>.txt
6) Run extraction
From {baseDir}/PhenoSnap/, run:
python3 extract_phenotypes.py --input-file "{baseDir}/artifacts/phenosnap_inputs/input_<TS>.txt" --hpo-obo "<HPO_OBO_PATH>" --output "{baseDir}/artifacts/phenosnap_outputs/phenotypes_<TS>.json" --format json
Validate:
- Output file exists
- Output file is non-empty
If validation fails:
- Return stderr/stdout
- Provide troubleshooting steps (missing hp.obo, permission issues, dependency issues)
7) Respond to user
Return a concise confirmation:
- Detected content: “phenotypes” and/or “medications”
- Input file path (redacted)
- Output file path (timestamped JSON)
- Note: no data uploaded; local-only
- Any warnings (e.g., missing hp.obo, PHI redaction/confirmation)
Troubleshooting
- PhenoSnap folder exists but script missing: confirm
{baseDir}/PhenoSnap/extract_phenotypes.py exists.
- No git: zip fallback should run; ensure curl/PowerShell is available for download.
- Unzip fails: use Python zipfile fallback.
- pip missing: ensurepip then get-pip.py steps above; consider installing Python with “pip” included.
- Permission errors installing packages: use a virtual environment:
python3 -m venv .venv then activate and rerun skill.
- hp.obo missing: place file at
{baseDir}/resources/hp.obo or set HPO_OBO_PATH.
Examples
Example 1 (phenotypes + meds)
User:
- “Symptoms: developmental delay, seizures, ataxia. Meds: valproate 250 mg BID.”
Action:
- Write redacted input → run PhenoSnap → output
phenotypes_<TS>.json
Example 2 (meds only)
User:
- “Current meds: metformin 500mg daily, atorvastatin 20 mg qhs.”
Action:
- Extract medication entities/phenotype-related terms supported by PhenoSnap → output JSON
Example 3 (should NOT trigger)
User:
- “What is the Human Phenotype Ontology and how is it used?”
Action:
- Do not run extraction; answer informationally outside this skill.
1---
2name: phenosnap-phenotype-extractor
3description: Extract clinical phenotypes and medication entities from user-provided text using PhenoSnap, producing a timestamped JSON output.
4user-invocable: true
5metadata:
6 source: https://skillmd.com/skills/modbender/phenosnap-phenotype-extractor
7 openclaw:
8 requires:
9 bins:
10 - python3
11 anyBins:
12 - git
13 - curl
14 - powershell
15 env:
16 - HPO_OBO_PATH
17 primaryEnv: HPO_OBO_PATH
18---
19
20## When to use
21Use this skill when the user provides **their own**:
22- clinical phenotypes / symptoms / diagnoses (free text, bullet lists, clinical note-like text), and/or
23- drugs/medications (names, dosages, frequencies).
24
25Examples that should trigger:
26- “Symptoms: ataxia, seizures, developmental delay. Meds: levetiracetam 500 mg BID.”
27- “I’m taking metformin 500mg daily and have fatigue, polyuria, blurry vision.”
28
29## When NOT to use
30Do **not** use this skill when:
31- The user asks general questions (e.g., “What is HPO?”, “What is a phenotype?”, “What is GLP-1?”).
32- The user provides text that is not personal clinical information (news articles, academic paragraphs, code, etc.).
33- The user asks you to interpret *someone else’s* private clinical record (PHI) without clear permission.
34
35## Safety & privacy
36- Treat user input as potentially sensitive clinical information.
37- **Do not upload** user text or extracted results anywhere (this skill is local-only).
38- Before writing any input to disk, **redact obvious identifiers**:
39 - emails, phone numbers, street addresses
40 - MRN-like long numeric identifiers (e.g., 8+ digits)
41 - names when clearly presented as “Name: …”
42- If the message appears to include **highly identifying PHI** (e.g., name + DOB + address, or name + MRN), **pause and ask for confirmation** to proceed, recommending the user remove identifiers first.
43
44## Requirements / setup
45- Python: `python3` available on PATH.
46- Network access (only for initial PhenoSnap download if missing).
47- HPO OBO file:
48 - Default expected path: `{baseDir}/resources/hp.obo`
49 - Override path via environment variable: `HPO_OBO_PATH`
50 - This skill **does not auto-download** `hp.obo`. You must supply it.
51
52Recommended (best practice):
53- Use a virtual environment (venv/conda) before running this skill, because it may install Python packages via `pip`.
54
55## Inputs & outputs
56- Input text file (redacted):
57 - `{baseDir}/artifacts/phenosnap_inputs/input_<YYYYMMDD_HHMMSS>.txt`
58- Output JSON file (timestamped):
59 - `{baseDir}/artifacts/phenosnap_outputs/phenotypes_<YYYYMMDD_HHMMSS>.json`
60- Third-party download cache:
61 - `{baseDir}/third_party/phenosnap_main.zip`
62 - `{baseDir}/third_party/get-pip.py`
63
64## Detection heuristic (activation check)
65Trigger if the user message contains **any** of:
66- phenotype cues: `symptom(s)`, `phenotype(s)`, `Dx`, `diagnosis`, `PMH`, `Hx`, `history of`, or a symptom-like list
67- medication cues: `meds`, `medications`, `taking`, `prescribed`, plus patterns like:
68 - dosages: `\b\d+(\.\d+)?\s?(mg|mcg|g|ml|units)\b`
69 - frequencies: `qd`, `q.d.`, `bid`, `b.i.d.`, `tid`, `t.i.d.`, `qhs`, `qAM`, `qPM`, `daily`, `weekly`
70
71Do not trigger for purely informational questions without user-provided phenotype/medication content.
72
73---
74
75# Procedure
76
77## 0) Create required directories
78Create if missing:
79- `{baseDir}/PhenoSnap/`
80- `{baseDir}/artifacts/phenosnap_inputs/`
81- `{baseDir}/artifacts/phenosnap_outputs/`
82- `{baseDir}/resources/`
83- `{baseDir}/third_party/`
84
85## 1) Confirm / redact sensitive identifiers
861) Scan the user message for identifiers (email/phone/address/MRN/name fields).
872) If strongly identifying PHI is present (name + DOB/address/MRN):
88 - Ask the user to confirm proceeding and recommend removing identifiers.
893) Produce a redacted version of the user text:
90 - Replace emails with `[REDACTED_EMAIL]`
91 - Replace phone numbers with `[REDACTED_PHONE]`
92 - Replace long numeric IDs with `[REDACTED_ID]`
93 - Replace address-like patterns with `[REDACTED_ADDRESS]`
94 - Replace explicit “Name: …” fields with `Name: [REDACTED_NAME]`
95
96## 2) Ensure PhenoSnap exists locally
97Target location: `{baseDir}/PhenoSnap/`
98
99### 2A) If `{baseDir}/PhenoSnap/` exists and contains `extract_phenotypes.py`
100Proceed to dependency self-test.
101
102### 2B) If `{baseDir}/PhenoSnap/` does NOT exist (or missing `extract_phenotypes.py`)
103Prefer git; fallback to zip.
104
105#### If `git` is available
106Run:
107- `git clone https://github.com/WGLab/PhenoSnap.git "{baseDir}/PhenoSnap"`
108
109#### If `git` is NOT available
110Download zip:
111- URL: `https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip`
112- Destination: `{baseDir}/third_party/phenosnap_main.zip`
113
114Download method (pick first available):
115- If `curl` exists:
116 - `curl -L "https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip" -o "{baseDir}/third_party/phenosnap_main.zip"`
117- Else on Windows PowerShell:
118 - `Invoke-WebRequest -Uri "https://github.com/WGLab/PhenoSnap/archive/refs/heads/main.zip" -OutFile "{baseDir}/third_party/phenosnap_main.zip"`
119
120Unzip (choose by OS/tools):
121- Windows PowerShell:
122 - `Expand-Archive -Path "{baseDir}/third_party/phenosnap_main.zip" -DestinationPath "{baseDir}/third_party/phenosnap_unzip" -Force`
123- macOS/Linux with unzip:
124 - `unzip -o "{baseDir}/third_party/phenosnap_main.zip" -d "{baseDir}/third_party/phenosnap_unzip"`
125
126If neither unzip nor Expand-Archive is available, use Python:
127- `python3 -c "import zipfile; z=zipfile.ZipFile(r'{baseDir}/third_party/phenosnap_main.zip'); z.extractall(r'{baseDir}/third_party/phenosnap_unzip')"`
128
129Then rename/move the extracted folder to `{baseDir}/PhenoSnap/`:
130- The extracted folder is typically `{baseDir}/third_party/phenosnap_unzip/PhenoSnap-main`
131- Move/rename to `{baseDir}/PhenoSnap/`
132
133Final check:
134- Verify `{baseDir}/PhenoSnap/extract_phenotypes.py` exists.
135- If not found, stop and report the directory listing of `{baseDir}/PhenoSnap/` and `{baseDir}/third_party/phenosnap_unzip/`.
136
137## 3) Dependency self-test and auto-install
138Run from inside `{baseDir}/PhenoSnap/`.
139
140### 3A) Smoke test importability
141Run:
142- `python3 -c "import importlib.util; spec=importlib.util.spec_from_file_location('extract_phenotypes','extract_phenotypes.py'); m=importlib.util.module_from_spec(spec); spec.loader.exec_module(m); print('ok')"`
143
144If it prints `ok`, proceed.
145
146### 3B) If smoke test fails with missing module (ModuleNotFoundError / ImportError)
147#### Step 1: Ensure pip exists for python3
148Check:
149- `python3 -m pip --version`
150
151If that fails, try:
152- `python3 -m ensurepip --upgrade`
153
154Check again:
155- `python3 -m pip --version`
156
157If still failing, bootstrap pip via get-pip.py:
158- Download `https://bootstrap.pypa.io/get-pip.py` to `{baseDir}/third_party/get-pip.py`
159 - with curl:
160 - `curl -L "https://bootstrap.pypa.io/get-pip.py" -o "{baseDir}/third_party/get-pip.py"`
161 - or PowerShell:
162 - `Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile "{baseDir}/third_party/get-pip.py"`
163- Install:
164 - `python3 "{baseDir}/third_party/get-pip.py"`
165- Verify:
166 - `python3 -m pip --version`
167
168If pip still cannot be used, stop and report the error output.
169
170#### Step 2: Install PhenoSnap dependencies
171From `{baseDir}/PhenoSnap/`, run:
172- `python3 -m pip install -r requirements.txt`
173
174#### Step 3: Re-run smoke test once
175Re-run:
176- `python3 -c "import importlib.util; spec=importlib.util.spec_from_file_location('extract_phenotypes','extract_phenotypes.py'); m=importlib.util.module_from_spec(spec); spec.loader.exec_module(m); print('ok')"`
177
178If still failing, stop and return:
179- the missing module name (from error)
180- the command output
181- recommended fix (use a venv/conda env; verify python3/pip; rerun pip install)
182
183## 4) Prepare HPO OBO path
184Resolve HPO OBO path in this order:
1851) If env var `HPO_OBO_PATH` is set and file exists, use that.
1862) Else use `{baseDir}/resources/hp.obo` if it exists.
187
188If the resolved file does not exist:
189- Stop and tell the user to place `hp.obo` at `{baseDir}/resources/hp.obo` or set `HPO_OBO_PATH` to its full path.
190
191## 5) Write input file (redacted)
192- Timestamp format: `YYYYMMDD_HHMMSS` (local time).
193- Write redacted user text to:
194 - `{baseDir}/artifacts/phenosnap_inputs/input_<TS>.txt`
195
196## 6) Run extraction
197From `{baseDir}/PhenoSnap/`, run:
198- `python3 extract_phenotypes.py --input-file "{baseDir}/artifacts/phenosnap_inputs/input_<TS>.txt" --hpo-obo "<HPO_OBO_PATH>" --output "{baseDir}/artifacts/phenosnap_outputs/phenotypes_<TS>.json" --format json`
199
200Validate:
201- Output file exists
202- Output file is non-empty
203
204If validation fails:
205- Return stderr/stdout
206- Provide troubleshooting steps (missing hp.obo, permission issues, dependency issues)
207
208## 7) Respond to user
209Return a concise confirmation:
210- Detected content: “phenotypes” and/or “medications”
211- Input file path (redacted)
212- Output file path (timestamped JSON)
213- Note: no data uploaded; local-only
214- Any warnings (e.g., missing hp.obo, PHI redaction/confirmation)
215
216---
217
218# Troubleshooting
219- **PhenoSnap folder exists but script missing:** confirm `{baseDir}/PhenoSnap/extract_phenotypes.py` exists.
220- **No git:** zip fallback should run; ensure curl/PowerShell is available for download.
221- **Unzip fails:** use Python zipfile fallback.
222- **pip missing:** ensurepip then get-pip.py steps above; consider installing Python with “pip” included.
223- **Permission errors installing packages:** use a virtual environment:
224 - `python3 -m venv .venv` then activate and rerun skill.
225- **hp.obo missing:** place file at `{baseDir}/resources/hp.obo` or set `HPO_OBO_PATH`.
226
227---
228
229# Examples
230
231## Example 1 (phenotypes + meds)
232User:
233- “Symptoms: developmental delay, seizures, ataxia. Meds: valproate 250 mg BID.”
234
235Action:
236- Write redacted input → run PhenoSnap → output `phenotypes_<TS>.json`
237
238## Example 2 (meds only)
239User:
240- “Current meds: metformin 500mg daily, atorvastatin 20 mg qhs.”
241
242Action:
243- Extract medication entities/phenotype-related terms supported by PhenoSnap → output JSON
244
245## Example 3 (should NOT trigger)
246User:
247- “What is the Human Phenotype Ontology and how is it used?”
248
249Action:
250- Do not run extraction; answer informationally outside this skill.