Skip to content

Commit 6c14f6b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ee6c345 commit 6c14f6b

7 files changed

Lines changed: 82 additions & 120 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ gsmap --help
6060
gsMap supports AI-assisted workflows that allow users to run spatial GWAS
6161
analysis using modern AI coding agents and Vibe coding environments.
6262
To add the gsMap MCP server and SKILLs in Claude Code:
63+
6364
```bash
6465
cd gsMap/gsmap_vibe
6566
uv pip install -e .
@@ -71,7 +72,6 @@ cp -r gsmap_skill ~/.claude/skills/
7172

7273
Please check out the documentation and tutorials at [gsMap Documentation](https://yanglab.westlake.edu.cn/gsmap/document/software).
7374

74-
7575
## 🌐 Online Visualization
7676

7777
To visualize the traits-cell association spatial maps,

gsmap_vibe/gsmap_mcp/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .server import main
22

3-
main()
3+
main()

gsmap_vibe/gsmap_mcp/docs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ def search_docs(query: str):
1313
results = []
1414

1515
for line in text.splitlines():
16-
1716
if query.lower() in line.lower():
1817
results.append(line.strip())
1918

20-
return "\n".join(results[:20])
19+
return "\n".join(results[:20])

gsmap_vibe/gsmap_mcp/server.py

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from mcp.server.fastmcp import FastMCP
2-
from .tools import *
2+
33
from .docs import search_docs
4+
from .tools import *
45

56
mcp = FastMCP("gsmap")
67

@@ -58,11 +59,7 @@ def download_example_dataset(output_dir: str):
5859

5960

6061
@mcp.tool()
61-
def gsmap_format_sumstats(
62-
sumstats: str,
63-
out: str,
64-
args: list[str] = []
65-
):
62+
def gsmap_format_sumstats(sumstats: str, out: str, args: list[str] = []):
6663
"""
6764
Convert GWAS summary statistics into gsMap-compatible format.
6865
@@ -107,11 +104,7 @@ def gsmap_format_sumstats(
107104

108105
@mcp.tool()
109106
def gsmap_quick_mode(
110-
workdir: str,
111-
hdf5_path: str,
112-
sumstats_file: str,
113-
trait_name: str,
114-
args: list[str] = []
107+
workdir: str, hdf5_path: str, sumstats_file: str, trait_name: str, args: list[str] = []
115108
):
116109
"""
117110
Run the gsMap quick_mode pipeline.
@@ -151,21 +144,12 @@ def gsmap_quick_mode(
151144
152145
Use this tool for most spatial GWAS analyses.
153146
"""
154-
return run_quick_mode(
155-
workdir,
156-
hdf5_path,
157-
sumstats_file,
158-
trait_name,
159-
args
160-
)
147+
return run_quick_mode(workdir, hdf5_path, sumstats_file, trait_name, args)
161148

162149

163150
@mcp.tool()
164151
def gsmap_find_latent_representation(
165-
workdir: str,
166-
sample_name: str,
167-
hdf5_path: str,
168-
args: list[str] = []
152+
workdir: str, sample_name: str, hdf5_path: str, args: list[str] = []
169153
):
170154
"""
171155
Step 1 of the gsMap step-by-step pipeline.
@@ -188,21 +172,11 @@ def gsmap_find_latent_representation(
188172
Optional additional CLI parameters for the latent
189173
representation learning step.
190174
"""
191-
return find_latent_representation(
192-
workdir,
193-
sample_name,
194-
hdf5_path,
195-
args
196-
)
175+
return find_latent_representation(workdir, sample_name, hdf5_path, args)
197176

198177

199178
@mcp.tool()
200-
def gsmap_latent_to_gene(
201-
workdir: str,
202-
sample_name: str,
203-
hdf5_path: str,
204-
args: list[str] = []
205-
):
179+
def gsmap_latent_to_gene(workdir: str, sample_name: str, hdf5_path: str, args: list[str] = []):
206180
"""
207181
Step 2 of the gsMap step-by-step pipeline.
208182
@@ -223,21 +197,11 @@ def gsmap_latent_to_gene(
223197
args : list[str]
224198
Optional additional CLI flags.
225199
"""
226-
return latent_to_gene(
227-
workdir,
228-
sample_name,
229-
hdf5_path,
230-
args
231-
)
200+
return latent_to_gene(workdir, sample_name, hdf5_path, args)
232201

233202

234203
@mcp.tool()
235-
def gsmap_generate_ldscore(
236-
workdir: str,
237-
sample_name: str,
238-
chromosome: int,
239-
args: list[str] = []
240-
):
204+
def gsmap_generate_ldscore(workdir: str, sample_name: str, chromosome: int, args: list[str] = []):
241205
"""
242206
Step 3 of the gsMap step-by-step pipeline.
243207
@@ -257,21 +221,12 @@ def gsmap_generate_ldscore(
257221
args : list[str]
258222
Optional additional CLI flags.
259223
"""
260-
return generate_ldscore(
261-
workdir,
262-
sample_name,
263-
chromosome,
264-
args
265-
)
224+
return generate_ldscore(workdir, sample_name, chromosome, args)
266225

267226

268227
@mcp.tool()
269228
def gsmap_spatial_ldsc(
270-
workdir: str,
271-
sample_name: str,
272-
sumstats_file: str,
273-
trait_name: str,
274-
args: list[str] = []
229+
workdir: str, sample_name: str, sumstats_file: str, trait_name: str, args: list[str] = []
275230
):
276231
"""
277232
Step 4 of the gsMap step-by-step pipeline.
@@ -296,13 +251,7 @@ def gsmap_spatial_ldsc(
296251
args : list[str]
297252
Optional additional CLI parameters.
298253
"""
299-
return spatial_ldsc(
300-
workdir,
301-
sample_name,
302-
sumstats_file,
303-
trait_name,
304-
args
305-
)
254+
return spatial_ldsc(workdir, sample_name, sumstats_file, trait_name, args)
306255

307256

308257
@mcp.tool()
@@ -324,4 +273,4 @@ def search_gsmap_docs(query: str):
324273

325274

326275
def main():
327-
mcp.run()
276+
mcp.run()

gsmap_vibe/gsmap_mcp/tools.py

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import subprocess
2-
import urllib.request
32
import tarfile
3+
import urllib.request
44
from pathlib import Path
55

6-
76
GSMAP_RESOURCE_URL = "https://yanglab.westlake.edu.cn/data/gsMap/gsMap_resource.tar.gz"
87
GSMAP_EXAMPLE_URL = "https://yanglab.westlake.edu.cn/data/gsMap/Visium_example_data.tar.gz"
98

109

1110
def run_command(cmd):
1211

13-
result = subprocess.run(
14-
cmd,
15-
capture_output=True,
16-
text=True
17-
)
12+
result = subprocess.run(cmd, capture_output=True, text=True)
1813

1914
if result.returncode != 0:
2015
raise RuntimeError(result.stderr)
@@ -66,8 +61,10 @@ def format_sumstats(sumstats, out, args):
6661
cmd = [
6762
"gsmap",
6863
"format_sumstats",
69-
"--sumstats", sumstats,
70-
"--out", out,
64+
"--sumstats",
65+
sumstats,
66+
"--out",
67+
out,
7168
]
7269

7370
cmd.extend(args)
@@ -82,10 +79,14 @@ def run_quick_mode(workdir, hdf5_path, sumstats_file, trait_name, args):
8279
cmd = [
8380
"gsmap",
8481
"quick_mode",
85-
"--workdir", workdir,
86-
"--hdf5_path", hdf5_path,
87-
"--sumstats_file", sumstats_file,
88-
"--trait_name", trait_name,
82+
"--workdir",
83+
workdir,
84+
"--hdf5_path",
85+
hdf5_path,
86+
"--sumstats_file",
87+
sumstats_file,
88+
"--trait_name",
89+
trait_name,
8990
]
9091

9192
cmd.extend(args)
@@ -100,9 +101,12 @@ def find_latent_representation(workdir, sample_name, hdf5_path, args):
100101
cmd = [
101102
"gsmap",
102103
"run_find_latent_representations",
103-
"--workdir", workdir,
104-
"--sample_name", sample_name,
105-
"--input_hdf5_path", hdf5_path,
104+
"--workdir",
105+
workdir,
106+
"--sample_name",
107+
sample_name,
108+
"--input_hdf5_path",
109+
hdf5_path,
106110
]
107111

108112
cmd.extend(args)
@@ -117,9 +121,12 @@ def latent_to_gene(workdir, sample_name, hdf5_path, args):
117121
cmd = [
118122
"gsmap",
119123
"run_latent_to_gene",
120-
"--workdir", workdir,
121-
"--sample_name", sample_name,
122-
"--input_hdf5_path", hdf5_path,
124+
"--workdir",
125+
workdir,
126+
"--sample_name",
127+
sample_name,
128+
"--input_hdf5_path",
129+
hdf5_path,
123130
]
124131

125132
cmd.extend(args)
@@ -134,9 +141,12 @@ def generate_ldscore(workdir, sample_name, chromosome, args):
134141
cmd = [
135142
"gsmap",
136143
"run_generate_ldscore",
137-
"--workdir", workdir,
138-
"--sample_name", sample_name,
139-
"--chrom", str(chromosome),
144+
"--workdir",
145+
workdir,
146+
"--sample_name",
147+
sample_name,
148+
"--chrom",
149+
str(chromosome),
140150
]
141151

142152
cmd.extend(args)
@@ -151,14 +161,18 @@ def spatial_ldsc(workdir, sample_name, sumstats_file, trait_name, args):
151161
cmd = [
152162
"gsmap",
153163
"run_spatial_ldsc",
154-
"--workdir", workdir,
155-
"--sample_name", sample_name,
156-
"--sumstats_file", sumstats_file,
157-
"--trait_name", trait_name,
164+
"--workdir",
165+
workdir,
166+
"--sample_name",
167+
sample_name,
168+
"--sumstats_file",
169+
sumstats_file,
170+
"--trait_name",
171+
trait_name,
158172
]
159173

160174
cmd.extend(args)
161175

162176
run_command(cmd)
163177

164-
return "Spatial LDSC finished"
178+
return "Spatial LDSC finished"

0 commit comments

Comments
 (0)