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

Go to the SVN repository for this file.

1 /* $Id: thrdsalr.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: thrdsalr.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 alignment range for a core segment */
43 
44 /* Find limiting values for alignment of a core segment, given the extent */
45 /* and alignment of other segments, loop length ranges, the length of the */
46 /* query sequence, and any explicit alignment constraints */
47 
48 int salr(Cor_Def* cdf, Qry_Seq* qsq, Cur_Loc* sli, Cur_Aln* sai, int cs, int* mn, int* mx) {
49 /*-----------------------------------------------------------*/
50 /* cdf: Contains specified loop length limits */
51 /* qsq: Sequence to thread with alignment contraints */
52 /* sli: Contains current segment location values */
53 /* sai: Contains current segment alignment values */
54 /* cs: The segment for which constraints are to be found */
55 /* mn,mx: The range of allowed aligments for this segment */
56 /*-----------------------------------------------------------*/
57 
58 int nsc; /* Number of core segments */
59 int lm1,lm2; /* Loop length limits */
60 int ntmn,ntmx; /* Alignment range due to n-termnal constraints */
61 int ctmn,ctmx; /* Alignment range due to c-termnal constraints */
62 
63 /* Number of core segments */
64 nsc=cdf->sll.n;
65 
66 /* printf("cs:%d ",cs);
67 for(i=0;i<nsc;i++) printf("%d ",sai->al[i]); printf("sai->al\n"); */
68 
69 /* Find constraints arising from the segment n-terminal to this one. */
70 if(cs==0) {
71  ntmn=-1+cdf->lll.llmn[0];
72  ntmx=qsq->n; }
73 else { ntmn=ntmx=sai->al[cs-1]+sli->co[cs-1];
74  /* printf("ntmn=ntmx:%d\n",ntmn); */
75  lm1=sli->lp[cs];
76  /* printf("sli->lp[%d]:%d\n",cs,sli->lp[cs]); */
77  lm2=cdf->lll.llmn[cs];
78  ntmn+= (lm1>lm2) ? lm1 : lm2;
79  /* printf("lm2:%d ntmn:%d\n",lm2,ntmn); */
80  lm2=cdf->lll.llmx[cs];
81  ntmx+= (lm1>lm2) ? lm1 : lm2;
82  /* printf("lm2:%d ntmx:%d\n",lm2,ntmx); */
83  }
84 ntmn+=sli->no[cs]+1;
85 ntmx+=sli->no[cs]+1;
86 /* printf("ntmn:%d ntmx:%d\n",ntmn,ntmx); */
87 
88 /* Find constraints arising from the segment c-terminal to this one. */
89 if(cs==(nsc-1)) {
90  ctmn=-1;
91  ctmx=qsq->n-cdf->lll.llmn[nsc]; }
92 else { ctmn=ctmx=sai->al[cs+1]-sli->no[cs+1];
93  /* printf("ctmn=ctmx:%d\n",ctmn); */
94  lm1=sli->lp[cs+1];
95  /* printf("sli->lp[%d]:%d\n",cs+1,sli->lp[cs+1]); */
96  lm2=cdf->lll.llmn[cs+1];
97  ctmx-= (lm1>lm2) ? lm1 : lm2;
98  /* printf("lm2:%d ctmx:%d\n",lm2,ctmx); */
99  lm2=cdf->lll.llmx[cs+1];
100  ctmn-= (lm1>lm2) ? lm1 : lm2;
101  /* printf("lm2:%d ctmn:%d\n",lm2,ctmn); */
102  }
103 ctmn-=sli->co[cs]+1;
104 ctmx-=sli->co[cs]+1;
105 /* printf("ctmn:%d ctmx:%d\n",ctmn,ctmx); */
106 
107 
108 /* Signal an error if no alignment falls within the limits identified. */
109 if(ntmn>ctmx||ntmx<ctmn) return(0);
110 
111 /* Reconcile n-termnal and c-termnal aligment limits. */
112 *mn=(ntmn>ctmn) ? ntmn : ctmn;
113 *mx=(ntmx<ctmx) ? ntmx : ctmx;
114 /* printf("mn:%d mx:%d\n",*mn,*mx); */
115 
116 /* Further reconcile any explict limits on the current segment alignment. */
117 /* printf("qsq->sac.mn[%d]: %d\n",cs,qsq->sac.mn[cs]); */
118 if(qsq->sac.mn[cs]>0) {
119  lm1=qsq->sac.mn[cs];
120  if(lm1>*mx) return(0);
121  if(lm1>*mn) *mn=lm1;}
122 /* printf("qsq->sac.mx[%d]: %d\n",cs,qsq->sac.mx[cs]); */
123 if(qsq->sac.mx[cs]>0) {
124  lm1=qsq->sac.mx[cs];
125  if(lm1<*mn) return(0);
126  if(lm1<*mx) *mx=lm1; }
127 
128 return(1);
129 
130 }
struct _Cor_Def::@23 sll
struct _Cor_Def::@24 lll
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 * lp
Definition: thrdatd.h:182
int * no
Definition: thrdatd.h:179
int * co
Definition: thrdatd.h:180
int * mx
Definition: thrdatd.h:96
int * mn
Definition: thrdatd.h:95
int n
Definition: thrdatd.h:93
struct _Qry_Seq::@26 sac
int salr(Cor_Def *cdf, Qry_Seq *qsq, Cur_Loc *sli, Cur_Aln *sai, int cs, int *mn, int *mx)
Definition: thrdsalr.c:48
Modified on Fri Sep 20 14:57:34 2024 by modify_doxy.py rev. 669887