mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #17482 from brsynth/feature_datatypes_sbol
Feature SBOL datatypes
This commit is contained in:
@@ -573,6 +573,7 @@
|
||||
<datatype extension="ttl" type="galaxy.datatypes.triples:Turtle" display_in_upload="true"/>
|
||||
<datatype extension="rdf" type="galaxy.datatypes.triples:Rdf" display_in_upload="true"/>
|
||||
<datatype extension="jsonld" type="galaxy.datatypes.triples:Jsonld" display_in_upload="true"/>
|
||||
<datatype extension="sbol" type="galaxy.datatypes.triples:Sbol" description="The SBOL (Synthetic Biology Open Language) standard was developed by the synthetic biology community to create a standardized format for the electronic exchange of information on the structural and functional aspects of biological designs." description_url="https://sbolstandard.org" display_in_upload="true"/>
|
||||
<!-- Excel datatypes -->
|
||||
<datatype extension="excel.xls" type="galaxy.datatypes.binary:ExcelXls" display_in_upload="true"/>
|
||||
<datatype extension="xlsx" type="galaxy.datatypes.binary:Xlsx" display_in_upload="true"/>
|
||||
@@ -1130,6 +1131,7 @@
|
||||
<sniffer type="galaxy.datatypes.proteomics:Wiff"/>
|
||||
<sniffer type="galaxy.datatypes.proteomics:PEFF"/>
|
||||
<sniffer type="galaxy.datatypes.molecules:CML"/>
|
||||
<sniffer type="galaxy.datatypes.triples:Sbol"/>
|
||||
<sniffer type="galaxy.datatypes.xml:GenericXml"/>
|
||||
<sniffer type="galaxy.datatypes.triples:HDT"/>
|
||||
<sniffer type="galaxy.datatypes.triples:Turtle"/>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@ Triple format classes
|
||||
import logging
|
||||
import re
|
||||
|
||||
from galaxy.datatypes.metadata import MetadataElement
|
||||
from galaxy.datatypes.protocols import DatasetProtocol
|
||||
from galaxy.datatypes.sniff import (
|
||||
build_sniff_from_prefix,
|
||||
@@ -21,6 +22,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
TURTLE_PREFIX_PATTERN = re.compile(r"@prefix\s+[^:]*:\s+<[^>]*>\s\.")
|
||||
TURTLE_BASE_PATTERN = re.compile(r"@base\s+<[^>]*>\s\.")
|
||||
SBOL_PATTERN = re.compile(r"http[s]?://[w\.]*sbol[s]?.org/v(\d{1})#")
|
||||
|
||||
|
||||
class Triples(data.Data):
|
||||
@@ -202,3 +204,38 @@ class HDT(binary.Binary, Triples):
|
||||
else:
|
||||
dataset.peek = "file does not exist"
|
||||
dataset.blurb = "file purged from disk"
|
||||
|
||||
|
||||
@build_sniff_from_prefix
|
||||
class Sbol(data.Text, Triples):
|
||||
"""
|
||||
The SBOL data format (https://sbolstandard.org).
|
||||
"""
|
||||
|
||||
MetadataElement(name="version", default="", readonly=True, visible=True, optional=True)
|
||||
edam_format = "format_3725"
|
||||
file_ext = "sbol"
|
||||
|
||||
def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> None:
|
||||
file_prefix = FilePrefix(filename=dataset.get_file_name())
|
||||
match = file_prefix.search(SBOL_PATTERN)
|
||||
if match and match.group(1):
|
||||
dataset.metadata.version = match.group(1)
|
||||
|
||||
def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
|
||||
# http://sbols.org/v2#
|
||||
if file_prefix.search(SBOL_PATTERN):
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
|
||||
"""Set the peek and blurb text"""
|
||||
if not dataset.dataset.purged:
|
||||
dataset.peek = data.get_file_peek(dataset.get_file_name())
|
||||
msg = "SBOL data"
|
||||
if dataset.metadata.version != "":
|
||||
msg += " v" + dataset.metadata.version
|
||||
dataset.blurb = msg
|
||||
else:
|
||||
dataset.peek = "file does not exist"
|
||||
dataset.blurb = "file purged from disk"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
from galaxy.datatypes.triples import Sbol
|
||||
from .util import (
|
||||
get_dataset,
|
||||
get_input_files,
|
||||
)
|
||||
|
||||
|
||||
def test_sbol_sniff():
|
||||
sbol_datatype = Sbol()
|
||||
with get_input_files("sbol.v2.crispr_example.xml") as input_files:
|
||||
assert sbol_datatype.sniff(input_files[0]) is True
|
||||
|
||||
|
||||
def test_sbol_set_meta():
|
||||
sbol_datatype = Sbol()
|
||||
with get_input_files("sbol.v2.crispr_example.xml") as input_files, get_dataset(input_files[0]) as dataset:
|
||||
sbol_datatype.set_meta(dataset)
|
||||
assert dataset.metadata.version == "2"
|
||||
|
||||
with get_input_files("sbol.v3.circuit.nt") as input_files, get_dataset(input_files[0]) as dataset:
|
||||
sbol_datatype.set_meta(dataset)
|
||||
assert dataset.metadata.version == "3"
|
||||
Reference in New Issue
Block a user