Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/bf873e4054c2/allpy/util.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 21:39:06 2013
Кодировка:
allpy: bf873e4054c2 allpy/util.py

allpy

view allpy/util.py @ 894:bf873e4054c2

test: add make rule alignments, downloading simple alignment This alignment is similar to alignment 1jcc_in.fasta, removed in [d1a3d3ee0843]. It consists of almost identical sequences of two proteins with resolved structure.
author Boris Nagaev <bnagaev@gmail.com>
date Fri, 23 Sep 2011 14:00:34 +0400
parents 4fa7b10ce252
children 7b2a37ff1662
line source
1 """Miscellanous utilities.
2 """
3 import sys
4 import warnings
6 def unzip(seq):
7 """The oppozite of zip() builtin."""
8 a, b = [], []
9 for x, y in seq:
10 a.append(x)
11 b.append(y)
12 return a, b
14 def open(filename, mode='r'):
15 """Open file. Return stdin/stdout for filename '-'."""
16 if filename == '-':
17 if 'w' in mode or 'a' in mode or '+' in mode:
18 return sys.stdout
19 if 'r' in mode:
20 return sys.stdin
21 raise AssertionError("Unknown file mode: %s" % mode)
22 else:
23 return file(filename, mode)
25 def remove_each(string, substrings):
26 """Remove each of substrings from string."""
27 for sub in substrings:
28 string = string.replace(sub, "")
29 return string
31 class UserDict(dict):
32 """Clone of dict that user may add attributes to."""
33 pass
35 class UserList(list):
36 """Clone of list that user may add attributes to."""
37 pass
39 class UserString(str):
40 """Clone of str that user may add attributes to."""
41 pass
43 def deprecated(message):
44 """Warn about function being deprecated."""
45 warnings.warn(message, DeprecationWarning, stacklevel=2)
47 class lazy_import(object):
48 """Lazy module import to help breaking bad import loops."""
49 def __init__(self, name, globals={}, locals={}, fromlist=[], level=-1):
50 self.name = name
51 self.globals = globals
52 self.locals = locals
53 self.fromlist = fromlist
54 self.level = level
55 def __getattr__(self, attr):
56 self.module = __import__(
57 self.name, self.globals, self.locals, self.fromlist, self.level
58 )
59 self.__dict__ = self.module.__dict__
60 return self.__dict__[attr]
62 # vim: set et ts=4 sts=4 sw=4: