Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/3a216769da26
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 01:17:07 2012
Кодировка:
allpy: 3a216769da26

allpy

changeset 798:3a216769da26

extract_pfam.py: command-line option parsing no longer interferes with importing of this script as a module
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Wed, 13 Jul 2011 18:01:42 +0400
parents 849d65b2fb1d
children f634a7d3943f
files utils/extract_pfam.py
diffstat 1 files changed, 30 insertions(+), 21 deletions(-) [+]
line diff
     1.1 --- a/utils/extract_pfam.py	Wed Jul 13 17:48:12 2011 +0400
     1.2 +++ b/utils/extract_pfam.py	Wed Jul 13 18:01:42 2011 +0400
     1.3 @@ -7,30 +7,39 @@
     1.4  from Bio import AlignIO, Align
     1.5  from allpy import base, protein, structure, markups
     1.6  
     1.7 -parser = optparse.OptionParser()
     1.8 -parser.add_option('--min-depth', type=int, default=2,
     1.9 -    help='Minimal allowed alignment weight')
    1.10 -parser.add_option('--min-width', type=int, default=20,
    1.11 -    help='Minimal allowed sequences length')
    1.12 -parser.add_option('-i', '--infile-name',
    1.13 -    default='/srv/databases/pfam/Pfam-A.full.gz',
    1.14 -    help='File with input alignments in Stockholm format')
    1.15 -parser.add_option('-o', '--outdir-name',
    1.16 -    default='/srv/databases/pfam/Pfam-with-PDB',
    1.17 -    help='Directory to save results to')
    1.18 -parser.add_option('-g', '--gzip', action='store_true', dest='gzip',
    1.19 -    help='Input file has gzip compression')
    1.20 -parser.add_option('-G', '--no-gzip', action='store_false', dest='gzip',
    1.21 -    help='Input file is plain text')
    1.22 -options, args = parser.parse_args()
    1.23 -if options.gzip is None:
    1.24 -    options.gzip = options.infile_name.endswith('.gz')
    1.25 -options.infile_name = os.path.abspath(options.infile_name)
    1.26 +class Struct(object):
    1.27 +    pass
    1.28 +
    1.29 +if __name__ == "__main__":
    1.30 +    parser = optparse.OptionParser()
    1.31 +    parser.add_option('--min-depth', type=int, default=2,
    1.32 +        help='Minimal allowed alignment weight')
    1.33 +    parser.add_option('--min-width', type=int, default=20,
    1.34 +        help='Minimal allowed sequences length')
    1.35 +    parser.add_option('-i', '--infile-name',
    1.36 +        default='/srv/databases/pfam/Pfam-A.full.gz',
    1.37 +        help='File with input alignments in Stockholm format')
    1.38 +    parser.add_option('-o', '--outdir-name',
    1.39 +        default='/srv/databases/pfam/Pfam-with-PDB',
    1.40 +        help='Directory to save results to')
    1.41 +    parser.add_option('-g', '--gzip', action='store_true', dest='gzip',
    1.42 +        help='Input file has gzip compression')
    1.43 +    parser.add_option('-G', '--no-gzip', action='store_false', dest='gzip',
    1.44 +        help='Input file is plain text')
    1.45 +    options, args = parser.parse_args()
    1.46 +    if options.gzip is None:
    1.47 +        options.gzip = options.infile_name.endswith('.gz')
    1.48 +    options.infile_name = os.path.abspath(options.infile_name)
    1.49 +else:
    1.50 +    options = Struct()
    1.51 +    options.min_depth = 2
    1.52 +    options.min_width = 20
    1.53 +    options.infile_name = '/srv/databases/pfam/Pfam-A.full.gz'
    1.54 +    options.outdir_name = '/srv/databases/pfam/Pfam-with-PDB'
    1.55 +    options.gzip = True
    1.56  
    1.57  download_pdb = structure.cached_download_pdb
    1.58  
    1.59 -class Struct(object):
    1.60 -    pass
    1.61  types = Struct()
    1.62  class Monomer(protein.Monomer):
    1.63      types = types