comparison ngsutils/support/ngs_utils.py @ 2:7a68005de299 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ngsutils commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
author iuc
date Sun, 27 Nov 2016 15:01:21 -0500
parents 4e4e4093d65d
children
comparison
equal deleted inserted replaced
1:8187a729d9f4 2:7a68005de299
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 """ 2 """
3
4 Common util classes / functions for the NGS project 3 Common util classes / functions for the NGS project
5
6 """ 4 """
5 import collections
6 import gzip
7 import os
8 import re
7 import sys 9 import sys
8 import os
9 import gzip
10 import re
11 import collections
12 10
13 11
14 def format_number(n): 12 def format_number(n):
15 ''' 13 '''
16 >>> format_number(1000) 14 >>> format_number(1000)
104 class gzip_opener: 102 class gzip_opener:
105 ''' 103 '''
106 A Python 2.6 class to handle 'with' opening of text files that may 104 A Python 2.6 class to handle 'with' opening of text files that may
107 or may not be gzip compressed. 105 or may not be gzip compressed.
108 ''' 106 '''
107
109 def __init__(self, fname): 108 def __init__(self, fname):
110 self.fname = fname 109 self.fname = fname
111 110
112 def __enter__(self): 111 def __enter__(self):
113 self.f = gzip_aware_open(self.fname) 112 self.f = gzip_aware_open(self.fname)
205 return opts, args 204 return opts, args
206 205
207 206
208 class memoize(object): 207 class memoize(object):
209 'Simple memoizing decorator to cache results' 208 'Simple memoizing decorator to cache results'
209
210 def __init__(self, func): 210 def __init__(self, func):
211 self.func = func 211 self.func = func
212 self.cache = {} 212 self.cache = {}
213 213
214 def __call__(self, *args): 214 def __call__(self, *args):