allpy
changeset 985:ce4ccbd2a1c2
pair_cores: add blocks3d outputs (high blocks)
author | Boris Nagaev <bnagaev@gmail.com> |
---|---|
date | Wed, 29 Feb 2012 15:16:46 +0400 |
parents | a1be82967e81 |
children | 854bb8659733 |
files | pair_cores/pair_cores.py |
diffstat | 1 files changed, 28 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/pair_cores/pair_cores.py Wed Feb 29 15:13:12 2012 +0400 1.2 +++ b/pair_cores/pair_cores.py Wed Feb 29 15:16:46 2012 +0400 1.3 @@ -7,6 +7,8 @@ 1.4 import argparse 1.5 from copy import copy 1.6 1.7 +from allpy import config 1.8 +from allpy.argparse_validators import timeout 1.9 from protein_pdb import Alignment, Block, Monomer, Sequence 1.10 from allpy import processors, markups 1.11 import allpy.base 1.12 @@ -15,7 +17,9 @@ 1.13 1.14 def homology_from_3d(markup_file, homology_file, max_delta, ignore_one_ss=False, alignment_file=None, 1.15 out_alignment_file=None, out_pair_cores_file=None, out_html_file=None, 1.16 - pdb_getter=cached_download_pdb, out_pymol_file=None, min_width=4): 1.17 + pdb_getter=cached_download_pdb, out_pymol_file=None, min_width=4, 1.18 + out_high_blocks_file=None, out_high_blocks_html_file=None, 1.19 + blocks3d_timeout=-1): 1.20 """ Turn pdb markup into homology_file 1.21 1.22 * markup_file -- file with pdb markup of alignment 1.23 @@ -28,6 +32,9 @@ 1.24 * pdb_getter -- see structure.SequenceMixin.auto_pdb 1.25 * out_pymol_file -- output file with PyMol superimposing script 1.26 * min_width -- min width of each core 1.27 + * out_high_blocks_file -- output file with blocks of multiple sequences 1.28 + * out_high_blocks_html_file -- output HTML file with blocks of multiple sequences 1.29 + * blocks3d_timeout -- Bron-Kerbosh (blocks3d) timeout (-1 - unlimited) 1.30 """ 1.31 if markup_file: 1.32 input_file = markup_file 1.33 @@ -60,6 +67,7 @@ 1.34 blocks = block.pair_core_parts(max_delta=max_delta, timeout=0, 1.35 min_width=min_width, ignore_one_ss=ignore_one_ss) 1.36 alignment.blocks_to_homology(homology_file, blocks) 1.37 + homology_file.close() 1.38 if out_alignment_file: 1.39 block.to_file(out_alignment_file) 1.40 if out_pair_cores_file: 1.41 @@ -68,6 +76,16 @@ 1.42 block.blocks_to_html(out_html_file, blocks, open(html_template).read()) 1.43 if out_pymol_file: 1.44 block.blocks_to_pymol(out_pymol_file, blocks) 1.45 + if out_high_blocks_file or out_high_blocks_html_file: 1.46 + high_blocks = [] 1.47 + high_blocks = list(block.blocks3d(parts=blocks, 1.48 + timeout_2=blocks3d_timeout)) 1.49 + del blocks # spoiled by blocks3d() 1.50 + if out_high_blocks_file: 1.51 + block.blocks_to_file(out_high_blocks_file, high_blocks) 1.52 + if out_high_blocks_html_file: 1.53 + block.blocks_to_html(out_high_blocks_html_file, high_blocks, 1.54 + open(html_template).read()) 1.55 1.56 def main(): 1.57 r = argparse.FileType('r') 1.58 @@ -85,15 +103,20 @@ 1.59 p.add_argument('-H',help='Output HTML file',metavar='FILE',type=w) 1.60 p.add_argument('-p',help='Output PyMol file',metavar='FILE',type=w) 1.61 p.add_argument('-w',help='Min width of pair core',metavar='WIDTH',type=int,default=4) 1.62 + 1.63 + p.add_argument('--high-blocks',help='Output text file with high blocks',metavar='FILE',type=w) 1.64 + p.add_argument('--high-blocks-html',help='Output HTML file with high blocks',metavar='FILE',type=w) 1.65 + p.add_argument('--blocks3d-timeout',help='Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)', 1.66 + metavar='int',type=timeout,default=config.timeout_2) 1.67 args = p.parse_args() 1.68 homology_from_3d(markup_file=args.m, homology_file=args.y, max_delta=args.d, ignore_one_ss=args.e, 1.69 alignment_file=args.i, out_alignment_file=args.o, out_pair_cores_file=args.b, 1.70 out_html_file=args.H, pdb_getter=CachedDownloadPdb(cache_dir=args.c), 1.71 - out_pymol_file=args.p,min_width=args.w) 1.72 + out_pymol_file=args.p,min_width=args.w, 1.73 + out_high_blocks_file=args.high_blocks, 1.74 + out_high_blocks_html_file=args.high_blocks_html, 1.75 + blocks3d_timeout=args.blocks3d_timeout) 1.76 1.77 if __name__ == '__main__': 1.78 - try: 1.79 main() 1.80 - except Exception, e: 1.81 - print e 1.82