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

allpy

changeset 129:a6d287f9c901

broken: lib::block::geometrical_cores returns list of blocks added new parameters to geometrical_core test passed
author boris <bnagaev@gmail.com>
date Sun, 24 Oct 2010 00:26:18 +0400
parents 3e69e4b38017
children 89de20cda19c
files lib/block.py lib/config.py test/test.py
diffstat 3 files changed, 32 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/lib/block.py	Sun Oct 24 00:02:24 2010 +0400
     1.2 +++ b/lib/block.py	Sun Oct 24 00:26:18 2010 +0400
     1.3 @@ -7,6 +7,7 @@
     1.4  import monomer
     1.5  import config
     1.6  from graph import Graph
     1.7 +from copy import copy
     1.8  
     1.9  class Block(object):
    1.10      """
    1.11 @@ -59,11 +60,20 @@
    1.12                  out_file.write("%s \n" % string)
    1.13      
    1.14      def geometrical_cores(self, max_delta=config.delta, 
    1.15 -    timeout=config.timeout, minsize=config.minsize):
    1.16 +    timeout=config.timeout, minsize=config.minsize, 
    1.17 +    ac_new_atoms=config.ac_new_atoms,
    1.18 +    ac_count=config.ac_count):
    1.19          """
    1.20 -        returns length-sorted list of GCs (GC -- frozenset of positions)
    1.21 +        returns length-sorted list of blocks, representing GCs
    1.22          
    1.23 -        delta -- threshold of distance spreading
    1.24 +        max_delta -- threshold of distance spreading
    1.25 +        timeout -- Bron-Kerbosh timeout (then fast O(n ln n) algorithm)
    1.26 +        minsize -- min size of each core
    1.27 +        ac_new_atoms -- min part or new atoms in new alternative core
    1.28 +            current GC is compared with each of already selected GCs
    1.29 +            if difference is less then ac_new_atoms, current GC is skipped
    1.30 +            difference = part of new atoms in current core
    1.31 +        ac_count -- max number of cores (including main core)
    1.32          
    1.33          If more than one pdb chain for some sequence provided, consider all of them
    1.34          cost is calculated as 1 / (delta + 1) 
    1.35 @@ -89,7 +99,17 @@
    1.36                          if delta <= max_delta:
    1.37                              lines[Graph.line(i, j)] = 1.0 / (1.0 + max_delta)
    1.38          graph = Graph(nodes, lines)
    1.39 -        return graph.cliques(timeout=timeout, minsize=minsize)
    1.40 +        cliques = graph.cliques(timeout=timeout, minsize=minsize)
    1.41 +        GCs = []
    1.42 +        for clique in cliques:
    1.43 +            for GC in GCs:
    1.44 +                if len(clique - set(GC.positions)) < ac_new_atoms * len(clique):
    1.45 +                    break
    1.46 +            else:
    1.47 +                GCs.append(Block(self.project, copy(self.sequences), clique))
    1.48 +                if len(GCs) >= ac_count:
    1.49 +                    break
    1.50 +        return GCs
    1.51      
    1.52      def xstring(self, x='X'):
    1.53          """
     2.1 --- a/lib/config.py	Sun Oct 24 00:02:24 2010 +0400
     2.2 +++ b/lib/config.py	Sun Oct 24 00:26:18 2010 +0400
     2.3 @@ -8,3 +8,10 @@
     2.4  timeout = 10 # time in sec. for BRON-KERBOSH algorithm
     2.5  
     2.6  
     2.7 +# min part or new atoms in new alternative core
     2.8 +ac_new_atoms = 0.5
     2.9 +
    2.10 +# max number of cores (including main core)
    2.11 +ac_count = 5
    2.12 +
    2.13 +
     3.1 --- a/test/test.py	Sun Oct 24 00:02:24 2010 +0400
     3.2 +++ b/test/test.py	Sun Oct 24 00:26:18 2010 +0400
     3.3 @@ -14,8 +14,7 @@
     3.4  GCs = b.geometrical_cores()
     3.5  GC = GCs[0]
     3.6  b.save_fasta(sys.stdout)
     3.7 -gc_block = Block(p, positions=GC)
     3.8 -print gc_block.xstring()
     3.9 +print GC.xstring()
    3.10  
    3.11  
    3.12  #~ p.muscle_align()