Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/83167a09a19d
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:33:50 2012
Кодировка: UTF-8
allpy: 83167a09a19d

allpy

changeset 1037:83167a09a19d 1.4.2

Merged utils, pair_cores, blocks3d and geometrical-core from 9ae23 into 1.4.2 This makes these programs broken. Porting to allpy 1.4.0 is required.
author Boris Nagaev <bnagaev@gmail.com>
date Mon, 19 Mar 2012 13:52:56 +0400
parents 08d892230e8c 9ae235d79156
children b551ded1420a
files NEWS allpy/base.py allpy/homology.py allpy/markups.py allpy/processors.py allpy/structure.py blocks3d/blocks3d.py geometrical_core/geometrical-core pair_cores/pair_cores.py test/test_markups.py
diffstat 16 files changed, 568 insertions(+), 11 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Fri Mar 16 16:45:00 2012 +0400
     1.2 +++ b/.hgignore	Mon Mar 19 13:52:56 2012 +0400
     1.3 @@ -31,6 +31,10 @@
     1.4  blocks3d/wt/files/resources
     1.5  blocks3d/html.htm
     1.6  pair_cores/html.htm
     1.7 +pair_cores/web/wc
     1.8 +pair_cores/web/*.o
     1.9 +pair_cores/web/*root
    1.10 +pair_cores/web/pair-cores.wt
    1.11  *.zip
    1.12  
    1.13  # Temporary files from sphinx
     2.1 --- a/NEWS	Fri Mar 16 16:45:00 2012 +0400
     2.2 +++ b/NEWS	Mon Mar 19 13:52:56 2012 +0400
     2.3 @@ -1,3 +1,10 @@
     2.4 +  * new: Geometrical core improvement: ignore cores, owned by one SS element
     2.5 +
     2.6 +  * new: add features of blocks3d.py to pair_cores.py
     2.7 +  * new: add MonomerHomology-based high blocks building algo to pair-cores
     2.8 +  * new: print default values of command line args in help message (pair_cores)
     2.9 +  * new: add web interface for pair-cores
    2.10 +
    2.11  1.4.1
    2.12  
    2.13  This is a code cleanup release.
     3.1 --- a/blocks3d/blocks3d.py	Fri Mar 16 16:45:00 2012 +0400
     3.2 +++ b/blocks3d/blocks3d.py	Mon Mar 19 13:52:56 2012 +0400
     3.3 @@ -34,6 +34,7 @@
     3.4  p.add_argument('-o',help='Output text file',metavar='FILE',type=w)
     3.5  p.add_argument('-H',help='Output html file',metavar='FILE',type=w)
     3.6  p.add_argument('-d',help='Distance spreading',metavar='float',type=f_nng,default=c.delta)
     3.7 +p.add_argument('-e',help='Ignore cores, owned by one SS element',type=bool, default=False)
     3.8  p.add_argument('-m',help='Min block width',metavar='int',type=pos,default=c.min_width)
     3.9  p.add_argument('-t',help='Bron-Kerbosh (couple cores) timeout (-1 - unlimited)',metavar='int',type=timeout,default=0)
    3.10  p.add_argument('-T',help='Bron-Kerbosh (blocks) timeout (-1 - unlimited)',metavar='int',type=timeout,default=c.timeout_2)
    3.11 @@ -44,7 +45,7 @@
    3.12      print 'Error: no output file provided'
    3.13      exit()
    3.14  
    3.15 -pdb_getter = CachedDownloadPdb(cache_dir=args.C) # FIXME , save=(not args.S))
    3.16 +pdb_getter = CachedDownloadPdb(cache_dir=args.C, save=(not args.S))
    3.17  
    3.18  try:
    3.19      alignment = Alignment().append_file(args.i, format='fasta')
    3.20 @@ -57,7 +58,7 @@
    3.21  
    3.22  blocks = list(block.blocks3d(max_delta=args.d,
    3.23      timeout=args.t, timeout_2=args.T,
    3.24 -    min_width=args.m))
    3.25 +    min_width=args.m, ignore_one_ss=args.e))
    3.26  
    3.27  if args.H:
    3.28      alignment.blocks_to_html(args.H, blocks, open(html_template).read())
     4.1 --- a/blocks3d/protein_pdb.py	Fri Mar 16 16:45:00 2012 +0400
     4.2 +++ b/blocks3d/protein_pdb.py	Mon Mar 19 13:52:56 2012 +0400
     4.3 @@ -16,3 +16,6 @@
     4.4  class Monomer(protein.Monomer):
     4.5      types = protein_pdb
     4.6  
     4.7 +class Column(protein.Column):
     4.8 +    types = protein_pdb
     4.9 +
     5.1 --- a/geometrical_core/geometrical-core	Fri Mar 16 16:45:00 2012 +0400
     5.2 +++ b/geometrical_core/geometrical-core	Mon Mar 19 13:52:56 2012 +0400
     5.3 @@ -40,6 +40,7 @@
     5.4  p.add_argument('-s',help='Output spt file',metavar='FILE',type=w)
     5.5  p.add_argument('-d',help='Distance spreading',
     5.6      metavar='float',type=f_nng,default=c.delta)
     5.7 +p.add_argument('-e',help='Ignore cores, owned by one SS element',type=bool, default=False)
     5.8  p.add_argument('-m',help='Min core size',
     5.9      metavar='int',type=pos,default=c.minsize)
    5.10  p.add_argument('-t',help='Bron-Kerbosh algorithm timeout',
    5.11 @@ -70,7 +71,7 @@
    5.12  for sequence in block.sequences:
    5.13      sequence.auto_pdb()
    5.14  GCs = block.geometrical_cores(max_delta=args.d, timeout=args.t,
    5.15 -    minsize=args.t, ac_new_atoms=args.n, ac_count=args.a)
    5.16 +    minsize=args.t, ac_new_atoms=args.n, ac_count=args.a, ignore_one_ss=args.e)
    5.17  
    5.18  column2pos = block.column2pos()
    5.19  
     6.1 --- a/geometrical_core/protein_pdb.py	Fri Mar 16 16:45:00 2012 +0400
     6.2 +++ b/geometrical_core/protein_pdb.py	Mon Mar 19 13:52:56 2012 +0400
     6.3 @@ -16,3 +16,6 @@
     6.4  class Monomer(protein.Monomer):
     6.5      types = protein_pdb
     6.6  
     6.7 +class Column(protein.Column):
     6.8 +    types = protein_pdb
     6.9 +
     7.1 --- a/pair_cores/pair_cores.py	Fri Mar 16 16:45:00 2012 +0400
     7.2 +++ b/pair_cores/pair_cores.py	Mon Mar 19 13:52:56 2012 +0400
     7.3 @@ -7,15 +7,20 @@
     7.4  import argparse
     7.5  from copy import copy
     7.6  
     7.7 +from allpy import config
     7.8 +from allpy.argparse_validators import timeout
     7.9  from protein_pdb import Alignment, Block, Monomer, Sequence
    7.10  from allpy import processors, markups
    7.11  import allpy.base
    7.12  from html import html_template
    7.13  from allpy.structure import CachedDownloadPdb, cached_download_pdb
    7.14 +from allpy.homology import MonomerHomology
    7.15  
    7.16 -def homology_from_3d(markup_file, homology_file, max_delta, alignment_file=None,
    7.17 +def homology_from_3d(markup_file, homology_file, max_delta, ignore_one_ss=False, alignment_file=None,
    7.18      out_alignment_file=None, out_pair_cores_file=None, out_html_file=None,
    7.19 -    pdb_getter=cached_download_pdb):
    7.20 +    pdb_getter=cached_download_pdb, out_pymol_file=None, min_width=4,
    7.21 +    out_high_blocks_file=None, out_high_blocks_html_file=None, blocks3d=False,
    7.22 +    blocks3d_timeout=-1,pair_timeout=0):
    7.23      """ Turn pdb markup into homology_file
    7.24  
    7.25      * markup_file -- file with pdb markup of alignment
    7.26 @@ -26,6 +31,13 @@
    7.27      * out_pair_cores_file -- output file with pair geomatrical cores
    7.28      * out_html_file -- output file with HTML representation of blocks
    7.29      * pdb_getter -- see structure.SequenceMixin.auto_pdb
    7.30 +    * out_pymol_file -- output file with PyMol superimposing script
    7.31 +    * min_width -- min width of each core
    7.32 +    * out_high_blocks_file -- output file with blocks of multiple sequences
    7.33 +    * out_high_blocks_html_file -- output HTML file with blocks of multiple sequences
    7.34 +    * blocks3d -- if old (graph-based) blocks algorithm is used
    7.35 +    * blocks3d_timeout -- Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)
    7.36 +    * pair_timeout -- Bron-Kerbosh (pair cores) timeout (-1 - unlimited)
    7.37      """
    7.38      if markup_file:
    7.39          input_file = markup_file
    7.40 @@ -46,41 +58,82 @@
    7.41      for sequence in copy(alignment.sequences):
    7.42          try:
    7.43              if markup_file:
    7.44 -                sequence.markups['pdb_resi'].add_pdb(download_pdb=pdb_getter, xyz_only=True)
    7.45 +                sequence.markups['pdb_resi'].add_pdb(download_pdb=pdb_getter)
    7.46              else:
    7.47 -                sequence.auto_pdb(xyz_only=True, pdb_getter=pdb_getter)
    7.48 +                sequence.auto_pdb(pdb_getter=pdb_getter)
    7.49          except Exception, e:
    7.50              raise Exception("Can't load structure for sequence %s from file %s (%s: %s)" % \
    7.51                  (sequence.name, input_file, e.__class__, e))
    7.52      if len(alignment.sequences) < 2:
    7.53          raise Exception("Alignment from file %s has too few sequences" % input_file)
    7.54      block = Block.from_alignment(alignment)
    7.55 -    blocks = block.pair_core_parts(max_delta=max_delta, timeout=0)
    7.56 +    blocks = block.pair_core_parts(max_delta=max_delta, timeout=pair_timeout,
    7.57 +        min_width=min_width, ignore_one_ss=ignore_one_ss)
    7.58      alignment.blocks_to_homology(homology_file, blocks)
    7.59 +    homology_file.close()
    7.60      if out_alignment_file:
    7.61          block.to_file(out_alignment_file)
    7.62      if out_pair_cores_file:
    7.63          block.blocks_to_file(out_pair_cores_file, blocks)
    7.64      if out_html_file:
    7.65          block.blocks_to_html(out_html_file, blocks, open(html_template).read())
    7.66 +    if out_pymol_file:
    7.67 +        block.blocks_to_pymol(out_pymol_file, blocks)
    7.68 +    if out_high_blocks_file or out_high_blocks_html_file:
    7.69 +        high_blocks = []
    7.70 +        if blocks3d:
    7.71 +            high_blocks = list(block.blocks3d(parts=blocks,
    7.72 +                timeout_2=blocks3d_timeout))
    7.73 +            del blocks # spoiled by blocks3d()
    7.74 +        else:
    7.75 +            homology = MonomerHomology()
    7.76 +            homology.read(homology_file.name, columns=True)
    7.77 +            homology.highest_blocks()
    7.78 +            high_blocks = block.blocks_from_homology(homology, min_width=min_width)
    7.79 +            high_blocks = reduce(lambda a,b:a+b,
    7.80 +                    (pre_block.continuous_blocks(min_width)
    7.81 +                        for pre_block in high_blocks), [])
    7.82 +            high_blocks = [b for b in high_blocks if len(b.sequences) >= 2]
    7.83 +        if out_high_blocks_file:
    7.84 +            block.blocks_to_file(out_high_blocks_file, high_blocks)
    7.85 +        if out_high_blocks_html_file:
    7.86 +            block.blocks_to_html(out_high_blocks_html_file, high_blocks,
    7.87 +                open(html_template).read())
    7.88  
    7.89  def main():
    7.90      r = argparse.FileType('r')
    7.91      w = argparse.FileType('w')
    7.92 -    p = argparse.ArgumentParser(description='PairCores')
    7.93 +    p = argparse.ArgumentParser(description='PairCores',
    7.94 +    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    7.95      p.add_argument('-v','--version',action='version',version='%(prog)s 2.0')
    7.96      p.add_argument('-m',help='Input pdb markup file',metavar='FILE',type=r)
    7.97      p.add_argument('-i',help='Input alignment file',metavar='FILE',type=r)
    7.98      p.add_argument('-y',help='Output homology file',metavar='FILE',type=w, required=True)
    7.99      p.add_argument('-c',help='Pdb cache directory',metavar='DIR',type=str, default='pdb_cache')
   7.100      p.add_argument('-d',help='Distance spreading',metavar='float',type=float,default=2.0)
   7.101 +    p.add_argument('-e',help='Ignore cores, owned by one SS element',type=bool, default=False)
   7.102      p.add_argument('-o',help='Output alignment file',metavar='FILE',type=w)
   7.103      p.add_argument('-b',help='Output pair_cores file',metavar='FILE',type=w)
   7.104      p.add_argument('-H',help='Output HTML file',metavar='FILE',type=w)
   7.105 +    p.add_argument('-p',help='Output PyMol file',metavar='FILE',type=w)
   7.106 +    p.add_argument('-w',help='Min width of pair core',metavar='WIDTH',type=int,default=4)
   7.107 +
   7.108 +    p.add_argument('--high-blocks',help='Output text file with high blocks',metavar='FILE',type=w)
   7.109 +    p.add_argument('--high-blocks-html',help='Output HTML file with high blocks',metavar='FILE',type=w)
   7.110 +    p.add_argument('--blocks3d',help='Use blocks3d algorithm for high blocks',action='store_true')
   7.111 +    p.add_argument('--blocks3d-timeout',help='Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)',
   7.112 +            metavar='int',type=timeout,default=config.timeout_2)
   7.113 +    p.add_argument('--pair-timeout',help='Bron-Kerbosh (pair cores) timeout (-1 - unlimited)',
   7.114 +            metavar='int',type=timeout,default=0)
   7.115      args = p.parse_args()
   7.116 -    homology_from_3d(markup_file=args.m, homology_file=args.y, max_delta=args.d,
   7.117 +    homology_from_3d(markup_file=args.m, homology_file=args.y, max_delta=args.d, ignore_one_ss=args.e,
   7.118          alignment_file=args.i, out_alignment_file=args.o, out_pair_cores_file=args.b,
   7.119 -        out_html_file=args.H, pdb_getter=CachedDownloadPdb(cache_dir=args.c))
   7.120 +        out_html_file=args.H, pdb_getter=CachedDownloadPdb(cache_dir=args.c),
   7.121 +        out_pymol_file=args.p,min_width=args.w,
   7.122 +        out_high_blocks_file=args.high_blocks,
   7.123 +        out_high_blocks_html_file=args.high_blocks_html,
   7.124 +        blocks3d=args.blocks3d, blocks3d_timeout=args.blocks3d_timeout,
   7.125 +        pair_timeout=args.pair_timeout)
   7.126  
   7.127  if __name__ == '__main__':
   7.128      try:
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/pair_cores/web/Makefile	Mon Mar 19 13:52:56 2012 +0400
     8.3 @@ -0,0 +1,53 @@
     8.4 +
     8.5 +all: build environment
     8.6 +
     8.7 +.PHONY: build
     8.8 +build: pair-cores.wt
     8.9 +
    8.10 +.PHONY: environment
    8.11 +environment: wc
    8.12 +	cd approot && ln -fs ../wc/locales wc-locales
    8.13 +	mkdir -p docroot/resources
    8.14 +	cd docroot/resources && rm -fr Wc
    8.15 +	cd docroot/resources && ln -fs /usr/share/Wt/resources/* .
    8.16 +	cd docroot/resources && rm -fr Wc
    8.17 +	cd docroot/resources && mkdir -p Wc
    8.18 +	cd docroot/resources/Wc && ln -fs ../../../wc/css/
    8.19 +	cd docroot/resources/Wc && ln -fs ../../../wc/js/
    8.20 +
    8.21 +.SECONDEXPANSION:
    8.22 +
    8.23 +wc_cpp = wc/src/Wbi.cpp wc/src/TableForm.cpp wc/src/util.cpp \
    8.24 +		wc/src/Countdown.cpp wc/src/TimeDuration.cpp wc/src/rand.cpp
    8.25 +
    8.26 +wc_hpp = $(wc_cpp:.cpp=.hpp) wc/src/global.hpp
    8.27 +
    8.28 +sources = $(wc_cpp) pair-cores.cpp
    8.29 +objects = $(sources:.cpp=.o)
    8.30 +headers = $(wc_hpp)
    8.31 +
    8.32 +WT_CONNECTOR=http
    8.33 +CXX = g++
    8.34 +LINK = g++
    8.35 +LIBS += -lwt$(WT_CONNECTOR)
    8.36 +LIBS += -lwt
    8.37 +LIBS += -lboost_signals -lboost_filesystem -lboost_system -lboost_thread
    8.38 +
    8.39 +%.o: %.cpp $$(headers)
    8.40 +	$(CXX) -c $(CXXFLAGS) $< -o $@
    8.41 +
    8.42 +$(wc_cpp) $(wc_hpp): wc
    8.43 +
    8.44 +pair-cores.wt: $$(objects)
    8.45 +	$(LINK) $(LFLAGS) $(objects) $(LIBS) -o $@
    8.46 +
    8.47 +wc:
    8.48 +	wget https://bitbucket.org/starius/wt-classes/get/1.3.5.tar.gz -O - | \
    8.49 +		tar -xz
    8.50 +	mkdir -p wc
    8.51 +	cp -a starius-wt-classes-*/* wc
    8.52 +	rm -r starius-wt-classes-*
    8.53 +	$(MAKE) -C wc js/jquery.countdown.js
    8.54 +	cd wc && ./for-wt-3.1.2.sh
    8.55 +	cd wc && ./no-openssl.sh
    8.56 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/pair_cores/web/README.rst	Mon Mar 19 13:52:56 2012 +0400
     9.3 @@ -0,0 +1,47 @@
     9.4 +Pair-cores web interface
     9.5 +========================
     9.6 +
     9.7 +Here is a web-interface for pair-cores program from allpy package.
     9.8 +
     9.9 +Requirements
    9.10 +------------
    9.11 +
    9.12 + * pair-cores command (hg rev e8c9f0a3482e +)
    9.13 + * g++ 4.5+
    9.14 + * Wt library 3.1.2+
    9.15 + * boost library (>= 1.42)
    9.16 +
    9.17 +Wt-classes library is included in this web ui, you do not need
    9.18 +to have it installed.
    9.19 +
    9.20 +Build
    9.21 +-----
    9.22 +
    9.23 + $ make build
    9.24 +
    9.25 +This will build pair-cores.wt executable, linked with wt http connector.
    9.26 +To build fcgi linked program, pass "WT_CONNECTOR=fcgi" to make.
    9.27 +
    9.28 +To test it, some files are needed:
    9.29 +
    9.30 + $ make environment
    9.31 +
    9.32 +Since Wt 3.1.2 does not accept --approot option,
    9.33 +it can be passed through wt_config "approot" runtime property.
    9.34 +By default, current directory is used as approot.
    9.35 +
    9.36 +Run test script:
    9.37 +
    9.38 + $ sh run.sh
    9.39 +
    9.40 +Links
    9.41 +-----
    9.42 +
    9.43 +For more information please visit:
    9.44 + * allpy (and pair-cores) homepage:
    9.45 +    http://kodomo.fbb.msu.ru/trac/allpy
    9.46 + * Distributed version control system of wt-classes:
    9.47 +    https://bitbucket.org/starius/wt-classes/
    9.48 + * Wt homepage:
    9.49 +    http://webtoolkit.eu/
    9.50 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/pair_cores/web/approot/locales/pair-cores-web.xml	Mon Mar 19 13:52:56 2012 +0400
    10.3 @@ -0,0 +1,57 @@
    10.4 +<?xml version="1.0" encoding="UTF-8"?>
    10.5 +<messages nplurals='2' plural="n==1 ? 0 : 1">
    10.6 +
    10.7 +    <message id='pair.in.Alignment'>Alignment file</message>
    10.8 +    <message id='pair.in.Delta'>Distance spreading</message>
    10.9 +    <message id='pair.in.Markup'>Markup file</message>
   10.10 +    <message id='pair.in.SS'>Ignore cores, owned by one SS element</message>
   10.11 +    <message id='pair.in.Width'>Min width of a block</message>
   10.12 +    <message id='pair.in.Blocks3D'>
   10.13 +        Use blocks3d algorithm for high blocks
   10.14 +    </message>
   10.15 +    <message id='pair.in.Blocks3D_timeout'>
   10.16 +        Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)
   10.17 +    </message>
   10.18 +    <message id='pair.in.Error_one_input'>
   10.19 +        Input alignment or input markup must be specified
   10.20 +    </message>
   10.21 +    <message id='pair.in.Pair_timeout'>
   10.22 +        Bron-Kerbosh (pair cores) timeout (-1 - unlimited)
   10.23 +    </message>
   10.24 +
   10.25 +    <message id='pair.main.Header'><h1>PairCores</h1></message>
   10.26 +    <message id='pair.main.Refresh'>Refresh</message>
   10.27 +    <message id='pair.main.Reset'>Reset</message>
   10.28 +    <message id='pair.main.Example'>
   10.29 +        Here is an example of an alignment for input for the program:
   10.30 +    </message>
   10.31 +    <message id='pair.main.Example_fasta'>
   10.32 +        <pre>
   10.33 +>1PER_L
   10.34 +SISSRVKSKRIQLGLNQAELAQKVGTTQQSIEQLENGKTK-RPRFLPELASALGVS
   10.35 +VDWLLNGT
   10.36 +>1PER_R
   10.37 +SISSRVKSKRIQLGLNQAELAQKVGTTQQSIEQLENGKTK-RPRFLPELASALGVS
   10.38 +VDWLLNGT
   10.39 +>1ADR_A_1
   10.40 +LMGERIRARRKKLKIRQAALGKMVGVSNVAISQWERSETEPNGENLLALSKALQCS
   10.41 +PDYLLKGD
   10.42 +>1ADR_A_2
   10.43 +LMGERIRARRKKLKIRQAALGKMVGVSNVAISQWERSETEPNGENLLALSKALQCS
   10.44 +PDYLLKGD
   10.45 +        </pre>
   10.46 +    </message>
   10.47 +    <message id='pair.main.Rfbr'>
   10.48 +        The work was partly supported by
   10.49 +        the Russian Foundation for Basic Research, grant 09-04-92743
   10.50 +    </message>
   10.51 +
   10.52 +    <message id='pair.out.High_blocks'>Text file with high blocks</message>
   10.53 +    <message id='pair.out.High_html'>HTML file with high blocks</message>
   10.54 +    <message id='pair.out.Homology'>Homology file</message>
   10.55 +    <message id='pair.out.Pair_blocks'>Pair cores file</message>
   10.56 +    <message id='pair.out.Pair_html'>Pair cores HTML file</message>
   10.57 +    <message id='pair.out.Pymol'>PyMol file</message>
   10.58 +
   10.59 +</messages>
   10.60 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/pair_cores/web/approot/locales/pair-cores-web_ru.xml	Mon Mar 19 13:52:56 2012 +0400
    11.3 @@ -0,0 +1,47 @@
    11.4 +<?xml version="1.0" encoding="UTF-8"?>
    11.5 +<messages nplurals="3"
    11.6 +    plural="(n%10 == 0 || n%10 >= 5 || n/10%10 == 1) ? 2 : n%10==1 ? 0 : 1">
    11.7 +
    11.8 +    <message id='pair.in.Alignment'>Выравнивание</message>
    11.9 +    <message id='pair.in.Markup'>Разметка</message>
   11.10 +    <message id='pair.in.Width'>Минимальная ширина блока</message>
   11.11 +    <message id='pair.in.Blocks3D'>
   11.12 +        Использовать алгоритм blocks3d для вертикальных блоков
   11.13 +    </message>
   11.14 +    <message id='pair.in.Blocks3D_timeout'>
   11.15 +        Ограничение по времени на работу алгоритма Брона-Кербоша <br/>
   11.16 +        для blocks3d (в секундах, -1 - без ограничения)
   11.17 +    </message>
   11.18 +    <message id='pair.in.Delta'>
   11.19 +        Допустимое расхождение расстояний между атомами
   11.20 +    </message>
   11.21 +    <message id='pair.in.Error_one_input'>
   11.22 +        Входное выравнивание или входная разметка должны быть указаны
   11.23 +    </message>
   11.24 +    <message id='pair.in.Pair_timeout'>
   11.25 +        Ограничение по времени на работу алгоритма Брона-Кербоша <br/>
   11.26 +        для парных ядер (в секундах, -1 - без ограничения)
   11.27 +    </message>
   11.28 +    <message id='pair.in.SS'>
   11.29 +        Пропускать ядра, входящие в один элемент вторичной структуры
   11.30 +    </message>
   11.31 +
   11.32 +    <message id='pair.main.Refresh'>Обновить</message>
   11.33 +    <message id='pair.main.Reset'>Сбросить</message>
   11.34 +    <message id='pair.main.Example'>
   11.35 +        Пример входного выравнивания для программы:
   11.36 +    </message>
   11.37 +    <message id='pair.main.Rfbr'>
   11.38 +        Работа частично поддержана
   11.39 +        Российским Фондом Фундаментальных Исследований, грант 09-04-92743
   11.40 +    </message>
   11.41 +
   11.42 +    <message id='pair.out.High_blocks'>Вертикальные блоки (текст)</message>
   11.43 +    <message id='pair.out.High_html'>Вертикальные блоки (HTML)</message>
   11.44 +    <message id='pair.out.Homology'>Файл гомологии</message>
   11.45 +    <message id='pair.out.Pair_blocks'>Парные блоки (текст)</message>
   11.46 +    <message id='pair.out.Pair_html'>Парные блоки (HTML)</message>
   11.47 +    <message id='pair.out.Pymol'>PyMol-скрипт</message>
   11.48 +
   11.49 +</messages>
   11.50 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/pair_cores/web/docroot/css/pair-cores.css	Mon Mar 19 13:52:56 2012 +0400
    12.3 @@ -0,0 +1,14 @@
    12.4 +.wt_tableform_header {
    12.5 +    background-color: #CFE4EB;
    12.6 +    color: #004040;
    12.7 +    font-weight: bold;
    12.8 +}
    12.9 +
   12.10 +.wc_task_message {
   12.11 +    color: red;
   12.12 +}
   12.13 +
   12.14 +.wt_tableform_comment {
   12.15 +    color: red;
   12.16 +}
   12.17 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/pair_cores/web/pair-cores.cpp	Mon Mar 19 13:52:56 2012 +0400
    13.3 @@ -0,0 +1,179 @@
    13.4 +#include <boost/bind.hpp>
    13.5 +
    13.6 +#include <Wt/WApplication>
    13.7 +#include <Wt/WEnvironment>
    13.8 +#include <Wt/WIntValidator>
    13.9 +#include <Wt/WDoubleValidator>
   13.10 +#include <Wt/WLineEdit>
   13.11 +#include <Wt/WCheckBox>
   13.12 +#include <Wt/WTemplate>
   13.13 +#include <Wt/WFileUpload>
   13.14 +#include <Wt/WPushButton>
   13.15 +
   13.16 +#include "wc/src/Wbi.hpp"
   13.17 +#include "wc/src/util.hpp"
   13.18 +
   13.19 +using namespace Wt;
   13.20 +using namespace Wt::Wc;
   13.21 +
   13.22 +TaskNumberQueue queue(100);
   13.23 +
   13.24 +bool validate(AbstractTask* task, TextFileInput* input_markup,
   13.25 +              TextFileInput* input_aln) {
   13.26 +    bool markup = input_markup->state() == AbstractInput::VALID;
   13.27 +    bool aln = input_aln->state() == AbstractInput::VALID;
   13.28 +    if (markup != aln) {
   13.29 +        task->set_message("");
   13.30 +        return true;
   13.31 +    } else {
   13.32 +        task->set_message(WString::tr("pair.in.Error_one_input"));
   13.33 +        return false;
   13.34 +    }
   13.35 +}
   13.36 +
   13.37 +std::string name_gen(TextFileInput* input_markup, TextFileInput* input_aln,
   13.38 +                     std::string extension) {
   13.39 +    TextFileInput* input = input_markup->state() == AbstractInput::VALID ?
   13.40 +                           input_markup : input_aln;
   13.41 +    std::string file = input->file_upload()->clientFileName().toUTF8();
   13.42 +    std::string without_extension = file.substr(0, file.find_last_of("."));
   13.43 +    if (without_extension.empty()) {
   13.44 +        without_extension = "pair-cores";
   13.45 +    }
   13.46 +    return without_extension + "." + extension;
   13.47 +}
   13.48 +
   13.49 +class PairCoresApp : public WApplication {
   13.50 +public:
   13.51 +    PairCoresApp(const WEnvironment& env);
   13.52 +
   13.53 +private:
   13.54 +    void reset_contents();
   13.55 +
   13.56 +    void do_nothing()
   13.57 +    { }
   13.58 +
   13.59 +    static Wt::WString tr(const char* key) {
   13.60 +        return Wt::WString::tr(key);
   13.61 +    }
   13.62 +};
   13.63 +
   13.64 +PairCoresApp::PairCoresApp(const WEnvironment& env):
   13.65 +    WApplication(env) {
   13.66 +    enableUpdates(true);
   13.67 +    std::string approot = config_value("approot", "");
   13.68 +    messageResourceBundle().use(approot + "wc-locales/wtclasses");
   13.69 +    messageResourceBundle().use(approot + "locales/pair-cores-web");
   13.70 +    useStyleSheet("css/pair-cores.css");
   13.71 +    reset_contents();
   13.72 +}
   13.73 +
   13.74 +void PairCoresApp::reset_contents() {
   13.75 +    root()->clear();
   13.76 +    //
   13.77 +    new Wt::WTemplate(tr("pair.main.Header"), root());
   13.78 +    if (!environment().ajax()) {
   13.79 +        WPushButton* refresh = new WPushButton(tr("pair.main.Refresh"), root());
   13.80 +        refresh->clicked().connect(this, &PairCoresApp::do_nothing);
   13.81 +    }
   13.82 +    WPushButton* reset = new WPushButton(tr("pair.main.Reset"), root());
   13.83 +    reset->clicked().connect(this, &PairCoresApp::reset_contents);
   13.84 +    //
   13.85 +    TableTask* task = new TableTask(root());
   13.86 +    //
   13.87 +    TextFileInput* input_markup = new TextFileInput("-m");
   13.88 +    input_markup->set_required(false);
   13.89 +    task->add_input(input_markup, tr("pair.in.Markup"));
   13.90 +    //
   13.91 +    TextFileInput* input_aln = new TextFileInput("-i");
   13.92 +    input_aln->set_required(false);
   13.93 +    task->add_input(input_aln, tr("pair.in.Alignment"));
   13.94 +    //
   13.95 +    WLineEdit* delta_edit = new WLineEdit("2.0");
   13.96 +    delta_edit->setValidator(new WDoubleValidator(0, 10));
   13.97 +    delta_edit->validator()->setMandatory(true);
   13.98 +    LineEditInput* delta = new LineEditInput(delta_edit, "-d");
   13.99 +    task->add_input(delta, tr("pair.in.Delta"));
  13.100 +    //
  13.101 +    WLineEdit* width_edit = new WLineEdit("3");
  13.102 +    width_edit->setValidator(new WIntValidator(3, 9999));
  13.103 +    width_edit->validator()->setMandatory(true);
  13.104 +    LineEditInput* width = new LineEditInput(width_edit, "-w");
  13.105 +    task->add_input(width, tr("pair.in.Width"));
  13.106 +    //
  13.107 +    BoolInput* blocks3d = new BoolInput(new WCheckBox(), "--blocks3d");
  13.108 +    task->add_input(blocks3d, tr("pair.in.Blocks3D"));
  13.109 +    //
  13.110 +    BoolInput* ioss = new BoolInput(new WCheckBox(), "-e");
  13.111 +    ioss->set_value_if_true("True");
  13.112 +    task->add_input(ioss, tr("pair.in.SS"));
  13.113 +    //
  13.114 +    WLineEdit* pair_timeout_edit = new WLineEdit("10");
  13.115 +    pair_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600));
  13.116 +    pair_timeout_edit->validator()->setMandatory(true);
  13.117 +    LineEditInput* pair_timeout = new LineEditInput(pair_timeout_edit,
  13.118 +            "--pair-timeout");
  13.119 +    task->add_input(pair_timeout, tr("pair.in.Pair_timeout"));
  13.120 +    //
  13.121 +    WLineEdit* blocks3d_timeout_edit = new WLineEdit("-1");
  13.122 +    blocks3d_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600));
  13.123 +    blocks3d_timeout_edit->validator()->setMandatory(true);
  13.124 +    LineEditInput* blocks3d_timeout = new LineEditInput(blocks3d_timeout_edit,
  13.125 +            "--blocks3d-timeout");
  13.126 +    task->add_input(blocks3d_timeout, tr("pair.in.Blocks3D_timeout"));
  13.127 +    //
  13.128 +    // outputs
  13.129 +    //
  13.130 +    boost::function<std::string(std::string)> name_gen2 = boost::bind(name_gen,
  13.131 +            input_markup, input_aln, _1);
  13.132 +    //
  13.133 +    ViewFileOutput* homology = new ViewFileOutput("-y");
  13.134 +    homology->set_suggested_gen(boost::bind(name_gen2, "hom"));
  13.135 +    homology->set_selectable(false);
  13.136 +    task->add_output(homology, tr("pair.out.Homology"));
  13.137 +    //
  13.138 +    ViewFileOutput* pair_blocks = new ViewFileOutput("-b");
  13.139 +    pair_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks"));
  13.140 +    task->add_output(pair_blocks, tr("pair.out.Pair_blocks"));
  13.141 +    //
  13.142 +    ViewFileOutput* pair_html = new ViewFileOutput("-H",
  13.143 +            &FileOutput::unique_name,
  13.144 +            "application/octet-stream",
  13.145 +            "text/html");
  13.146 +    pair_html->set_suggested_gen(boost::bind(name_gen2, "html"));
  13.147 +    task->add_output(pair_html, tr("pair.out.Pair_html"));
  13.148 +    //
  13.149 +    ViewFileOutput* pymol = new ViewFileOutput("-p");
  13.150 +    pymol->set_suggested_gen(boost::bind(name_gen2, "pml"));
  13.151 +    task->add_output(pymol, tr("pair.out.Pymol"));
  13.152 +    //
  13.153 +    ViewFileOutput* high_blocks = new ViewFileOutput("--high-blocks");
  13.154 +    high_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks"));
  13.155 +    task->add_output(high_blocks, tr("pair.out.High_blocks"));
  13.156 +    //
  13.157 +    ViewFileOutput* high_html = new ViewFileOutput("--high-blocks-html",
  13.158 +            &FileOutput::unique_name,
  13.159 +            "application/octet-stream",
  13.160 +            "text/html");
  13.161 +    high_html->set_suggested_gen(boost::bind(name_gen2, "html"));
  13.162 +    task->add_output(high_html, tr("pair.out.High_html"));
  13.163 +    //
  13.164 +    task->set_runner(new ForkingRunner("pair-cores"));
  13.165 +    task->set_queue(&queue);
  13.166 +    task->set_validator(boost::bind(validate, task, input_markup, input_aln));
  13.167 +    new TaskCountup(task, root());
  13.168 +    //
  13.169 +    new WBreak(root());
  13.170 +    new Wt::WTemplate(tr("pair.main.Example"), root());
  13.171 +    new Wt::WTemplate(tr("pair.main.Example_fasta"), root());
  13.172 +    new Wt::WTemplate(tr("pair.main.Rfbr"), root());
  13.173 +}
  13.174 +
  13.175 +WApplication* createPairCoresApp(const WEnvironment& env) {
  13.176 +    return new PairCoresApp(env);
  13.177 +}
  13.178 +
  13.179 +int main(int argc, char** argv) {
  13.180 +    return WRun(argc, argv, &createPairCoresApp);
  13.181 +}
  13.182 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/pair_cores/web/run.sh	Mon Mar 19 13:52:56 2012 +0400
    14.3 @@ -0,0 +1,3 @@
    14.4 +cd approot && ../pair-cores.wt --docroot ../docroot/ \
    14.5 +    --http-port 56929 --http-address 127.0.0.1
    14.6 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/utils/markup_to_html.html	Mon Mar 19 13:52:56 2012 +0400
    15.3 @@ -0,0 +1,37 @@
    15.4 +<html>
    15.5 +	<head>
    15.6 +		<title>Alignment with markup</title>
    15.7 +		<style>
    15.8 +			* { font-family: fixed; font-size: 8pt; }
    15.9 +			.code1 { display: block; font-size: 12pt; width: 2em; }
   15.10 +			.code3 { display: none; }
   15.11 +			.number { display: none; }
   15.12 +			.popup { display: none; background: #ffc; padding: .2em; border: solid thin black; white-space: nowrap; }
   15.13 +			span.code1:hover { background: #fcc; }
   15.14 +			span.code1:hover .popup { display: block; position: absolute; margin-left: 1em; }
   15.15 +		</style>
   15.16 +	</head>
   15.17 +	<body>
   15.18 +		<table>
   15.19 +			{% for row in rows %}
   15.20 +			<tr>
   15.21 +				{% for monomer in row %}
   15.22 +				<td>
   15.23 +					{% if monomer %}
   15.24 +					<span class='code1'>{{ monomer.code1 }}
   15.25 +						<div class='popup'>{{ monomer.description.replace("\n", "<br>") }}</div>
   15.26 +					</span>
   15.27 +					<span class='code3'>{{ monomer.code3 }}</span>
   15.28 +					{% for name, markup in row.sequence.markups.items() %}
   15.29 +					<span class='{{ name }}'>{{ markup.get(monomer, "") }}</span>
   15.30 +					{% endfor %}
   15.31 +					{% else %}
   15.32 +					<span class='code1'>-</span>
   15.33 +					{% endif %}
   15.34 +				</td>
   15.35 +				{% endfor %}
   15.36 +			</tr>
   15.37 +			{% endfor %}
   15.38 +		</table>
   15.39 +	</body>
   15.40 +</html>
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/utils/markup_to_html.py	Mon Mar 19 13:52:56 2012 +0400
    16.3 @@ -0,0 +1,48 @@
    16.4 +#!/usr/bin/python
    16.5 +"""Represent markup as HTML file.
    16.6 +
    16.7 +Input defaults to stdin.
    16.8 +"""
    16.9 +import sys
   16.10 +import optparse
   16.11 +from os.path import dirname, join
   16.12 +from allpy import protein
   16.13 +from jinja2 import Template
   16.14 +
   16.15 +template_prefix = dirname(sys.modules[__name__].__file__)
   16.16 +template_file = join(template_prefix, "markup_to_html.html")
   16.17 +
   16.18 +parser = optparse.OptionParser(description=__doc__, usage="%prog [options] [infile]")
   16.19 +parser.add_option("-o", "--outfile",
   16.20 +	help="Output file name, default: stdout")
   16.21 +parser.add_option("-m", "--import-module",
   16.22 +	help="Import this module before anything, useful for custom markup classes")
   16.23 +options, args = parser.parse_args()
   16.24 +
   16.25 +outfile = options.outfile and open(options.outfile, "w") or sys.stdout
   16.26 +infile = len(args) == 1 and open(args[0]) or sys.stdin
   16.27 +if len(args) > 1:
   16.28 +	parser.error("Too many arguments on the command line")
   16.29 +
   16.30 +if options.import_module:
   16.31 +	sys.path.append(".")
   16.32 +	__import__(options.import_module)
   16.33 +
   16.34 +aln = protein.Alignment().append_file(infile, format="markup")
   16.35 +
   16.36 +def repr_items(items):
   16.37 +	return ["{0}: {1}".format(k, v) for k, v in sorted(items)]
   16.38 +
   16.39 +for sequence in aln.sequences:
   16.40 +	sequence.add_markup('number')
   16.41 +	for monomer in sequence:
   16.42 +		items = repr_items((k,v) for k, v in vars(monomer).items() if k != 'input_code1')
   16.43 +		items += [""]
   16.44 +		items += repr_items([('code3', monomer.code3), ('name', monomer.name)])
   16.45 +		items += [""]
   16.46 +		items += repr_items([('sequence ' + k, v) for k, v in vars(sequence).items() if k != 'markups'])
   16.47 +		monomer.description = "\n".join(items)
   16.48 +
   16.49 +rows = aln.rows_as_lists()
   16.50 +template = Template(open(template_file).read())
   16.51 +outfile.write(template.render(vars()))