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

allpy

view allpy/util.py @ 864:cfcbd13f6761

Added fileio.BioPythonFile as a method to parse unknown file formats [closes #106] Biopython can parse more formats than EMBOSS, but surprisingly, it cannot do msf. Also, there is no way to see in the current tests, where a test used biopython or emboss for a particular IO task. This will likely be fixed with the 1.5.0 release with the new fileio system. For now, Biopython has precedence over EMBOSS, so an IO test of msf tests EMBOSS, and IO test of Stockholm tests Biopython.
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Mon, 25 Jul 2011 14:40:41 +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: