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

Go to the SVN repository for this file.

1 /* $Id: thrdcprl.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: thrdcprl.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 #include <stdlib.h>
42 
43 /* Count and/or list largest possible sets of contact indices by segment. */
44 /* The flag ct specifies whether contacts should only be counted, or whether */
45 /* their indices should be stored. The former option is used to determine */
46 /* the required memory allocation. */
47 
48 /* Organize residue-residue contacts as a list of paired indices, with an */
49 /* associated distance interval. Organize residue peptide contacts as a */
50 /* similar list. Organize residue-fixed environment contacts as a list of */
51 /* indices and types. */
52 
53 /*int*/ void cprl(Fld_Mtf* mtf, Cor_Def* cdf, Rcx_Ptl* pmf, Cxl_Los** cpr, int ct) {
54 /*--------------------------------------------------------*/
55 /* mtf: Contact matrices defining the folding motif */
56 /* cdf: contains min/max segment locations */
57 /* pmf: Potential of mean force as a 3-d lookup table */
58 /* cpr: indices of contacts by seg, largest possible set */
59 /* ct: If 0, count contacts but do not assign indices */
60 /*--------------------------------------------------------*/
61 
62 int ppi; /* Index of peptide group in contact potential */
63 int nmt; /* Number of motif residue positions */
64 int nsc; /* Number of threaded core segments */
65 int nfs; /* Number of fixed core segments */
66 int *cs; /* Flag for core residue positions */
67 int *fs; /* Flag for fixed residue positions */
68 int i,j; /* Counters */
69 int mn,mx; /* Ranges */
70 int r1,r2,d; /* Motif residue positions */
71 int s1,s2; /* Core segment indices */
72 int f1,f2; /* Fixed segment residue positions */
73 int t2; /* Fixed segment residue type */
74 Cxl_Los *cp; /* Pointer to segment contact lists */
75 
76 
77 /* Parameters */
78 
79 nsc=cdf->sll.n;
80 nfs=cdf->fll.n;
81 nmt=mtf->n;
82 ppi=pmf->ppi;
83 
84 /*
85 printf("nsc %d\n",nsc);
86 printf("nfs %d\n",nfs);
87 printf("nmt %d\n",nmt);
88 printf("ppi %d\n",ppi);
89 */
90 
91 
92 /* Local storage for identifying residue positions by segment */
93 
94 cs=(int *)calloc(nmt,sizeof(int));
95 fs=(int *)calloc(nmt,sizeof(int));
96 
97 
98 /* Zero contact counts */
99 
100 for(i=0; i<nsc; i++) { cp=cpr[i]; cp->rr.n=0; cp->rp.n=0; cp->rf.n=0; }
101 
102 /*
103 for(i=0; i<nsc; i++) {
104  cp=cpr[i];
105  printf("rr:%d rp:%d rf:%d cpr[%d]\n",cp->rr.n,cp->rp.n,cp->rf.n,i); }
106 */
107 
108 /* Flag residue positions by core segment, at segments maximum extent */
109 
110 for(i=0; i<nmt; i++) cs[i]=-1;
111 for(i=0; i<nsc; i++) {
112  mn=cdf->sll.rfpt[i]-cdf->sll.nomx[i];
113  mx=cdf->sll.rfpt[i]+cdf->sll.comx[i];
114  for(j=mn; j<=mx; j++) cs[j]=i; }
115 
116 /* for(i=0; i<nmt; i++) printf("%d ",cs[i]); printf("cs\n"); */
117 
118 
119 /* Count and/or copy residue-residue contacts to by-segment contact lists. */
120 
121 for(i=0; i<mtf->rrc.n; i++) {
122  r1=mtf->rrc.r1[i];
123  s1=cs[r1];
124  if(s1<0) continue;
125  r2=mtf->rrc.r2[i];
126  s2=cs[r2];
127  if(s2<0) continue;
128  d=mtf->rrc.d[i];
129  cp=cpr[s1];
130  cp->rr.n++;
131  if(ct!=0) { j=cp->rr.n-1;
132  cp->rr.r1[j]=r1;
133  cp->rr.r2[j]=r2;
134  cp->rr.d[j]=d; }
135 
136  if(s1==s2) continue;
137 
138  cp=cpr[s2];
139  cp->rr.n++;
140  if(ct!=0) { j=cp->rr.n-1;
141  cp->rr.r1[j]=r1;
142  cp->rr.r2[j]=r2;
143  cp->rr.d[j]=d; } }
144 
145 /*
146 for(i=0; i<nsc; i++) {
147  cp=cpr[i];
148  printf("rr:%d rp:%d rf:%d cpr[%d]\n",cp->rr.n,cp->rp.n,cp->rf.n,i);
149  if(ct!=0) for(j=0; j<cp->rr.n; j++) {
150  printf("%d %d %d\n",cp->rr.r1[j],cp->rr.r2[j],cp->rr.d[j]); } }
151 */
152 
153 /* Count and/or copy residue-peptide contacts to by segment contact lists. */
154 
155 for(i=0; i<mtf->rpc.n; i++) {
156  r1=mtf->rpc.r1[i];
157  s1=cs[r1];
158  if(s1<0) continue;
159  r2=mtf->rpc.p2[i];
160  s2=cs[r2];
161  if(s2<0) continue;
162  d=mtf->rpc.d[i];
163  cp=cpr[s1];
164  cp->rp.n++;
165  if(ct!=0) { j=cp->rp.n-1;
166  cp->rp.r1[j]=r1;
167  cp->rp.p2[j]=r2;
168  cp->rp.d[j]=d; }
169 
170  if(s1==s2) continue;
171 
172  cp=cpr[s2];
173  cp->rp.n++;
174  if(ct!=0) { j=cp->rp.n-1;
175  cp->rp.r1[j]=r1;
176  cp->rp.p2[j]=r2;
177  cp->rp.d[j]=d; } }
178 
179 /*
180 for(i=0; i<nsc; i++) {
181  cp=cpr[i];
182  printf("rr:%d rp:%d rf:%d cpr[%d]\n",cp->rr.n,cp->rp.n,cp->rf.n,i);
183  if(ct!=0) for(j=0; j<cp->rp.n; j++) {
184  printf("%d %d %d\n",cp->rp.r1[j],cp->rp.p2[j],cp->rp.d[j]); } }
185 */
186 
187 /* Flag residue positions within fixed segments */
188 
189 for(i=0; i<nmt; i++) fs[i]=-1;
190 for(i=0; i<nfs; i++) {
191  mn=cdf->fll.nt[i];
192  mx=cdf->fll.ct[i];
193  for(j=mn; j<=mx; j++) fs[j]=j; }
194 
195 /* for(i=0; i<nmt; i++) printf("%d ",fs[i]); printf("fs\n"); */
196 
197 /* Count and/or copy residue-fixed contacts to by segment contact lists. */
198 
199 for(i=0; i<mtf->rrc.n; i++) {
200  r1=mtf->rrc.r1[i];
201  s1=cs[r1]; f1=fs[r1];
202  if(s1<0&&f1<0) continue;
203  r2=mtf->rrc.r2[i];
204  s2=cs[r2]; f2=fs[r2];
205  if(s2<0&&f2<0) continue;
206 
207  if(f1<0&&f2<0) continue;
208  if(f1>0&&f2>0) continue;
209 
210  if(s2>0&&f1>0) { s1=s2; r1=r2; f2=f1; }
211 
212  d=mtf->rrc.d[i];
213  cp=cpr[s1];
214  t2=cdf->fll.sq[f2];
215  if(t2<0) continue;
216  cp->rf.n++;
217  if(ct!=0) { j=cp->rf.n-1;
218  cp->rf.r1[j]=r1;
219  cp->rf.t2[j]=t2;
220  cp->rf.d[j]=d; } }
221 
222 for(i=0; i<mtf->rpc.n; i++) {
223  r1=mtf->rpc.r1[i];
224  s1=cs[r1];
225  if(s1<0) continue;
226  r2=mtf->rpc.p2[i];
227  f2=fs[r2];
228  if(f2<0) continue;
229 
230  d=mtf->rpc.d[i];
231  cp=cpr[s1];
232  cp->rf.n++;
233  if(ct!=0) { j=cp->rf.n-1;
234  cp->rf.r1[j]=r1;
235  cp->rf.t2[j]=ppi;
236  cp->rf.d[j]=d; } }
237 
238 
239 /*
240 for(i=0; i<nsc; i++) {
241  cp=cpr[i];
242  printf("rr:%d rp:%d rf:%d cpr[%d]\n",cp->rr.n,cp->rp.n,cp->rf.n,i);
243  if(ct!=0) for(j=0; j<cp->rf.n; j++) {
244  printf("%d %d %d\n",cp->rf.r1[j],cp->rf.t2[j],cp->rf.d[j]); } }
245 
246 */
247 
248 /* Free local storage */
249 
250 free(fs);
251 free(cs);
252 
253 }
int i
static const sljit_gpr r1
static const sljit_gpr r2
int * ct
Definition: thrdatd.h:84
struct _Cor_Def::@23 sll
int * nt
Definition: thrdatd.h:83
int * sq
Definition: thrdatd.h:85
int * nomx
Definition: thrdatd.h:71
struct _Cor_Def::@25 fll
int * rfpt
Definition: thrdatd.h:69
int * comx
Definition: thrdatd.h:73
int n
Definition: thrdatd.h:74
int * r2
Definition: thrdatd.h:276
int n
Definition: thrdatd.h:279
struct _Cxl_Los::@29 rr
struct _Cxl_Los::@30 rp
int * p2
Definition: thrdatd.h:283
int * r1
Definition: thrdatd.h:275
int * t2
Definition: thrdatd.h:290
struct _Cxl_Los::@31 rf
int * d
Definition: thrdatd.h:277
int * d
Definition: thrdatd.h:54
int * p2
Definition: thrdatd.h:59
struct _Fld_Mtf::@21 rrc
int n
Definition: thrdatd.h:50
int * r1
Definition: thrdatd.h:52
struct _Fld_Mtf::@22 rpc
int * r2
Definition: thrdatd.h:53
int ppi
Definition: thrdatd.h:108
void cprl(Fld_Mtf *mtf, Cor_Def *cdf, Rcx_Ptl *pmf, Cxl_Los **cpr, int ct)
Definition: thrdcprl.c:53
void free(voidpf ptr)
voidp calloc(uInt items, uInt size)
Modified on Fri Sep 20 14:57:51 2024 by modify_doxy.py rev. 669887