Mercurial > repos > sanbi-uwc > plink_datatypes
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:57bd7c6a72cd |
---|---|
1 # -*- coding: utf-8 -*- | |
2 from galaxy import eggs | |
3 | |
4 | |
5 import pkg_resources | |
6 pkg_resources.require( "bx-python" ) | |
7 | |
8 | |
9 import logging, os, sys, time, sets, tempfile, shutil | |
10 import data | |
11 from galaxy import util | |
12 from galaxy.datatypes.sniff import * | |
13 from cgi import escape | |
14 import urllib | |
15 from bx.intervals.io import * | |
16 from galaxy.datatypes import metadata | |
17 from galaxy.datatypes.metadata import MetadataElement | |
18 from galaxy.datatypes.tabular import Tabular | |
19 | |
20 | |
21 class Bim( Tabular ): | |
22 """Tab delimited data in bim format""" | |
23 file_ext = "bim" | |
24 | |
25 MetadataElement( name="columns", default=3, desc="Number of columns", readonly=True ) | |
26 | |
27 | |
28 def __init__ (self, **kwd): | |
29 """Initialize bim datatype""" | |
30 Tabular. __init__ (self, **kwd) | |
31 self.do_something_else() | |
32 | |
33 | |
34 def init_meta( self, dataset, copy_from=None ): | |
35 Tabular.init_meta( self, dataset, copy_from=copy_from ) | |
36 if elems_len == 8: | |
37 try: | |
38 map( int, [hdr[6], hdr[7]] ) | |
39 proceed = True | |
40 except: | |
41 pass | |
42 | |
43 | |
44 def sniff( self, filename ): | |
45 headers = get_headers( filename, '\t' ) | |
46 try: | |
47 if len(headers) < 2: | |
48 return False | |
49 for hdr in headers: | |
50 if len( hdr ) > 1 and hdr[0] and not hdr[0].startswith( '#' ): | |
51 if len(hdr) != 8: | |
52 return False | |
53 try: | |
54 map( int, [hdr[6], hdr[7]] ) | |
55 except: | |
56 return False | |
57 # Do other necessary checking here... | |
58 except: | |
59 return False | |
60 # If we haven't yet returned False, then... | |
61 return True |