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

Go to the SVN repository for this file.

1 /* $Id: thrdslor.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: thrdslor.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 /* Find allowed extent range for a core segment */
43 
44 /* Find limiting values for location of a core segment terminus, given the */
45 /* extent and alignment of other segments, loop length ranges, and the */
46 /* length of the query sequence. */
47 
48 /* The algorithm used begins by defining the interval on the query sequence */
49 /* which is available for assignment to the loop plus extenstion of the core */
50 /* segment beyond it's minimum extent. Beginning at the current segment */
51 /* extent, it moves the segment endpoint towards it's minimum, until either */
52 /* the minimum extent is reached, or a loop length inconsistent with motif- */
53 /* derived limits is encounterd (see comment below). Beginning again with */
54 /* the current extent, the algorithm then moves the segment endpoint towards */
55 /* its maximum, until either the maxixmum extent is reached, or the portion */
56 /* of the query sequence interval remaining for the loop decreases below it's */
57 /* explicit or motif-derived limit. The resulting range is continuous, and */
58 /* contains at least one value, the current or starting extent. */
59 
60 int slor(Fld_Mtf* mtf, Cor_Def* cdf, Qry_Seq* qsq, Cur_Loc* sli, Cur_Aln* sai,
61  int cs, int ct, int* mn, int*mx) {
62 /*------------------------------------------------------------*/
63 /* mtf: Contact matrices defining the folding motif */
64 /* cdf: Contains specified loop length limits */
65 /* qsq: Sequence to thread with alignment contraints */
66 /* sli: Contains current segment location values */
67 /* sai: Contains current segment alignment values */
68 /* cs: The segment for which constraints are to be found */
69 /* ct: The terminus for which constraints are to be found */
70 /* mn,mx: The range of allowed aligments for this segment */
71 /*------------------------------------------------------------*/
72 
73 int nsc; /* Number of core segments */
74 int i; /* Counter */
75 int nr; /* Endpoint residue position in neighboring segment */
76 int qs,qf; /* Start and finish of a query sequence interval */
77 int ql; /* Limit on loop plus extentsion length by query seq */
78 int ns; /* Neighbor segment index */
79 int mxo,mno; /* Explicit maximum and minimum segment extent */
80 int cuo; /* Current segment extent */
81 int cua; /* Current segment alignment */
82 int *mp=NULL; /* Motif-derived loop length limits */
83 int l1; /* Minimum loop length allowed by core definition */
84 int l2; /* Minimum loop length allowed by folding motif */
85 int ll; /* Loop length implied by a given segment extent */
86 int lm; /* Reconciled loop length limit */
87 int cr; /* Central residue of this core segment */
88 int q1,q2; /* Limits on query sequence interval finish */
89 
90 /* Number of core segments */
91 nsc=cdf->sll.n;
92 
93 /* for(i=0;i<nsc;i++) printf("%d ",sai->al[i]); printf("sai->al\n");
94 for(i=0;i<sai->nmt;i++) printf("%d ",sai->sq[i]); printf("sai->sq\n");
95 for(i=0;i<nsc;i++) printf("%d ",sli->no[i]); printf("sli->no\n");
96 for(i=0;i<nsc;i++) printf("%d ",sli->co[i]); printf("sli->co\n");
97 for(i=0;i<sli->nlp;i++) printf("%d ",sli->lp[i]); printf("sli->lp\n");
98 for(i=0;i<sli->nmt;i++) printf("%d ",sli->cr[i]); printf("sli->cr\n"); */
99 
100 /* Current alignment of this segment */
101 cua=sai->al[cs];
102 
103 /* Central residue of this segment */
104 cr=cdf->sll.rfpt[cs];
105 
106 switch(ct) {
107 
108  case 0: { /* N-terminal limits */
109 
110  if(cs>0) { ns=cs-1;
111 
112  /* Start of query sequence interval */
113  qs=sai->al[ns]+sli->co[ns]+1;
114 
115  /* Finish of query sequence interval */
116  q1=cua-cdf->sll.nomn[cs]-1;
117  q2=qs+cdf->lll.llmx[cs]-1;
118  qf=(q2<q1) ? q2 : q1;
119 
120  /* Last position of neighboring core segment */
121  nr=cdf->sll.rfpt[ns]+sli->co[ns];
122  /* printf("q1:%d q2:%d nr:%d\n",q1,q2,nr); */
123 
124  /* Pointer to motif-derived loop length limits */
125  mp=mtf->mll[nr];
126 
127  }
128 
129  else {
130  /* Start of query sequence interval */
131  /* qs=0+cdf->lll.llmn[cs]; */
132  qs=0;
133 
134  /* Finish of query sequence interval */
135  qf=cua-cdf->sll.nomn[cs]-1;
136 
137  /* Flag value for last position of preceding segment */
138  nr=-1; }
139 
140 
141  /* Minimum extent allowed by alignment and explicit limit */
142  mno=cua-qf-1;
143 
144  /* Maximum extent allowed by core definition */
145  mxo=cdf->sll.nomx[cs];
146 
147  /* Explicit minimum loop length */
148  l1=cdf->lll.llmn[cs];
149 
150  /* Length of query sequence interval */
151  ql=qf-qs+1;
152 
153  /* Current extent of this segment */
154  cuo=sli->no[cs];
155 
156  /* Check current extent against motif loop limits */
157  l2=(nr<0) ? l1 : mp[cr-cuo];
158  lm=(l1>l2) ? l1:l2;
159  ll=ql-(cuo-mno);
160 /* printf("cs:%d ct:0 qs:%d qf:%d cuo:%d mno:%d mxo:%d l1:%d l2:%d ll:%d\n",
161  cs,qs,qf,cuo,mno,mxo,l1,l2,ll); */
162  if(ll<lm) return(0);
163 
164  /* Find the minimum extent consistent with motif loop limits. */
165  /* This is expected to be the minimum extent given explicitly */
166  /* in the core definition, since by the triangle inequality */
167  /* one may expect to remove residues from the terminus of the */
168  /* segment and add them to the loop, and always have a loop */
169  /* long enough to reach the neighboring segment. This must */
170  /* be checked, however, since coordinate imprecision allows */
171  /* occasional violations of this inequality in the matrix of */
172  /* motif-derived loop limits. The minimum identified here */
173  /* will define a continuous extent range that includes the */
174  /* present extent, and has at least this one valid value. */
175 
176  *mn=cuo;
177  for(i=cuo-1; i>=mno; i--) {
178 
179  /* Length of loop implied by this extent */
180  ll=ql-(i-mno);
181 
182  /* Motif-derived minimum loop length */
183  l2=(nr<0) ? l1 : mp[cr-i];
184 
185  /* Greater of fixed and motif-derived loop limits */
186  lm=(l1>l2) ? l1:l2;
187  /* printf("mn:%d ll:%d l1:%d l2:%d lm:%d nr2:%d\n",
188  i,ll,l1,l2,lm,cr-i); */
189 
190  /* Set minimum extent if loop length is allowed */
191  if(ll>=lm) *mn=i; else break;
192 
193  }
194 
195 
196  /* Find the maximum extent consistent with motif and */
197  /* explicit minimum loop limits. This maxixum varies with */
198  /* the aligment, which will have assigned varying numbers */
199  /* of residues to the extent-plus-loop interval on the query */
200  /* sequence. */
201 
202  *mx=cuo;
203  for(i=cuo+1; i<=mxo; i++) {
204 
205  /* Length of adjacent loop implied by this extent */
206  ll=ql-(i-mno);
207 
208  /* Motif-derived minimum loop length */
209  l2=(nr<0) ? l1 : mp[cr-i];
210 
211  /* Greater of fixed and motif-derived loop limits */
212  lm=(l1>l2) ? l1:l2;
213  /* printf("mx:%d ll:%d l1:%d l2:%d lm:%d nr2:%d\n",
214  i,ll,l1,l2,lm,cr-i); */
215 
216  /* If loop length is above minimum, increase extent */
217  if(ll>=lm) *mx=i; else break; }
218 
219  break;
220  }
221 
222 
223  case 1: { /* C-terminal limits */
224 
225 
226  if(cs<(nsc-1)) { ns=cs+1;
227 
228  /* Finish of query sequence interval */
229  qf=sai->al[ns]-sli->no[ns]-1;
230 
231  /* Start of query sequence interval */
232  q1=cua+cdf->sll.comn[cs]+1;
233  q2=qf-cdf->lll.llmx[ns]+1;
234  qs=(q2>q1) ? q2 : q1;
235 
236  /* Last position of following core segment */
237  nr=cdf->sll.rfpt[ns]-sli->no[ns];
238  /* printf("q1:%d q2:%d nr:%d\n",q1,q2,nr); */
239 
240  /* Pointer to motif-derived loop length limits */
241  mp=mtf->mll[nr];
242  }
243 
244  else {
245  /* Start of query sequence interval */
246  /* qf=qsq->n-1-cdf->lll.llmn[nsc]; */
247  qf=qsq->n-1;
248 
249  /* Finish of query sequence interval */
250  qs=cua+cdf->sll.comn[cs]+1;
251 
252  /* Flag value for last position of preceding segment */
253  nr=-1; }
254 
255  /* Length of query sequence interval */
256  ql=qf-qs+1;
257 
258  /* Minimum extent allowed by alignment and explicit limit */
259  mno=qs-cua-1;
260 
261  /* Maximum extent allowed by core definition */
262  mxo=cdf->sll.comx[cs];
263 
264  /* Explicit minimum loop length */
265  l1=cdf->lll.llmn[cs+1];
266 
267  /* Current extent of this segment */
268  cuo=sli->co[cs];
269 
270  /* Check current extent against motif loop limits */
271  l2=(nr<0) ? l1 : mp[cr+cuo];
272  lm=(l1>l2) ? l1:l2;
273  ll=ql-(cuo-mno);
274 /* printf("cs:%d ct:1 qs:%d qf:%d cuo:%d mno:%d mxo:%d l1:%d l2:%d ll:%d\n",
275  cs,qs,qf,cuo,mno,mxo,l1,l2,ll); */
276  if(ll<lm) return(0);
277 
278  /* Find the minimum extent consistent with motif loop limits. */
279  /* This is expected to be the minimum extent given explicitly */
280  /* in the core definition, since by the triangle inequality */
281  /* one may expect to remove residues from the terminus of the */
282  /* segment and add them to the loop, and always have a loop */
283  /* long enough to reach the neighboring segment. This must */
284  /* be checked, however, since coordinate imprecision allows */
285  /* occasional violations of this inequality in the matrix of */
286  /* motif-derived loop limits. The minimum identified here */
287  /* will define a continuous extent range that includes the */
288  /* present extent, and has at least this one valid value. */
289 
290  *mn=cuo;
291  for(i=cuo-1; i>=mno; i--) {
292 
293  /* Length of loop implied by this extent */
294  ll=ql-(i-mno);
295 
296  /* Motif-derived minimum loop length */
297  l2=(nr<0) ? l1 : mp[cr+i];
298 
299  /* Greater of fixed and motif-derived loop limits */
300  lm=(l1>l2) ? l1:l2;
301  /* printf("mn:%d ll:%d l1:%d l2:%d lm:%d nr2:%d\n",
302  i,ll,l1,l2,lm,cr+i); */
303 
304  /* Set minimum extent if loop length is allowed */
305  if(ll>=lm) *mn=i; else break;
306 
307  }
308 
309 
310  /* Find the maximum extent consistent with motif and */
311  /* explicit minimum loop limits. This maxixum varies with */
312  /* the aligment, which will have assigned varying numbers */
313  /* of residues to the extent-plus-loop interval on the query */
314  /* sequence. */
315 
316  *mx=cuo;
317  for(i=cuo+1; i<=mxo; i++) {
318 
319  /* Length of adjacent loop implied by this extent */
320  ll=ql-(i-mno);
321 
322  /* Motif-derived minimum loop length */
323  l2=(nr<0) ? l1 : mp[cr+i];
324 
325  /* Greater of fixed and motif-derived loop limits */
326  lm=(l1>l2) ? l1:l2;
327  /* printf("mx:%d ll:%d l1:%d l2:%d lm:%d nr2:%d\n",
328  i,ll,l1,l2,lm,cr+i); */
329 
330  /* If loop length is above minimum, increase extent */
331  if(ll>=lm) *mx=i; else break; }
332 
333  break;
334  }
335 
336  }
337 
338 
339 /* printf("mn:%d mx:%d\n",*mn,*mx); */
340 
341 return(1);
342 }
#define NULL
Definition: ncbistd.hpp:225
int i
static SLJIT_INLINE sljit_ins nr(sljit_gpr dst, sljit_gpr src)
int * comn
Definition: thrdatd.h:72
int * nomn
Definition: thrdatd.h:70
struct _Cor_Def::@23 sll
int * nomx
Definition: thrdatd.h:71
struct _Cor_Def::@24 lll
int * rfpt
Definition: thrdatd.h:69
int * comx
Definition: thrdatd.h:73
int * llmx
Definition: thrdatd.h:78
int * llmn
Definition: thrdatd.h:77
int n
Definition: thrdatd.h:74
int * al
Definition: thrdatd.h:190
int * no
Definition: thrdatd.h:179
int * co
Definition: thrdatd.h:180
int ** mll
Definition: thrdatd.h:63
int n
Definition: thrdatd.h:93
int slor(Fld_Mtf *mtf, Cor_Def *cdf, Qry_Seq *qsq, Cur_Loc *sli, Cur_Aln *sai, int cs, int ct, int *mn, int *mx)
Definition: thrdslor.c:60
Modified on Fri Sep 20 14:58:05 2024 by modify_doxy.py rev. 669887