~ubuntu-branches/ubuntu/gutsy/ncbi-tools6/gutsy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* $Id: gapinfo.h,v 1.20 2005/04/27 19:49:49 dondosha Exp $
 * ===========================================================================
 *
 *                            PUBLIC DOMAIN NOTICE
 *               National Center for Biotechnology Information
 *
 *  This software/database is a "United States Government Work" under the
 *  terms of the United States Copyright Act.  It was written as part of
 *  the author's offical duties as a United States Government employee and
 *  thus cannot be copyrighted.  This software/database is freely available
 *  to the public for use. The National Library of Medicine and the U.S.
 *  Government have not placed any restriction on its use or reproduction.
 *
 *  Although all reasonable efforts have been taken to ensure the accuracy
 *  and reliability of the software and data, the NLM and the U.S.
 *  Government do not and cannot warrant the performance or results that
 *  may be obtained by using this software or data. The NLM and the U.S.
 *  Government disclaim all warranties, express or implied, including
 *  warranties of performance, merchantability or fitness for any particular
 *  purpose.
 *
 *  Please cite the author in any work or product based on this material.
 *
 * ===========================================================================
 *
 * Author: Ilya Dondoshansky
 *
 */

/** @file gapinfo.h
 * Definitions of structures used for saving traceback information.
 */

#ifndef __GAPINFO__
#define __GAPINFO__

#include <algo/blast/core/blast_def.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Operation types within the edit script*/
typedef enum EGapAlignOpType { 
   eGapAlignDel = 0, /**< Deletion: a gap in query */
   eGapAlignDel2 = 1,/**< Frame shift deletion of two nucleotides */
   eGapAlignDel1 = 2,/**< Frame shift deletion of one nucleotide */
   eGapAlignSub = 3, /**< Substitution */
   eGapAlignIns1 = 4,/**< Frame shift insertion of one nucleotide */
   eGapAlignIns2 = 5,/**< Frame shift insertion of two nucleotides */
   eGapAlignIns = 6, /**< Insertion: a gap in subject */
   eGapAlignDecline = 7, /**< Non-aligned region */
   eGapAlignInvalid = 8 /**< Invalid operation */
} EGapAlignOpType;

/** Edit script: linked list of correspondencies between two sequences */
typedef struct GapEditScript {
   EGapAlignOpType op_type;    /**< Type of operation */
   Int4 num;                   /**< Number of operations */
   struct GapEditScript* next; /**< Pointer to next link */
} GapEditScript;

/** A version of GapEditScript used to store initial results
    from the gapped alignment routines */
typedef struct GapPrelimEditScript {
   EGapAlignOpType op_type;    /**< Type of operation */
   Int4 num;                   /**< Number of operations */
} GapPrelimEditScript;

/** Preliminary version of GapEditBlock, used directly by the low-
 * level dynamic programming routines 
 */
typedef struct GapPrelimEditBlock {
    GapPrelimEditScript *edit_ops;  /**< array of edit operations */
    Int4 num_ops_allocated;        /**< size of allocated array */
    Int4 num_ops;                  /**< number of edit ops presently in use */
    EGapAlignOpType last_op;        /**< most recent operation added */
} GapPrelimEditBlock;

/** Structure to keep memory for state structure. */ 
typedef struct GapStateArrayStruct {
	Int4 	length,		/**< length of the state_array. */
		used;		/**< how much of length is used. */
	Uint1* state_array;	/**< array to be used. */
	struct GapStateArrayStruct* next; /**< Next link in the list. */
} GapStateArrayStruct;

/** Initialize the edit script structure. 
 *  @param old Pointer to existing edit script to which
 *         the new script will be appended
 *  @return Pointer to the new edit script
 */
GapEditScript* 
GapEditScriptNew (GapEditScript* old);

/** Free all links of an edit script structure. 
 *  @param esp Pointer to first link in the edit script [in]
 *  @return Always NULL
 */
GapEditScript* 
GapEditScriptDelete (GapEditScript* esp);

/** Frees a preliminary edit block structure 
 *  @param edit_block The edit block to free [in]
 *  @return Always NULL
 */
GapPrelimEditBlock *
GapPrelimEditBlockFree(GapPrelimEditBlock *edit_block);

/** Allocates a preliminary edit block structure 
 *  @return Pointer to the allocated preliminary edit block
 */
GapPrelimEditBlock *
GapPrelimEditBlockNew(void);

/** Add a new operation to a preliminary edit block, possibly combining
 *  it with the last operation if the two operations are identical
 *
 *  @param edit_block The script to update [in/modified]
 *  @param op_type The operation type to add [in]
 *  @param num_ops The number of the specified type of operation to add [in]
 */
void
GapPrelimEditBlockAdd(GapPrelimEditBlock *edit_block, 
                 EGapAlignOpType op_type, Int4 num_ops);

/** Append one GapPrelimEditBlock to the end of the other.
 * @param edit_block1 First traceback block [in]
 * @param edit_block2 Second traceback block, to be appended at the end of
 *                    the first.
 */
void
GapPrelimEditBlockAppend(GapPrelimEditBlock *edit_block1,
                         GapPrelimEditBlock *edit_block2);


/** Reset a preliminary edit block without freeing it 
 * @param edit_block The preliminary edit block to reset
 */
void
GapPrelimEditBlockReset(GapPrelimEditBlock *edit_block);

/** Free the gap state structure. 
 * @param state_struct The state structure to free
 * @return Always NULL
 */
GapStateArrayStruct* 
GapStateFree(GapStateArrayStruct* state_struct);

#ifdef __cplusplus
}
#endif
#endif /* !__GAPINFO__ */