1 /* $Id: thrdslou.c,v 1.2 2001/04/26 17:23:38 thiessen 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:  thrdslou.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: thrdslou.c,v $
39 * Revision 1.2  2001/04/26 17:23:38  thiessen
40 * fix bug in updating aligned residue types
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 /* Update core segment location */
51 
52 #include <thrdatd.h>
53 #include <thrddecl.h>
54 
slou(Fld_Mtf * mtf,Cor_Def * cdf,int cs,int ct,int of,Cur_Loc * sli,Cur_Aln * sai,Qry_Seq * qsq)55 int slou(Fld_Mtf* mtf, Cor_Def* cdf, int cs, int ct, int of, Cur_Loc* sli,
56     Cur_Aln* sai, Qry_Seq* qsq) {
57 /*--------------------------------------------------------*/
58 /* mtf:  Contact matrices defining the folding motif      */
59 /* cdf:  Core definition contains min/max segment extents */
60 /* cs:   Current segment                                  */
61 /* ct:   Current terminus                                 */
62 /* of:   New alignment of current segment                 */
63 /* sli:  Current locations of core segments in the motif  */
64 /*--------------------------------------------------------*/
65 
66 int	i;		/* Residue indices in core motif */
67 int     nsc;            /* Number of threaded core segments */
68 int	mx,mn;		/* Range of motif indices */
69 int	rf;		/* Reference point for core segment offsets */
70 int	nt;		/* Terminus of neighboring segment */
71 int	ns;		/* Neighbor segment index */
72 int	ci, si;
73 
74 /* Number of core segments */
75 nsc=cdf->sll.n;
76 
77 /* Lower in-core flags for all positions in the current element */
78 rf=cdf->sll.rfpt[cs];
79 mn=rf-sli->no[cs];
80 mx=rf+sli->co[cs];
81 for(i=mn; i<=mx; i++) sli->cr[i]=-1;
82 
83 
84 /* Record new element range based on updated n- or c-terminal extent */
85 switch(ct) {
86 
87 	case 0: { 	sli->no[cs]=of;
88 			mn=rf-of;
89 			ns=cs-1; if(ns>=0) {
90 				nt=cdf->sll.rfpt[ns]+sli->co[ns];
91 				sli->lp[cs]=mtf->mll[nt][mn]; }
92 			break; }
93 
94 	case 1: { 	sli->co[cs]=of;
95 			mx=rf+of;
96 			ns=cs+1; if(ns<nsc) {
97 				nt=cdf->sll.rfpt[ns]-sli->no[ns];
98 				sli->lp[cs+1]=mtf->mll[mx][nt]; }
99 			break; }
100 		}
101 
102 
103 /* Raise in-core flags for all positions in the new element */
104 for(i=mn; i<=mx; i++) sli->cr[i]=cs;
105 
106 /* update aligned residue types */
107 mn=sai->al[cs]-sli->no[cs];
108 mx=sai->al[cs]+sli->co[cs];
109 ci=cdf->sll.rfpt[cs]-sli->no[cs];
110 for(si=mn; si<=mx; si++) {
111     sai->sq[ci]=qsq->sq[si];
112     ci++; }
113 
114 }
115 
116