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

Go to the SVN repository for this file.

1 /* $Id: thrdsgoi.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: thrdsgoi.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 
39 /* Set core segment sampling order */
40 
43 
44 /*int*/ void sgoi(int is, int it, Rnd_Smp* pvl, Seg_Ord* sgo) {
45 /*----------------------------------------------------*/
46 /* is: Code to determine order of segment sampling */
47 /* it: Code to determine order of terminus sampling */
48 /* pvl: Storage for segment location probabilities */
49 /* sgo: Segment samping order */
50 /*----------------------------------------------------*/
51 
52 int nsc; /* Number of threaded core segments */
53 int i,j,k; /* Counters */
54 int *si; /* Segment index by order of sampling */
55 int *so; /* Flags segments already assigned an order */
56 int *to; /* Order of terminus sampling, 0=Nterm, 1=Cterm. */
57 float pv; /* P value */
58 
59 
60 /* Number of core segments */
61 nsc=sgo->nsc;
62 
63 /* Initialize alignment order arrays */
64 si=sgo->si;
65 so=sgo->so;
66 for(i=0; i<nsc; i++) so[i]=1;
67 to=sgo->to;
68 
69 /* Determine the order of core segment alignment */
70 /* printf("is:%d\n",is); */
71 switch(is) {
72 
73  default: { /* Order randomly */
74  /* printf("segment order by default random method\n"); */
75  pvl->n=nsc;
76  for(i=0; i<nsc; i++) {
77  pv= 1.0f /(nsc-i);
78  for(j=0; j<nsc; j++) {
79  if(so[j]==1) pvl->p[j]=pv;
80  else pvl->p[j]=0.; }
81  k=rsmp(pvl); so[k]=0; si[i]=k; }
82  break; }
83 
84  case 1: { /* Order by occurrence in the core definition */
85 
86  /* printf("segment order by occurrence, case 1\n"); */
87  for(i=0; i<nsc; i++) si[i]=i; break; }
88 
89  }
90 
91 
92 /* Select the terminus to sample first, using the specified method */
93 /* printf("it:%d\n",it); */
94 switch(it) {
95 
96  default: { /* Choose n- or c-terminus at random */
97  /* printf("terminus order by default random method\n");*/
98  for(i=0; i<nsc; i++) {
99  pvl->n=2; pvl->p[0]=.5; pvl->p[1]=.5;
100  to[i]=rsmp(pvl); } break; }
101 
102  case 1: { /* N-terminus first */
103  /* printf("segment order n-terminus first, case 1\n"); */
104  for(i=0; i<nsc; i++) to[i]=0; break; }
105 
106  case 2: { /* C-terminus first */
107  /* printf("segment order c-terminus first, case 2\n"); */
108  for(i=0; i<nsc; i++) to[i]=1; break; }
109 
110  }
111 
112 }
static const char si[8][64]
Definition: des.c:146
int i
float * p
Definition: thrdatd.h:308
int n
Definition: thrdatd.h:307
int nsc
Definition: thrdatd.h:302
int * si
Definition: thrdatd.h:299
int * to
Definition: thrdatd.h:301
int * so
Definition: thrdatd.h:300
int rsmp(Rnd_Smp *pvl)
Definition: thrdrsmp.c:48
void sgoi(int is, int it, Rnd_Smp *pvl, Seg_Ord *sgo)
Definition: thrdsgoi.c:44
Modified on Thu May 02 14:31:20 2024 by modify_doxy.py rev. 669887