1 /* $Id: thrdslou.c 99676 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: thrdslou.c
27 *
28 * Author: Stephen Bryant
29 *
30 * Initial Version Creation Date: 08/16/2000
31 *
32 * $Revision: 99676 $
33 *
34 * File Description: threader
35 */
36
37
38
39 /* Update core segment location */
40
41 #include <algo/structure/threader/thrdatd.h>
42 #include <algo/structure/threader/thrddecl.h>
43
slou(Fld_Mtf * mtf,Cor_Def * cdf,int cs,int ct,int of,Cur_Loc * sli,Cur_Aln * sai,Qry_Seq * qsq)44 /*int*/ void slou(Fld_Mtf* mtf, Cor_Def* cdf, int cs, int ct, int of, Cur_Loc* sli,
45 Cur_Aln* sai, Qry_Seq* qsq) {
46 /*--------------------------------------------------------*/
47 /* mtf: Contact matrices defining the folding motif */
48 /* cdf: Core definition contains min/max segment extents */
49 /* cs: Current segment */
50 /* ct: Current terminus */
51 /* of: New alignment of current segment */
52 /* sli: Current locations of core segments in the motif */
53 /*--------------------------------------------------------*/
54
55 int i; /* Residue indices in core motif */
56 int nsc; /* Number of threaded core segments */
57 int mx,mn; /* Range of motif indices */
58 int rf; /* Reference point for core segment offsets */
59 int nt; /* Terminus of neighboring segment */
60 int ns; /* Neighbor segment index */
61 int ci, si;
62
63 /* Number of core segments */
64 nsc=cdf->sll.n;
65
66 /* Lower in-core flags for all positions in the current element */
67 rf=cdf->sll.rfpt[cs];
68 mn=rf-sli->no[cs];
69 mx=rf+sli->co[cs];
70 for(i=mn; i<=mx; i++) sli->cr[i]=-1;
71
72
73 /* Record new element range based on updated n- or c-terminal extent */
74 switch(ct) {
75
76 case 0: { sli->no[cs]=of;
77 mn=rf-of;
78 ns=cs-1; if(ns>=0) {
79 nt=cdf->sll.rfpt[ns]+sli->co[ns];
80 sli->lp[cs]=mtf->mll[nt][mn]; }
81 break; }
82
83 case 1: { sli->co[cs]=of;
84 mx=rf+of;
85 ns=cs+1; if(ns<nsc) {
86 nt=cdf->sll.rfpt[ns]-sli->no[ns];
87 sli->lp[cs+1]=mtf->mll[mx][nt]; }
88 break; }
89 }
90
91
92 /* Raise in-core flags for all positions in the new element */
93 for(i=mn; i<=mx; i++) sli->cr[i]=cs;
94
95 /* update aligned residue types */
96 mn=sai->al[cs]-sli->no[cs];
97 mx=sai->al[cs]+sli->co[cs];
98 ci=cdf->sll.rfpt[cs]-sli->no[cs];
99 for(si=mn; si<=mx; si++) {
100 sai->sq[ci]=qsq->sq[si];
101 ci++; }
102
103 }
104