Skip to content

fairscape-conversion

Turns metadata you already have (a datasheet, a data package, a workflow engine’s run output) into a FAIRSCAPE RO-Crate, so you don’t have to type it in again. It can also export a crate to other formats.

It is the create step of FAIRSCAPE, next to fairscape_models.

Install

Terminal window
pip install fairscape-conversion

Example

Terminal window
mkdir my-crate
python -m fairscape_conversion.core.cli convert d4d import datasheet.yaml my-crate/ro-crate-metadata.json

Every format works the same way: convert <format> <import|export> INPUT [OUTPUT].

From a workflow run to a crate

The Snakemake variant-calling tutorial, run with the FAIRSCAPE reporter. The Snakefile on the left is the only thing anyone wrote by hand; the crate, and the pages built from it, came out of the run.

rule bwa_map:
"""Align one sample's reads to the reference genome."""
input:
genome=GENOME,
reads="data/samples/{sample}.fastq",
output:
temp("results/mapped/{sample}.bam"),
conda:
"envs/mapping.yaml"
shell:
"bwa mem -t {threads} {input.genome} {input.reads} | samtools view -Sb - > {output}"
rule samtools_sort:
input: "results/mapped/{sample}.bam",
output: "results/sorted/{sample}.bam",
shell: "samtools sort -O bam {input} > {output}"
rule bcftools_call:
input:
fa=GENOME,
bam=expand("results/sorted/{sample}.bam", sample=SAMPLES),
output: "results/calls/all.vcf",
shell: "bcftools mpileup -f {input.fa} {input.bam} | bcftools call -mv - > {output}"
Terminal window
snakemake --cores 4 --use-conda --reporter fairscape

Formats

Import fromInput
d4dDatasheet for Datasets (YAML or JSON)
snakemakerecords JSON from snakemake --reporter fairscape
cromwellmetadata.json from cromwell run -m
galaxyan invocation export (.tar.gz, .zip, folder) or a .ga file
mlflowan mlruns dir or tracking URI, with --experiment NAME (needs pip install mlflow)
wrroca Workflow Run RO-Crate ro-crate-metadata.json (CWL, Galaxy, …)
redcapthe data dictionary CSV, plus --records DATA.csv if you want the records too
frictionlessa datapackage.json or its folder
c2m2a CFDE C2M2 datapackage folder
cpma CPM RO-Crate folder with its PROV bundle files
Export to
croissantMLCommons Croissant
d4dDatasheet for Datasets
wrrocWorkflow Run RO-Crate
frictionlessFrictionless datapackage.json
cpmPROV-JSON (or PROV-N with --provn)

Details

  • Try every converter with no data of your own. python examples/run_all.py runs each one on the sample input that ships in plugins/<format>/ and checks the result against a reviewed golden file. examples/mlflow/mlflow_to_rocrate.ipynb is a full walk-through.
  • Linking crates. If this run’s inputs were another run’s outputs, pass --link-crate /path/to/upstream-crate. The new crate reuses the upstream identifiers, so the evidence graph can follow one crate into the other. See examples/linked-crates/.
  • Adding a format. A converter is a folder with two CSV mapping files and a small plugin class. See docs/NEW-PLUGIN.md, docs/INTERNALS.md and MAPPING-SCHEMA.md.

Source: github.com/fairscape/fairscape_conversion