allpy
changeset 988:59acf74bfeb3
pair_cores: add another high blocks building algo (or blocks3d algo optionally)
This is a binding to the algo from MonomerHomology class (highest_blocks)
author | Boris Nagaev <bnagaev@gmail.com> |
---|---|
date | Thu, 01 Mar 2012 00:24:08 +0400 |
parents | 508416802ca7 |
children | 43d4854f3473 |
files | pair_cores/pair_cores.py |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/pair_cores/pair_cores.py Wed Feb 29 22:40:54 2012 +0400 1.2 +++ b/pair_cores/pair_cores.py Thu Mar 01 00:24:08 2012 +0400 1.3 @@ -14,11 +14,12 @@ 1.4 import allpy.base 1.5 from html import html_template 1.6 from allpy.structure import CachedDownloadPdb, cached_download_pdb 1.7 +from allpy.homology import MonomerHomology 1.8 1.9 def homology_from_3d(markup_file, homology_file, max_delta, ignore_one_ss=False, alignment_file=None, 1.10 out_alignment_file=None, out_pair_cores_file=None, out_html_file=None, 1.11 pdb_getter=cached_download_pdb, out_pymol_file=None, min_width=4, 1.12 - out_high_blocks_file=None, out_high_blocks_html_file=None, 1.13 + out_high_blocks_file=None, out_high_blocks_html_file=None, blocks3d=False, 1.14 blocks3d_timeout=-1): 1.15 """ Turn pdb markup into homology_file 1.16 1.17 @@ -34,6 +35,7 @@ 1.18 * min_width -- min width of each core 1.19 * out_high_blocks_file -- output file with blocks of multiple sequences 1.20 * out_high_blocks_html_file -- output HTML file with blocks of multiple sequences 1.21 + * blocks3d -- if old (graph-based) blocks algorithm is used 1.22 * blocks3d_timeout -- Bron-Kerbosh (blocks3d) timeout (-1 - unlimited) 1.23 """ 1.24 if markup_file: 1.25 @@ -78,9 +80,15 @@ 1.26 block.blocks_to_pymol(out_pymol_file, blocks) 1.27 if out_high_blocks_file or out_high_blocks_html_file: 1.28 high_blocks = [] 1.29 - high_blocks = list(block.blocks3d(parts=blocks, 1.30 - timeout_2=blocks3d_timeout)) 1.31 - del blocks # spoiled by blocks3d() 1.32 + if blocks3d: 1.33 + high_blocks = list(block.blocks3d(parts=blocks, 1.34 + timeout_2=blocks3d_timeout)) 1.35 + del blocks # spoiled by blocks3d() 1.36 + else: 1.37 + homology = MonomerHomology() 1.38 + homology.read(homology_file.name, columns=True) 1.39 + homology.highest_blocks() 1.40 + high_blocks = block.blocks_from_homology(homology, min_width=min_width) 1.41 if out_high_blocks_file: 1.42 block.blocks_to_file(out_high_blocks_file, high_blocks) 1.43 if out_high_blocks_html_file: 1.44 @@ -106,6 +114,7 @@ 1.45 1.46 p.add_argument('--high-blocks',help='Output text file with high blocks',metavar='FILE',type=w) 1.47 p.add_argument('--high-blocks-html',help='Output HTML file with high blocks',metavar='FILE',type=w) 1.48 + p.add_argument('--blocks3d',help='Use blocks3d algorithm for high blocks',action='store_true') 1.49 p.add_argument('--blocks3d-timeout',help='Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)', 1.50 metavar='int',type=timeout,default=config.timeout_2) 1.51 args = p.parse_args() 1.52 @@ -115,7 +124,7 @@ 1.53 out_pymol_file=args.p,min_width=args.w, 1.54 out_high_blocks_file=args.high_blocks, 1.55 out_high_blocks_html_file=args.high_blocks_html, 1.56 - blocks3d_timeout=args.blocks3d_timeout) 1.57 + blocks3d=args.blocks3d, blocks3d_timeout=args.blocks3d_timeout) 1.58 1.59 if __name__ == '__main__': 1.60 main()