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

Go to the SVN repository for this file.

1 /* $Id: thrdspci.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: thrdspci.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 
42 /* Sum residue type counts for the n-th core segment and for loops adjacent */
43 /* it. Use these sums to recompute total threaded sequence composition. For */
44 /* loops, include their residues in the composition sum only if their length */
45 /* is less than the maximum reference state length specified in the core */
46 /* definition. For loops at the terminii, include either this maximum number */
47 /* of residues or the total length of the assigned sequence segment, */
48 /* whichever is less. Return 1 if the composition has changed since the */
49 /* previous call and 0 if it has not. */
50 
51 int spci(Cor_Def* cdf, Qry_Seq* qsq, Cur_Loc* sli, Cur_Aln* sai, int n, Seg_Cmp* spc) {
52 /*--------------------------------------------------------*/
53 /* cdf: Core segment locations and loop length limits */
54 /* qsq: Sequence to thread with alignment contraints */
55 /* sli: Current locations of core segments in the motif */
56 /* sai: Current alignment of query sequence with core */
57 /* n: Update composition for this core segment only */
58 /* spc: Residue type composition of current threaded seq */
59 /*--------------------------------------------------------*/
60 
61 int nsc; /* Number of core segments */
62 int nlp; /* Number of loops */
63 int nrt; /* Number of residue types in potential */
64 int nqi; /* Number of residues in query sequence */
65 int i,j; /* Counters */
66 int r; /* Residue type */
67 int nt,ct; /* Core segment or loop terminii */
68 int *rtn; /* Pointer to residue type counts */
69 int lm; /* Maximum loop length to include in counts */
70 
71 nsc=spc->nsc;
72 nrt=spc->nrt;
73 nlp=spc->nlp;
74 nqi=qsq->n;
75 
76 /* Assign core segment composition from previous thread */
77 
78 for(i=0; i<nrt; i++) spc->rto[i]=spc->rt[i];
79 /* for(i=0;i<nrt;i++) printf("%d ",spc->rto[i]); printf(":spc->rto[%d]\n",n); */
80 
81 /* Assign current core segment composition */
82 
83 rtn=spc->srt[n]; for(r=0;r<nrt;r++) rtn[r]=0;
84 nt=sai->al[n]-sli->no[n];
85 ct=sai->al[n]+sli->co[n];
86 /* printf("nt:%d ct:%d\n",nt,ct); */
87 for(i=nt;i<=ct;i++) {
88  r=qsq->sq[i];
89  if(r<0) continue;
90  /* printf("i:%d r:%d\n",i,r); */
91  rtn[r]++; }
92 /* for(i=0;i<nrt;i++) printf("%d ",rtn[i]); printf(":spc->srt[%d]\n",n); */
93 
94 /* Assign n-terminal loop composition */
95 
96 lm=cdf->lll.lrfs[n];
97 if(lm>0) {
98  rtn=spc->lrt[n];
99  for(r=0;r<nrt;r++) rtn[r]=0;
100  if(n==0) {
101  ct=sai->al[0]-sli->no[0]-1;
102  nt=ct-lm+1;
103  nt=(nt<0) ? 0 : nt;
104  /* printf("nt:%d ct:%d\n",nt,ct); */
105  for(i=nt;i<=ct;i++) {
106  r=qsq->sq[i];
107  if(r<0) continue;
108  /* printf("i:%d r:%d\n",i,r); */
109  rtn[r]++; } }
110  else {
111  ct=sai->al[n]-sli->no[n]-1;
112  nt=sai->al[n-1]+sli->co[n-1]+1;
113  if((ct-nt)<lm ) {
114  /* printf("nt:%d ct:%d\n",nt,ct); */
115  for(i=nt;i<=ct;i++) {
116  r=qsq->sq[i];
117  if(r<0) continue;
118  /* printf("i:%d r:%d\n",i,r); */
119  rtn[r]++; } } } }
120 
121 /* for(i=0;i<nrt;i++) printf("%d ",spc->lrt[n][i]);
122 printf(":spc->lrt[%d]\n",n); */
123 
124 
125 /* Assign c-terminal loop composition */
126 
127 lm=cdf->lll.lrfs[n+1];
128 if(lm>0) {
129  rtn=spc->lrt[n+1];
130  for(r=0;r<nrt;r++) rtn[r]=0;
131  if((n+1)==nsc) {
132  nt=sai->al[n]+sli->co[n]+1;
133  ct=nt+lm-1;
134  ct=(ct>=nqi) ? nqi-1 : ct;
135  /* printf("nt:%d ct:%d\n",nt,ct); */
136  for(i=nt;i<=ct;i++) {
137  r=qsq->sq[i];
138  if(r<0) continue;
139  /* printf("i:%d r:%d\n",i,r); */
140  rtn[r]++; } }
141  else {
142  nt=sai->al[n]+sli->co[n]+1;
143  ct=sai->al[n+1]-sli->no[n+1]-1;
144  if((ct-nt)<lm ) {
145  /* printf("nt:%d ct:%d\n",nt,ct); */
146  for(i=nt;i<=ct;i++) {
147  r=qsq->sq[i];
148  if(r<0) continue;
149  /* printf("i:%d r:%d\n",i,r); */
150  rtn[r]++; } } } }
151 
152 /* for(i=0;i<nrt;i++) printf("%d ",spc->lrt[n+1][i]);
153 printf(":spc->lrt[%d]\n",n+1); */
154 
155 
156 /* Assign composition, or total residue type counts */
157 
158 for(r=0;r<nrt;r++) spc->rt[r]=0;
159 
160 /* for(i=0; i<nrt; i++) printf("%d ",spc->rt[i]); printf("spc->rt\n");
161 for(j=0; j<nsc; j++) {
162  for(i=0;i<nrt;i++) printf("%d ",spc->srt[j][i]);
163  printf("spc->srt[%d]\n",j); }
164 for(j=0; j<nlp; j++) {
165  for(i=0;i<nrt;i++) printf("%d ",spc->lrt[j][i]);
166  printf("spc->lrt[%d]\n",j); } */
167 
168 for(i=0;i<nsc;i++) {
169  rtn=spc->srt[i]; for(r=0;r<nrt;r++) spc->rt[r] += rtn[r]; }
170 for(i=0;i<nlp;i++) {
171  rtn=spc->lrt[i]; for(r=0;r<nrt;r++) spc->rt[r] += rtn[r]; }
172 
173 /* for(i=0; i<nrt; i++) printf("%d ",spc->rt[i]); printf("spc->rt\n"); */
174 
175 
176 /* If composition has not changed from the previous thread return 0 */
177 
178 j=0; for(i=0; i<nrt; i++) if(spc->rt[i]!=spc->rto[i]) { j=1; break; }
179 return(j);
180 
181 }
int i
yy_size_t n
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
int * lrfs
Definition: thrdatd.h:79
struct _Cor_Def::@24 lll
int * al
Definition: thrdatd.h:190
int * no
Definition: thrdatd.h:179
int * co
Definition: thrdatd.h:180
int * sq
Definition: thrdatd.h:92
int n
Definition: thrdatd.h:93
int * rt
Definition: thrdatd.h:219
int nsc
Definition: thrdatd.h:215
int nlp
Definition: thrdatd.h:218
int nrt
Definition: thrdatd.h:216
int ** lrt
Definition: thrdatd.h:217
int * rto
Definition: thrdatd.h:220
int ** srt
Definition: thrdatd.h:214
int spci(Cor_Def *cdf, Qry_Seq *qsq, Cur_Loc *sli, Cur_Aln *sai, int n, Seg_Cmp *spc)
Definition: thrdspci.c:51
Modified on Sat Mar 02 10:54:05 2024 by modify_doxy.py rev. 669887