Mercurial > repos > sanbi-uwc > plink_datatypes
view bim/bim.py @ 0:57bd7c6a72cd draft
planemo upload for repository https://github.com/CPGRZA/cpgr_ancestry/tree/master/datatypes/plink_datatypes commit 2bf82b5426ec792b408104250a875585cbf7347f
author | sanbi-uwc |
---|---|
date | Wed, 29 Aug 2018 08:26:08 -0400 |
parents | |
children |
line wrap: on
line source
# -*- coding: utf-8 -*- from galaxy import eggs import pkg_resources pkg_resources.require( "bx-python" ) import logging, os, sys, time, sets, tempfile, shutil import data from galaxy import util from galaxy.datatypes.sniff import * from cgi import escape import urllib from bx.intervals.io import * from galaxy.datatypes import metadata from galaxy.datatypes.metadata import MetadataElement from galaxy.datatypes.tabular import Tabular class Bim( Tabular ): """Tab delimited data in bim format""" file_ext = "bim" MetadataElement( name="columns", default=3, desc="Number of columns", readonly=True ) def __init__ (self, **kwd): """Initialize bim datatype""" Tabular. __init__ (self, **kwd) self.do_something_else() def init_meta( self, dataset, copy_from=None ): Tabular.init_meta( self, dataset, copy_from=copy_from ) if elems_len == 8: try: map( int, [hdr[6], hdr[7]] ) proceed = True except: pass def sniff( self, filename ): headers = get_headers( filename, '\t' ) try: if len(headers) < 2: return False for hdr in headers: if len( hdr ) > 1 and hdr[0] and not hdr[0].startswith( '#' ): if len(hdr) != 8: return False try: map( int, [hdr[6], hdr[7]] ) except: return False # Do other necessary checking here... except: return False # If we haven't yet returned False, then... return True