view fam/fam.py @ 1:0e9c114c748f draft default tip

planemo upload for repository https://github.com/CPGRZA/cpgr_ancestry/tree/master/datatypes/plink_datatypes commit d0354c6155e1a44aab9c2fecf7a1a7f9e4bb22de
author sanbi-uwc
date Thu, 30 Aug 2018 07:41:55 -0400
parents 57bd7c6a72cd
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 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