agentsclimarketplace

Json serialization of query structures

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/json-serialization-of-query-structures

Use when you have parsed a MassQL query string into an AST representation and need to store, validate, transmit, or integrate the query structure with other tools or systems.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill json-serialization-of-query-structures

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.9 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

json-serialization-of-query-structures

Summary

Convert domain-specific query language abstract syntax trees (ASTs) into JSON format to preserve structured query components (SELECT clauses, WHERE conditions, constraints) in a machine-readable and interoperable form. This enables downstream processing, visualization, validation, and integration of mass spectrometry queries across pipelines.

When to use

Apply this skill when you have parsed a MassQL query string into an AST representation and need to store, validate, transmit, or integrate the query structure with other tools or systems. Use it whenever you need the query to be independently inspectable, versioned, or transformed by downstream agents without reparsing the original query string.

When NOT to use

  • Query string is already in JSON form or does not require interoperability with other tools.
  • Query structure is simple enough that raw AST objects or internal representations suffice for downstream processing.
  • Application requires lossy compression or does not need to preserve full query semantics for validation or reconstruction.

Inputs

  • Parsed AST (abstract syntax tree) from MassQL query parser
  • Query component metadata (SELECT clause targets, WHERE condition predicates, constraint values)

Outputs

  • JSON-serialized query representation with nested structure
  • Query structure document preserving mass spectrometry constraints and operators

How to apply

After building an AST from tokenized MassQL query syntax, recursively serialize the tree into a JSON object that preserves all query components: SELECT clauses (e.g. scaninfo, MS2DATA), WHERE condition filters (e.g. MS1MZ, TOLERANCEMZ, INTENSITYPERCENT), logical operators (AND, OR), mass tolerance parameters, and scan type constraints. Map each AST node to a JSON object with fields for node type, operator/keyword, operands, and nested conditions. Validate the JSON output against reference query examples from the MassQueryLanguage repository to ensure structural correctness and that all mass spectrometry-specific parameters (mass/m-z values, tolerance thresholds, intensity percentages) are accurately represented. The JSON form should be human-readable and reconstruct the original query semantics without loss of information.

Related tools

Examples

from massql import msql_engine; import json; results_df = msql_engine.process_query('QUERY MS2DATA WHERE MS1MZ=100', 'test.mzML'); query_json = json.dumps({'SELECT': 'MS2DATA', 'WHERE': {'MS1MZ': 100}}, indent=2)

Evaluation signals

  • JSON output is valid and parseable; no syntax errors or truncation.
  • All AST nodes are represented in the JSON structure with no information loss (e.g., all mass tolerance values, scan type constraints, and WHERE operators are present).
  • JSON-serialized query can be round-tripped: deserialize to JSON, reconstruct query string, re-parse, and produce equivalent AST to original.
  • Mass spectrometry-specific parameters (MS1MZ, TOLERANCEMZ, INTENSITYPERCENT, MS2PREC) are correctly mapped to JSON field names and values matching reference query examples.
  • Query structure matches expected schema for SELECT, WHERE, AND/OR operators, and constraint parameters when validated against reference examples from the MassQueryLanguage documentation.

Limitations

  • Serialization only captures query structure; does not include execution results or performance metrics. Downstream tools must re-parse and execute the JSON-serialized query to obtain spectrum results.
  • JSON output may grow large for complex queries with deeply nested AND/OR conditions; no built-in compression is specified in the reference implementation.
  • Serialization assumes a stable, well-defined grammar; changes to MassQL syntax or addition of new constraint types require schema migration of existing JSON-serialized queries.
  • No changelog documented for the MassQL specification; breaking changes to serialization format are not formally tracked.

Evidence

  • [other] The workflow specifies that serialization to JSON is a key step in parsing and representation.: "Serialize the AST to JSON format, preserving query components (SELECT clauses, WHERE conditions, mass tolerance, scan type constraints, etc.)."
  • [other] The reference implementation is the canonical source for AST structure and validation.: "Analyze the reference parser to identify the grammar rules, token types, and AST (abstract syntax tree) structure used to represent MassQL queries."
  • [intro] MassQL is designed to bake mass spectrometry assumptions into syntax and semantics.: "It is inspired by SQL, but it attempts to bake in assumptions of mass spectrometry"
  • [other] Validation against reference examples ensures correctness of the serialization.: "Validate the parser output against reference query examples from the repository to ensure structural correctness."
  • [readme] The repository provides a reference implementation with documented grammar and structure.: "This is the repository to define the language and reference implementation. This contains several parts: 1. Language Grammar 2. Reference Implementation Python API"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.