Spaces:
Sleeping
Sleeping
Update biopython/mcp_output/mcp_plugin/mcp_service.py
Browse files
biopython/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -430,8 +430,13 @@ def pdb_summary(payload: dict):
|
|
| 430 |
@mcp.tool(name="msa_read_fasta", description="Read a FASTA alignment file; return length and sequences")
|
| 431 |
def msa_read_fasta(payload: dict):
|
| 432 |
try:
|
|
|
|
|
|
|
| 433 |
path = payload.get("path", "")
|
| 434 |
-
|
|
|
|
|
|
|
|
|
|
| 435 |
seqs = [{"id": rec.id, "seq": str(rec.seq)} for rec in alignment]
|
| 436 |
aln_len = alignment.get_alignment_length() if isinstance(alignment, MultipleSeqAlignment) else None
|
| 437 |
return {"success": True, "result": {"alignment_length": aln_len, "sequences": seqs}, "error": None}
|
|
@@ -442,8 +447,13 @@ def msa_read_fasta(payload: dict):
|
|
| 442 |
@mcp.tool(name="msa_consensus", description="Compute simple consensus from FASTA alignment file")
|
| 443 |
def msa_consensus(payload: dict):
|
| 444 |
try:
|
|
|
|
|
|
|
| 445 |
path = payload.get("path", "")
|
| 446 |
-
|
|
|
|
|
|
|
|
|
|
| 447 |
consensus = alignment.column_annotations.get("consensus") if hasattr(alignment, "column_annotations") else None
|
| 448 |
if consensus is None:
|
| 449 |
# naive majority rule per column
|
|
|
|
| 430 |
@mcp.tool(name="msa_read_fasta", description="Read a FASTA alignment file; return length and sequences")
|
| 431 |
def msa_read_fasta(payload: dict):
|
| 432 |
try:
|
| 433 |
+
fmt = payload.get("format", "fasta")
|
| 434 |
+
data = payload.get("data", "")
|
| 435 |
path = payload.get("path", "")
|
| 436 |
+
if data:
|
| 437 |
+
alignment = AlignIO.read(StringIO(data), fmt)
|
| 438 |
+
else:
|
| 439 |
+
alignment = AlignIO.read(path, fmt)
|
| 440 |
seqs = [{"id": rec.id, "seq": str(rec.seq)} for rec in alignment]
|
| 441 |
aln_len = alignment.get_alignment_length() if isinstance(alignment, MultipleSeqAlignment) else None
|
| 442 |
return {"success": True, "result": {"alignment_length": aln_len, "sequences": seqs}, "error": None}
|
|
|
|
| 447 |
@mcp.tool(name="msa_consensus", description="Compute simple consensus from FASTA alignment file")
|
| 448 |
def msa_consensus(payload: dict):
|
| 449 |
try:
|
| 450 |
+
fmt = payload.get("format", "fasta")
|
| 451 |
+
data = payload.get("data", "")
|
| 452 |
path = payload.get("path", "")
|
| 453 |
+
if data:
|
| 454 |
+
alignment = AlignIO.read(StringIO(data), fmt)
|
| 455 |
+
else:
|
| 456 |
+
alignment = AlignIO.read(path, fmt)
|
| 457 |
consensus = alignment.column_annotations.get("consensus") if hasattr(alignment, "column_annotations") else None
|
| 458 |
if consensus is None:
|
| 459 |
# naive majority rule per column
|