NCBI C++ ToolKit
thrdbwfi.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: thrdbwfi.c 32839 2007-03-05 20:41:55Z kazimird $
2 *===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: thrdbwfi.c
27 *
28 * Author: Stephen Bryant
29 *
30 * Initial Version Creation Date: 08/16/2000
31 *
32 * $Revision: 32839 $
33 *
34 * File Description: threader
35 */
36 
37 
38 
41 #include <math.h>
42 
43 /*float*/ void bwfi(Thd_Tbl* ttb, Gib_Scd* gsp, Thd_Tst* tts) {
44 /*---------------------------------------------------------*/
45 /* ttb: Table holding results of Gibbs sampled threading */
46 /* gsp: Various control parameters for Gibb's sampling */
47 /* tts: Pameters for local min and convergence tests */
48 /*---------------------------------------------------------*/
49 
50 int i; /* Counter */
51 int ct; /* Index of current thread in list traversal */
52 int nz=0; /* Number of threads with non-zero Boltzmann weight */
53 int nt=0; /* Number of threads within specified ensemble cutoff */
54 float tm; /* Temperature for calculation of Boltzmann weight */
55 float gm; /* Minimum energy value for scaling of exponents */
56 float g; /* Energy value */
57 float b; /* Boltzmann exponent exponents */
58 float sb; /* Sum of Boltzmann exponents */
59 float cw; /* Cumulative sum of Boltzmann factors */
60 
61 
62 /* Identify the top threads of the current ensemble */
63 
64 /* Calculate and sum Boltzmann exponents*/
65 gm=ttb->tg[ttb->mx]; tm=(float)gsp->cet;
66 sb=0.; ct=ttb->mx; for(i=0; i<ttb->n; i++) {
67  if(ttb->tf[ct]==0) {nz=i; break;}
68  g=ttb->tg[ct]-gm;
69  b=(float) exp(g/tm);
70  tts->bw[ct]=b;
71  sb+=b;
72  /* printf("gm:%.2f sb:%.5f i:%d ct:%d g:%.2f b:%.5f\n",
73  gm,sb,i,ct,ttb->tg[ct],b); */
74  if(b<NERZRO) {nz=i; break;}
75  ct=ttb->nx[ct];}
76 
77 /* Cumulate Boltzmann weights to identify top threads */
78 cw=0.; ct=ttb->mx; for(i=0; i<=nz; i++) {
79  b=tts->bw[ct]/sb;
80  tts->bw[ct]=b;
81  cw+=b;
82  /* printf("gm:%.2f sb:%.5f i:%d ct:%d g:%.2f b:%.5f cw:%.5f\n",
83  gm,sb,i,ct,ttb->tg[ct],b,cw); */
84  if(cw>((float)gsp->cef)/100.) {nt=i; break;}
85  ct=ttb->nx[ct];}
86 
87 
88 /* Find the highest random-start count and frequecy for any top thread */
89 
90 tts->ts=-1; tts->tf=-1;
91 ct=ttb->mx; for(i=0; i<=nt; i++) {
92  if(ttb->ts[ct]>tts->ts) {
93  tts->ts=ttb->ts[ct];
94  tts->tf=ttb->tf[ct]; }
95  else if(ttb->ts[ct]==tts->ts && ttb->tf[ct]>tts->tf)
96  tts->tf=ttb->tf[ct];
97  /* printf("ensi:%d ct:%d dgi:%.1f bfi:%.4f tsi:%d ts:%d
98  tfi: %d tf:%d\n",
99  i,ct,ttb->tg[ct],tts->bw[ct],ttb->ts[ct],tts->ts,
100  ttb->tf[ct],tts->tf); */
101  ct=ttb->nx[ct];}
102 
103 }
int i
yy_size_t n
int cet
Definition: thrdatd.h:119
int cef
Definition: thrdatd.h:120
int * tf
Definition: thrdatd.h:149
int * ts
Definition: thrdatd.h:150
int * nx
Definition: thrdatd.h:156
float * tg
Definition: thrdatd.h:139
int mx
Definition: thrdatd.h:157
float * bw
Definition: thrdatd.h:165
int ts
Definition: thrdatd.h:172
int tf
Definition: thrdatd.h:171
#define NERZRO
Definition: thrdatd.h:330
void bwfi(Thd_Tbl *ttb, Gib_Scd *gsp, Thd_Tst *tts)
Definition: thrdbwfi.c:43
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
Definition: thrddgri.c:44
Modified on Fri Sep 20 14:58:23 2024 by modify_doxy.py rev. 669887