Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/tip/blocks3d/blocks3d.py
Дата изменения: Unknown
Дата индексирования: Tue Apr 12 11:23:48 2016
Кодировка:
allpy: b556c96c6719 blocks3d/blocks3d.py

allpy

view blocks3d/blocks3d.py @ 1168:b556c96c6719

blocks3d/www Makefile: never check certificates of github, they are too confusing for wget
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Mon, 26 May 2014 17:20:29 +0400
parents cf9236900f1c
children
line source
1 #!/usr/bin/python
2 """
3 Blocks3D
4 version 2.0
5 """
7 import argparse
8 import os
10 from allpy import config
11 from allpy import markup
12 from allpy.argparse_validators import f_nng, part, timeout, pos, i_nng
13 from allpy.structure import CachedDownloadPdb
15 from protein_pdb import Alignment, Block, Sequence
16 from html import html_template
18 r = argparse.FileType('r')
19 w = argparse.FileType('w')
20 c = config
22 p = argparse.ArgumentParser(
23 description='Blocks3D',
24 epilog='''1) Distance spreading [angstrom]
25 2) -1 timeout means running Bron-Kerbosch algorithm without timeout''',
26 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
27 )
29 p.add_argument('-v','--version',action='version',version='%(prog)s 2.0')
30 p.add_argument('-i',help='Input alignment file',metavar='FILE',type=r,required=True)
31 p.add_argument('-c',help='PDB names conformity file',metavar='FILE',type=r)
32 p.add_argument('-C',help='Pdb cache directory',metavar='DIR',type=str, default='pdb_cache')
33 p.add_argument('-S',action='store_const', const=True, help='Do not save downloaded PDBs', default=False)
34 p.add_argument('-o',help='Output text file',metavar='FILE',type=w)
35 p.add_argument('-H',help='Output html file',metavar='FILE',type=w)
36 p.add_argument('-d',help='Distance spreading',metavar='float',type=f_nng,default=c.delta)
37 p.add_argument('-e',help='Ignore cores, owned by one SS element',type=bool, default=False)
38 p.add_argument('-m',help='Min block width',metavar='int',type=pos,default=c.min_width)
39 p.add_argument('-t',help='Bron-Kerbosch (couple cores) timeout (-1 - unlimited)',metavar='int',type=timeout,default=0)
40 p.add_argument('-T',help='Bron-Kerbosch (blocks) timeout (-1 - unlimited)',metavar='int',type=timeout,default=c.timeout_2)
42 args = p.parse_args()
44 if not args.o and not args.H:
45 print 'Error: no output file provided'
46 exit()
48 pdb_getter = CachedDownloadPdb(cache_dir=args.C, save=(not args.S))
50 try:
51 alignment = Alignment().append_file(args.i, format='fasta')
52 except:
53 alignment = Alignment().append_file(args.i, format='msf')
55 block = Block.from_alignment(alignment)
56 for sequence in block.sequences:
57 sequence.auto_pdb(pdb_getter=pdb_getter)
59 blocks = list(block.blocks3d(max_delta=args.d,
60 timeout=args.t, timeout_2=args.T,
61 min_width=args.m, ignore_one_ss=args.e))
63 if args.H:
64 alignment.blocks_to_html(args.H, blocks, open(html_template).read())
66 if args.o:
67 alignment.blocks_to_file(args.o, blocks)