From f9898ca2280864c4395ea5510e3a08a61e626395 Mon Sep 17 00:00:00 2001 From: Trevor Manz Date: Mon, 12 Jun 2023 12:09:21 -0400 Subject: [PATCH] feat: Upgrade to Gosling v0.9.31 (#137) * feat: Upgrade to Gosling v0.9.30 * feat: add gos.bed * chore: bump gosling.js v0.9.31 --- doc/user_guide/API.rst | 1 + gosling/__init__.py | 1 + gosling/data/__init__.py | 1 + gosling/schema/__init__.py | 4 +-- gosling/schema/core.py | 42 +++++++++++++++++++++++++++--- gosling/schema/gosling-schema.json | 40 +++++++++++++++++++++++++++- pyproject.toml | 1 + tools/generate_schema_wrapper.py | 2 +- 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/doc/user_guide/API.rst b/doc/user_guide/API.rst index 712a402a..9408532b 100644 --- a/doc/user_guide/API.rst +++ b/doc/user_guide/API.rst @@ -77,6 +77,7 @@ Low-Level Schema Wrappers Assembly AxisPosition BamData + BedData BeddbData BigWigData BinAggregate diff --git a/gosling/__init__.py b/gosling/__init__.py index 4b012f6a..d8e3f441 100644 --- a/gosling/__init__.py +++ b/gosling/__init__.py @@ -10,6 +10,7 @@ from gosling.data import ( GoslingDataServer, bam, + bed, beddb, bigwig, csv, diff --git a/gosling/data/__init__.py b/gosling/data/__init__.py index 7d58e985..9e83d0b5 100644 --- a/gosling/data/__init__.py +++ b/gosling/data/__init__.py @@ -135,6 +135,7 @@ def json(values: list[dict[str, typing.Any]], **kwargs): bam = _create_loader("bam") csv = _create_loader("csv") bigwig = _create_loader("bigwig") +bed = _create_loader("bed") # tileset resources beddb = _create_loader("beddb", tilesets.beddb) diff --git a/gosling/schema/__init__.py b/gosling/schema/__init__.py index bc25e134..81eb3a04 100644 --- a/gosling/schema/__init__.py +++ b/gosling/schema/__init__.py @@ -1,6 +1,6 @@ # flake8: noqa from .core import * from .channels import * -SCHEMA_VERSION = 'v0.9.29' -SCHEMA_URL = 'https://raw.githubusercontent.com/gosling-lang/gosling.js/v0.9.29/schema/gosling.schema.json' +SCHEMA_VERSION = 'v0.9.31' +SCHEMA_URL = 'https://raw.githubusercontent.com/gosling-lang/gosling.js/v0.9.31/schema/gosling.schema.json' THEMES = {'dark', 'ensembl', 'excel', 'ggplot', 'google', 'igv', 'jbrowse', 'light', 'ucsc', 'warm', 'washu'} diff --git a/gosling/schema/core.py b/gosling/schema/core.py index 4f1bd91b..12343392 100644 --- a/gosling/schema/core.py +++ b/gosling/schema/core.py @@ -174,9 +174,9 @@ def __init__(self, domain=Undefined, field=Undefined, legend=Undefined, range=Un class DataDeep(GoslingSchema): """DataDeep schema wrapper - anyOf(:class:`JsonData`, :class:`CsvData`, :class:`BigWigData`, :class:`MultivecData`, - :class:`BeddbData`, :class:`VectorData`, :class:`MatrixData`, :class:`BamData`, - :class:`VcfData`) + anyOf(:class:`JsonData`, :class:`CsvData`, :class:`BedData`, :class:`BigWigData`, + :class:`MultivecData`, :class:`BeddbData`, :class:`VectorData`, :class:`MatrixData`, + :class:`BamData`, :class:`VcfData`) """ _schema = {'$ref': '#/definitions/DataDeep'} _rootschema = GoslingSchema._rootschema @@ -223,6 +223,39 @@ def __init__(self, indexUrl=Undefined, type=Undefined, url=Undefined, extractJun maxInsertSize=maxInsertSize, **kwds) +class BedData(DataDeep): + """BedData schema wrapper + + Mapping(required=[type, url, indexUrl]) + BED file format + + Attributes + ---------- + + indexUrl : string + Specify the URL address of the data file index. + type : string + + url : string + Specify the URL address of the data file. + customFields : List(string) + An array of strings, where each string is the name of a non-standard field in the + BED file. If there are `n` custom fields, we assume that the last `n` columns of the + BED file correspond to the custom fields. + sampleLength : float + Specify the number of rows loaded from the URL. + + __Default:__ `1000` + """ + _schema = {'$ref': '#/definitions/BedData'} + _rootschema = GoslingSchema._rootschema + + def __init__(self, indexUrl=Undefined, type=Undefined, url=Undefined, customFields=Undefined, + sampleLength=Undefined, **kwds): + super(BedData, self).__init__(indexUrl=indexUrl, type=type, url=url, customFields=customFields, + sampleLength=sampleLength, **kwds) + + class BeddbData(DataDeep): """BeddbData schema wrapper @@ -309,7 +342,8 @@ class CsvData(DataDeep): chromosomeField : string Specify the name of chromosome data fields. chromosomePrefix : string - experimental + Specify the chromosome prefix if chromosomes are denoted using a prefix besides + "chr" or a number genomicFields : List(string) Specify the name of genomic data fields. genomicFieldsToConvert : List(Mapping(required=[chromosomeField, genomicFields])) diff --git a/gosling/schema/gosling-schema.json b/gosling/schema/gosling-schema.json index 0cf1b801..cb352d85 100644 --- a/gosling/schema/gosling-schema.json +++ b/gosling/schema/gosling-schema.json @@ -101,6 +101,41 @@ ], "type": "object" }, + "BedData": { + "additionalProperties": false, + "description": "BED file format", + "properties": { + "customFields": { + "description": "An array of strings, where each string is the name of a non-standard field in the BED file. If there are `n` custom fields, we assume that the last `n` columns of the BED file correspond to the custom fields.", + "items": { + "type": "string" + }, + "type": "array" + }, + "indexUrl": { + "description": "Specify the URL address of the data file index.", + "type": "string" + }, + "sampleLength": { + "description": "Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`", + "type": "number" + }, + "type": { + "const": "bed", + "type": "string" + }, + "url": { + "description": "Specify the URL address of the data file.", + "type": "string" + } + }, + "required": [ + "type", + "url", + "indexUrl" + ], + "type": "object" + }, "BeddbData": { "additionalProperties": false, "description": "Regular BED or similar files can be pre-aggregated for the scalable data exploration. Find our more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#bed-files).", @@ -420,7 +455,7 @@ "type": "string" }, "chromosomePrefix": { - "description": "experimental", + "description": "Specify the chromosome prefix if chromosomes are denoted using a prefix besides \"chr\" or a number", "type": "string" }, "genomicFields": { @@ -495,6 +530,9 @@ { "$ref": "#/definitions/CsvData" }, + { + "$ref": "#/definitions/BedData" + }, { "$ref": "#/definitions/BigWigData" }, diff --git a/pyproject.toml b/pyproject.toml index a9b45476..7550c1ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,3 +63,4 @@ features = ["dev", "all"] test = "pytest --ignore gosling/examples --ignore tools/altair --doctest-modules gosling" clean = "rm -rf doc/_build doc/user_guide/generated/ doc/gallery" docs = "sphinx-build -b html doc dist" +generate-schema-wrapper = "python tools/generate_schema_wrapper.py" diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 254f260a..59f54450 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -411,7 +411,7 @@ def generate_mark_mixin(schemafile: pathlib.Path, mark_enum: str, style_def: str def main(skip_download: Optional[bool] = False): library = "gosling.js" - version = "v0.9.29" + version = "v0.9.31" schemapath = here.parent / ".." / "gosling" / "schema" schemafile = download_schemafile(