VFBquery¶
VFBquery answers questions about the Virtual Fly Brain knowledge graph — Drosophila neuroanatomy, connectomics, expression and single-cell transcriptomics — and it does so in three shapes, from the same code:
As a Python library. pip install vfbquery, call get_term_info or run_query in process. This
is the original shape and what the VFB services themselves use.
As an HTTP service. The same queries behind an aiohttp front end (ha_api), deployed as
v3-cached.virtualflybrain.org, with a process pool, request coalescing, a result cache and queue
backpressure in front of them. This is what the website and the MCP server talk to.
As a lightweight HTTP client. pip install vfbquery-client — requests and pandas, nothing
else. It installs in seconds on a fresh Colab runtime, needs no navis and no setuptools pin, and
returns DataFrames. If you are writing a notebook, this is the one you want.
Which one do I want?
If you are exploring, teaching, or writing a notebook, start with the client — nothing to compile, and it works from Colab. Reach for the library instead when you need VFBquery inside a service, or when you want the query functions without a network hop.
Start here¶
Using it
- Getting started
- The HTTP API
/combine— asking questions no single VFB query can answer- 1. The request
- 2. The operators, in plain English
- 3. Precedence and brackets
- 4. What “everything” means (the universe)
- 5. How rows from different queries are matched
- 6. How columns are merged (nothing is dropped)
- 7. Reading the response
- 8. Worked biological examples
- 9. The traps, and what the endpoint says about them
- 10. Limits
- 11. From Python
- 12. Expressions bigger than the operand limit
- Implementation notes
- The Python client
API reference
The query catalogue
Running and releasing it
A worked question, three ways¶
“Which neurons have arbours in both the mushroom body calyx and the lateral horn?” — a question no single VFB query answers, because each query returns one region’s neurons.
With the client:
from vfbquery_client import VfbClient
vfb = VfbClient()
both = vfb.combine(
"calyx AND lateral_horn",
{"calyx": "NeuronsPartHere:FBbt_00007401",
"lateral_horn": "NeuronsPartHere:FBbt_00007053"},
)
print(both.attrs["plain_english"]) # neurons in both lists
print(len(both))
Over HTTP directly:
GET /combine?expr=calyx AND lateral_horn
&calyx=NeuronsPartHere:FBbt_00007401
&lateral_horn=NeuronsPartHere:FBbt_00007053
And in the library, by calling run_query twice and intersecting on the identity column yourself —
which is precisely the fiddly part /combine exists to get right, because
“the identity column” is not always the first one and duplicate rows are common.
Where things live¶
Source |
|
Library on PyPI |
|
Client on PyPI |
|
Live service |
|
The site itself |
This documentation is built for version 1.22.37.