1 /* $Id: thrdcpll.c,v 1.2 2006/07/13 17:07:27 bollin Exp $
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: thrdcpll.c
27 *
28 * Author: Stephen Bryant
29 *
30 * Initial Version Creation Date: 08/16/2000
31 *
32 * $Revision: 1.2 $
33 *
34 * File Description: threader
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * $Log: thrdcpll.c,v $
39 * Revision 1.2 2006/07/13 17:07:27 bollin
40 * removed unused variables
41 *
42 * Revision 1.1 2000/08/16 20:45:21 hurwitz
43 * initial check in of threading routines
44 *
45 * ==========================================================================
46 */
47
48
49
50 #include <thrdatd.h>
51 #include <thrddecl.h>
52
53 /* Given the current alignment, construct by-segment contact lists for */
54 /* location sampling. These lists contain the same information as the */
55 /* largest-extent or reference contact lists, but some contacts may be */
56 /* omitted, if loop length limits or sequence length constrain the possible */
57 /* n- or c-terminal offsets of a segment. They contain pointers to the */
58 /* energies of each contact, as well as distance intervals. */
59
cpll(Cor_Def * cdf,Rcx_Ptl * pmf,Qry_Seq * qsq,Cxl_Los ** cpr,Cur_Aln * sai,Cxl_Los ** cpl)60 int cpll(Cor_Def* cdf, Rcx_Ptl* pmf, Qry_Seq* qsq, Cxl_Los** cpr,
61 Cur_Aln* sai, Cxl_Los** cpl) {
62 /*-----------------------------------------------------*/
63 /* cdf: Core segment locations and loop length limits */
64 /* pmf: Potential of mean force as a 3-d lookup table */
65 /* qsq: Sequence to thread with alignment contraints */
66 /* cpr: Contacts by segment, largest possible set */
67 /* sai: Current alignment of query sequence with core */
68 /* cpl: Contacts by segment, given current alignment */
69 /*-----------------------------------------------------*/
70
71 int nmt; /* Number of motif residue positions */
72 int nsc; /* Number of threaded core segments */
73 int ppi; /* Index of peptide group in potential */
74 int nrt; /* Number of residue types */
75 int nqi; /* Number of residues in query sequence */
76 int i,j,k; /* Counters */
77 int t1,t2; /* Motif residue types */
78 int r1,r2; /* Motif residue positions */
79 int s1,s2; /* Core segment indices */
80 int d; /* Distance inteva */
81 Cxl_Los *cr; /* Pointer to segment reference contact lists */
82 Cxl_Los *cl; /* Pointer to segment location sampling contact lists */
83 int *cf; /* Flags residues possibly within the core. */
84 int le; /* Explicit limit on segment extent, query index */
85 int la; /* Alignment-derived limit on segment extent */
86 int mn,mx; /* Range */
87
88 /* Parameters */
89
90 nsc=sai->nsc;
91 nmt=sai->nmt;
92 ppi=pmf->ppi;
93 nrt=pmf->nrt;
94 nqi=qsq->n;
95
96
97 /* printf("nsc %d\n",nsc);
98 printf("nmt %d\n",nmt);
99 printf("ppi %d\n",ppi);
100 printf("nrt %d\n",nrt);
101 printf("nqi %d\n",nqi); */
102
103
104
105 /* Flag residues which may fall in the core, given the current alignment */
106
107 cf=sai->cf;
108 for(i=0;i<nmt;i++) cf[i]=(-1);
109 /* for(i=0; i<nmt; i++) printf("%d ",cf[i]); printf("cf\n"); */
110
111 for(i=0; i<nsc; i++) {
112
113 /* Identify maximum n-terminal extent of this segment */
114 le=sai->al[i]-cdf->sll.nomx[i];
115 la=(i==0) ? cdf->lll.llmn[0]:
116 sai->al[i-1]+cdf->sll.comn[i-1]+cdf->lll.llmn[i]+1;
117 /* printf("nt-le:%d nt-la:%d\n",le,la); */
118 le=(la>le) ? la : le;
119 mn=cdf->sll.rfpt[i]-(sai->al[i]-le);
120 /* printf("nt-le:%d nt-mn:%d\n",le,mn); */
121
122 /* Identify maximum c-terminal extent of this segment */
123 le=sai->al[i]+cdf->sll.comx[i];
124 la=(i==(nsc-1)) ? nqi-1-cdf->lll.llmn[nsc]:
125 sai->al[i+1]-cdf->sll.nomn[i+1]-cdf->lll.llmn[i+1]-1;
126 /* printf("ct-le:%d ct-la:%d\n",le,la); */
127 le=(la<le) ? la : le;
128 mx=cdf->sll.rfpt[i]+(le-sai->al[i]);
129 /* printf("ct-le:%d ct-mx:%d\n",le,mx); */
130
131 /* Flag possible core residues */
132 /* printf("mn:%d mx:%d\n",mn,mx); */
133 for(j=mn; j<=mx; j++) cf[j]=i; }
134
135 /* for(i=0; i<nmt; i++) printf("%d ",cf[i]); printf("cf\n"); */
136
137
138 /* Zero pair counts */
139
140 for(i=0; i<nsc; i++) { cl=cpl[i]; cl->rr.n=0; cl->rp.n=0; cl->rf.n=0;}
141
142
143 /* Loop over core segments */
144
145 for(i=0; i<nsc; i++ ) {
146 cl=cpl[i];
147 cr=cpr[i];
148
149 /* Loop over residue-residue contacts in the reference list */
150
151 for(j=0; j<cr->rr.n; j++) {
152
153 /* Test that contact is within the allowed extent range */
154 r1=cr->rr.r1[j];
155 s1=cf[r1];
156 if(s1<0) continue;
157 t1=qsq->sq[sai->al[s1]-(cdf->sll.rfpt[s1]-r1)];
158 if(t1<0) continue;
159 r2=cr->rr.r2[j];
160 s2=cf[r2];
161 if(s2<0) continue;
162 t2=qsq->sq[sai->al[s2]-(cdf->sll.rfpt[s2]-r2)];
163 if(t2<0) continue;
164 d=cr->rr.d[j];
165
166 /* Copy contact to the location-sampling pair list */
167 k=cl->rr.n;
168 cl->rr.r1[k]=r1;
169 cl->rr.r2[k]=r2;
170 cl->rr.d[k]=d;
171 cl->rr.e[k]=pmf->rrt[d][t1][t2];
172 cl->rr.n++;
173 /* printf("j:%d k:%d s1:%d s2:%d r1:%d r2:%d t1:%d t2:%d d:%d e:%d\n",
174 j,k,s1,s2,r1,r2,t1,t2,d,cl->rr.e[k]); */
175
176 }
177
178
179 /* Loop over residue-peptide contacts in the reference list */
180 for(j=0; j<cr->rp.n; j++) {
181
182 /* Test that the contact is present in the current core */
183 r1=cr->rp.r1[j];
184 s1=cf[r1];
185 if(s1<0) continue;
186 t1=qsq->sq[sai->al[s1]-(cdf->sll.rfpt[s1]-r1)];
187 if(t1<0) continue;
188 r2=cr->rp.p2[j];
189 s2=cf[r2];
190 if(s2<0) continue;
191 d=cr->rp.d[j];
192
193 /* Copy contact to the location-sampling pair list */
194 k=cl->rp.n;
195 cl->rp.r1[k]=r1;
196 cl->rp.p2[k]=r2;
197 cl->rp.d[k]=d;
198 cl->rp.e[k]=pmf->rrt[d][t1][ppi];
199 cl->rp.n++;
200 /* printf("j:%d k:%d s1:%d s2:%d r1:%d r2:%d t1:%d t2:%d d:%d e:%d\n",
201 j,k,s1,s2,r1,r2,t1,ppi,d,cl->rp.e[k]); */
202 }
203
204
205 /* Loop over residue-fixed contacts in the reference list */
206 for(j=0; j<cr->rf.n; j++) {
207
208 /* Test that the contact is present in the current core */
209 r1=cr->rf.r1[j];
210 s1=cf[r1];
211 if(s1<0) continue;
212 t1=qsq->sq[sai->al[s1]-(cdf->sll.rfpt[s1]-r1)];
213 if(t1<0) continue;
214 t2=cr->rf.t2[j];
215 d=cr->rf.d[j];
216
217 /* Copy contact to the location-sampling pair list */
218 k=cl->rf.n;
219 cl->rf.r1[k]=r1;
220 cl->rf.t2[k]=r2;
221 cl->rf.d[k]=d;
222 cl->rf.e[k]=pmf->rrt[d][t1][t2];
223 cl->rf.n++;
224 /* printf("j:%d k:%d s1:%d s2:%d r1:%d r2:%d t1:%d t2:%d d:%d e:%d\n",
225 j,k,s1,s2,r1,r2,t1,ppi,d,cl->rf.e[k]); */
226 }
227 }
228
229 }
230
231
232