# HG changeset patch # User sanbi-uwc # Date 1535629315 14400 # Node ID 0e9c114c748f8c92b2cdf50d902359f0d7961c71 # Parent 57bd7c6a72cd893c805188c46c836268b359ca61 planemo upload for repository https://github.com/CPGRZA/cpgr_ancestry/tree/master/datatypes/plink_datatypes commit d0354c6155e1a44aab9c2fecf7a1a7f9e4bb22de diff -r 57bd7c6a72cd -r 0e9c114c748f fam/fam.py --- a/fam/fam.py Wed Aug 29 08:26:08 2018 -0400 +++ b/fam/fam.py Thu Aug 30 07:41:55 2018 -0400 @@ -0,0 +1,61 @@ +# -*- 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 Fam( Tabular ): + """Tab delimited data in bim format""" + file_ext = "fam" + + 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 \ No newline at end of file