Skip to content

Add new ODV datatype #20581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/galaxy/config/sample/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
<datatype extension="deeptools_compute_matrix_archive" type="galaxy.datatypes.binary:CompressedArchive" subclass="true" display_in_upload="true"/>
<datatype extension="deeptools_coverage_matrix" type="galaxy.datatypes.binary:CompressedArchive" subclass="true" display_in_upload="true"/>
<datatype extension="netcdf" type="galaxy.datatypes.binary:NetCDF" mimetype="application/octet-stream" display_in_upload="true" description="Format used by netCDF software library for writing and reading chromatography-MS data files."/>
<datatype extension="odv" type="galaxy.datatypes.text:ODV" display_in_upload="true" description="Ocean Data View format file"/>
<datatype extension="eps" type="galaxy.datatypes.images:Eps" mimetype="image/eps"/>
<datatype extension="rast" type="galaxy.datatypes.images:Rast" mimetype="image/rast"/>
<datatype extension="laj" type="galaxy.datatypes.images:Laj"/>
Expand Down Expand Up @@ -1379,6 +1380,7 @@
<sniffer type="galaxy.datatypes.text:PithyaResult"/>
<sniffer type="galaxy.datatypes.text:BCSLts"/>
<sniffer type="galaxy.datatypes.text:Json"/>
<sniffer type="galaxy.datatypes.text:ODV"/>
<sniffer type="galaxy.datatypes.genetics:GenotypeMatrix"/>
<sniffer type="galaxy.datatypes.genetics:DataIn"/>
<sniffer type="galaxy.datatypes.genetics:MarkerMap"/>
Expand Down
52 changes: 52 additions & 0 deletions lib/galaxy/datatypes/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,3 +1532,55 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
False
"""
return file_prefix.startswith("RBT_PARAMETER_FILE_V1.00")


class ODV(Text):
file_ext = "odv"

MetadataElement(name="meta_var_count", default=0, desc="Number of Meta Variables", readonly=True)
MetadataElement(name="var_count", default=0, desc="Number of Variables", readonly=True)

def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
"""
Determines whether the file is has some required details in General section
"""
header = file_prefix.contents_header.lower()
keywords = ["collectionformat", "odvcf"]
return all(keyword in header for keyword in keywords)

def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd):
dataset.metadata.meta_var_count = 0
dataset.metadata.var_count = 0

section = None
try:
with open(dataset.get_file_name(), encoding="utf-8") as f:
for line in f:
line = line.strip()

if line.startswith("[") and line.endswith("]"):
section = line[1:-1].strip()
if section != "General":
# Stop after [General] section
break
continue

if section != "General" or not line or "=" not in line:
continue

key, value = map(str.strip, line.split("=", 1))
if key == "NumberOfMetaVariables":
dataset.metadata.meta_var_count = int(value)
elif key == "NumberOfVariables":
dataset.metadata.var_count = int(value)

except Exception:
log.exception("Error in set_meta")

def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
if not dataset.dataset.purged:
dataset.peek = get_file_peek(dataset.get_file_name())
dataset.blurb = f"ODV Collection Format: {dataset.metadata.meta_var_count} meta variables, {dataset.metadata.var_count} variables"
else:
dataset.peek = "file does not exist"
dataset.blurb = "file purged from disc"
Loading