Mercurial > repos > geco-team > gmql_datatypes
changeset 0:5d6ff635462f draft default tip
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
author | geco-team |
---|---|
date | Tue, 26 Jun 2018 08:57:11 -0400 |
parents | |
children | |
files | datatypes_conf.xml gmql.py |
diffstat | 2 files changed, 86 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/datatypes_conf.xml Tue Jun 26 08:57:11 2018 -0400 @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<datatypes> + <datatype_files> + <datatype_file name="gmql.py" /> + </datatype_files> + <registration> + <!-- GMQL Custom datatypes --> + <datatype extension="gmql_user" type="galaxy.datatypes.tabular:Tabular" subclass="True" /> + <datatype extension="gmql_query" type="galaxy.datatypes.data:Text" subclass="True"/> + <datatype extension="gmql_repository" type="galaxy.datatypes.tabular:Tabular" subclass="True" /> + <datatype extension="meta" type="galaxy.datatypes.tabular:Tabular" subclass="True" /> + <datatype extension="gdm" type="galaxy.datatypes.gmql:Gdm" display_in_upload="True" /> + </registration> + <sniffers> + <sniffer type="galaxy.datatypes.gmql:Gdm" /> + </sniffers> +</datatypes>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmql.py Tue Jun 26 08:57:11 2018 -0400 @@ -0,0 +1,69 @@ +# Custom datatypes for the use of the GMQL framework within Galaxy +# ---------------------------------------------------------------------------- +# Luana Brancato, luana.brancato@mail.polimi.it +# ---------------------------------------------------------------------------- + +from galaxy.datatypes import metadata +from galaxy.datatypes.metadata import MetadataElement +from galaxy.datatypes.tabular import Tabular +from galaxy.datatypes.sniff import get_headers + +import logging + +class Gdm ( Tabular ): + """Tab delimited data in Gdm format""" + + file_ext = "gdm" + column_names = ['chr','left','right','strand','name','score'] + + + MetadataElement( name='columns', default='6', desc='Number of Columns', readonly=True, visible=False ) + MetadataElement( name='column_types', default=['str','int','int','str','str','float'], + param=metadata.ColumnTypesParameter, desc="Column types", readonly=True, visible=False) + + + def display_peek(self, dataset): + """Returns formatted html of peek""" + + return self.make_html_table(dataset, column_names=self.column_names) + + def sniff(self, filename): + """ + Determines whether a file is in gdm format + + GDM files have at least 6 required fields. + (Actually in the format definition only the first 5 are mandatory, but the ones returned by the system have + always at least 6). + + Required fields must be tab separated. + + Columns 0, 3, 4 must be strings. + Columns 1, 2, 5 numbers. + + Column 5 (Score) can be not provided. + + + """ + + + headers = get_headers(filename, '\t', count=10) + + + try: + for hdr in headers: + if hdr and hdr[0] and not hdr[0].startswith('#'): + if len(hdr) != 6: + return False + try: + int(hdr[1]) + int(hdr[2]) + except: + return False + if hdr[5] != '.': + try: + float(hdr[5]) + except: + return False + return True + except: + return False