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