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

allpy

view allpy/util.py @ 1081:43b5207a70d7

Bugfixed the previous commit (decency verification), (see #98) * Removed the decency verification function itself, it does not seem to be necessary YET * Moved the check on alignment quality within processors.FixOrdering, which is the one that actually fails and is hard to debug if sequences have the same identification. * Added a specific testcase for this situation.
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Wed, 30 May 2012 13:35:04 +0400
parents 0e1a20b6abc0
children a3e439d09322
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: