Package Bio
[hide private]
[frames] | no frames]

Source Code for Package Bio

 1  # Copyright 2000 by Jeffrey Chang.  All rights reserved. 
 2  # This code is part of the Biopython distribution and governed by its 
 3  # license.  Please see the LICENSE file that should have been included 
 4  # as part of this package. 
 5  """Collection of modules for dealing with biological data in Python. 
 6   
 7  The Biopython Project is an international association of developers  
 8  of freely available Python tools for computational molecular biology. 
 9   
10  http://biopython.org 
11  """ 
12   
13 -class MissingExternalDependencyError(Exception):
14 pass
15
16 -def _load_registries():
17 import sys, os 18 from Bio.config.Registry import Registry 19 20 if getattr(sys, "version_info", (1, 5))[:2] < (2, 1): 21 return 22 23 self = sys.modules[__name__] # self refers to this module. 24 # Load the registries. Look in all the '.py' files in Bio.config 25 # for Registry objects. Save them all into the local namespace. 26 # Import code changed to allow for compilation with py2exe from distutils 27 # import Bio.config 28 config_imports = __import__("Bio.config", {}, {}, ["Bio"]) 29 # in a zipfile 30 if hasattr(config_imports, '__loader__'): 31 zipfiles = __import__("Bio.config", {}, {}, ["Bio"]).__loader__._files 32 # Get only Bio.config modules 33 x = [zipfiles[file][0] for file in zipfiles.keys() \ 34 if 'Bio\\config' in file] 35 x = [name.split("\\")[-1] for name in x] # Get module name 36 x = map(lambda x: x[:-4], x) # chop off '.pyc' 37 # not in a zipfile, get files normally 38 else: 39 x = os.listdir(os.path.dirname(config_imports.__file__)) 40 x = filter(lambda x: not x.startswith("_") and x.endswith(".py"), x) 41 x = map(lambda x: x[:-3], x) # chop off '.py' 42 for module in x: 43 module = __import__("Bio.config.%s" % module, {}, {}, ["Bio","config"]) 44 for name, obj in module.__dict__.items(): 45 if name.startswith("_") or not isinstance(obj, Registry): 46 continue 47 setattr(self, name, obj)
48 49 # Put the registry loading code in a function so we don't polute the 50 # module namespace with local variables. 51 52 # WARNING: 53 # The call to _load_registries is being skipped as part of deprecating 54 # Bio.expressions, which does not function properly with the new version 55 # of mxTextTools. If at some point we decide to revive Bio.expressions, 56 # this line should be reinstated. 57 58 # _load_registries() 59 60 61 del _load_registries 62