NCBI C++ ToolKit
blast_query_info.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: blast_query_info.h 75049 2016-10-17 19:00:07Z boratyng $
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  * Author: Christiam Camacho
27  *
28  */
29 
30 /** @file blast_query_info.h
31  * Definitions and functions associated with the BlastQueryInfo structure
32  */
33 
34 #ifndef ALGO_BLAST_CORE__BLAST_QUERY_INFO__H
35 #define ALGO_BLAST_CORE__BLAST_QUERY_INFO__H
36 
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /** Information about paired segments (for mapping short reads)
46  */
47 typedef enum EMagicBlastSegmentInfo {
48  eNoSegments = 0, /**< Sequence is not part of a pair */
49  fFirstSegmentFlag = 1, /**< The first sequence of a pair */
50  fLastSegmentFlag = 1 << 1, /**< The last sequence of a pair */
51  fPartialFlag = 1 << 2, /**< The other segment is not present (did not
52  pass quality filtering */
53  eFirstSegment = fFirstSegmentFlag, /**< The first sequence of a pair with
54  both sequences read and accepted */
55  eLastSegment = fLastSegmentFlag /** The last sequence of a pair with
56  both sequences read and accepted */
58 
59 /** The context related information */
60 typedef struct BlastContextInfo {
61  Int4 query_offset; /**< Offset of this query, strand or frame in the
62  concatenated super-query. */
63  Int4 query_length; /**< Length of this query, strand or frame */
64  Int8 eff_searchsp; /**< Effective search space for this context. */
65  Int4 length_adjustment; /**< Length adjustment for boundary conditions */
66  Int4 query_index; /**< Index of query (same for all frames) */
67  Int1 frame; /**< Frame number (-1, -2, -3, 0, 1, 2, or 3) */
68  Boolean is_valid; /**< Determine if this context is valid or not.
69  This field should be set only by the setup code
70  and read by subsequent stages of the BLAST search
71  */
72  Int4 segment_flags; /**< Flags describing segments for paired reads */
74 
75 /** Forward declaration of SPHIQueryInfo */
76 struct SPHIQueryInfo;
77 
78 /** The query related information
79  */
80 typedef struct BlastQueryInfo {
81  Int4 first_context; /**< Index of the first element of the context array */
82  Int4 last_context; /**< Index of the last element of the context array */
83  int num_queries; /**< Number of query sequences */
84  BlastContextInfo * contexts; /**< Information per context */
85  Uint4 max_length; /**< Length of the longest among the concatenated
86  queries */
87  Uint4 min_length; /**< Length of the shortest among the concatenated
88  queries */
89  struct SPHIQueryInfo* pattern_info; /**< Counts of PHI BLAST pattern
90  occurrences, used in PHI BLAST only. */
92 
93 
94 /** Allocate memory for query information structure */
96 BlastQueryInfo* BlastQueryInfoNew(EBlastProgramType program, int num_queries);
97 
98 /** Deallocate memory for query information structure */
101 
102 /** Duplicates the query information structure */
105 
106 /** Given a context from BLAST engine core, return the query index.
107  * @param context Context saved in a BlastHSP structure [in]
108  * @param program Type of BLAST program [in]
109  * @return Query index in a set of queries or -1 on error
110  */
113 
114 
115 /** Return the query index (zero based), given the query offset
116  * in the initial HSP as the program.
117  * @param query_offset Offset of the query in the initial HSP [in]
118  * @param program EBlastProgramType [in]
119  * @param query_info information about all the queries [in]
120  * @return Query Index in a set of queries
121 */
123 Int4 Blast_GetQueryIndexFromQueryOffset(Int4 query_offset, EBlastProgramType program, const BlastQueryInfo* query_info);
124 
125 
126 /** Retrieve a query sequence's search space
127  * @param qinfo BlastQueryInfo structure [in]
128  * @param program CORE program type [in]
129  * @param query_index number of the query
130  * (query_index < BlastQueryInfo::num_queries) [in]
131  * @return the search space of the query sequence requested or 0 if this is not
132  * set */
134 Int8
136  EBlastProgramType program,
137  Int4 query_index);
138 
139 /** Set a query sequence's search space
140  * @param qinfo BlastQueryInfo structure [in]
141  * @param program CORE program type [in]
142  * @param query_index number of the query
143  * (query_index < BlastQueryInfo::num_queries) [in]
144  * @param eff_searchsp the effective search space to use [in]
145  */
147 void
149  EBlastProgramType program,
150  Int4 query_index,
151  Int8 eff_searchsp);
152 
153 /** Obtains the sequence length for a given query in the query, without taking
154  * into consideration any applicable translations
155  * @param qinfo BlastQueryInfo structure [in]
156  * @param program CORE program type [in]
157  * @param query_index number of the query
158  * (query_index < BlastQueryInfo::num_queries) [in]
159  * @return the length of the query sequence requested
160  */
163  EBlastProgramType program,
164  Int4 query_index);
165 
166 /** Create auxiliary query structures with all data corresponding
167  * to a single query sequence within a concatenated set. Allocates the
168  * structures if the pointers are NULL on input; otherwise only changes the
169  * contents.
170  * @param one_query_info_ptr Pointer to the query information structure for a
171  * single query. Allocated and filled here, so the
172  * caller of this function will be responsible for
173  * freeing it. [out]
174  * @param one_query_ptr Pointer to the query sequence block structure; allocated
175  * here, but the contents are not allocated; it is still
176  * safe to free by the caller after use. [out]
177  * @param query_info Query information structure containing information about a
178  * concatenated set. [in]
179  * @param query Query sequence block corresponding to a concatenated set of
180  * queries. [in]
181  * @param query_index Which query index to create the auxiliary structures
182  * for? [in]
183  * @return -1 if memory allocation failed; 0 on success
184  */
186 Int2 Blast_GetOneQueryStructs(BlastQueryInfo** one_query_info_ptr,
187  BLAST_SequenceBlk** one_query_ptr,
188  const BlastQueryInfo* query_info,
189  BLAST_SequenceBlk* query, Int4 query_index);
190 
191 /** Search BlastContextInfo structures for the specified offset */
194 
195 /** Get the number of bytes required for the concatenated sequence
196  * buffer, given a query info structure. The context data should
197  * already be assigned.
198  * @param qinfo Query info structure. [in/out]
199  * @return Number of bytes for all queries and inter-query marks.
200  */
202 Uint4
204 
205 
206 /** Copy the context query offsets to an allocated array of Int4.
207  * @param info Describes the concatenated query.
208  * @return Allocated array.
209  */
212 
213 
214 /** Copy the context query offsets from an array of Int4, allocating
215  * the context array if needed.
216  * @param info Destination for the values.
217  * @param new_offsets Array of values to copy from.
218  * @param prog The blast program type.
219  */
222  Int4 * new_offsets,
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* !ALGO_BLAST_CORE__BLAST_QUERY_INFO__H */
Definitions used throughout BLAST.
#define NCBI_XBLAST_EXPORT
NULL operations for other cases.
Definition: blast_export.h:65
Definitions for various programs supported by core BLAST.
EBlastProgramType
Defines the engine's notion of the different applications of the BLAST algorithm.
Definition: blast_program.h:72
BlastQueryInfo * BlastQueryInfoDup(const BlastQueryInfo *query_info)
Duplicates the query information structure.
Int4 Blast_GetQueryIndexFromQueryOffset(Int4 query_offset, EBlastProgramType program, const BlastQueryInfo *query_info)
Return the query index (zero based), given the query offset in the initial HSP as the program.
BlastQueryInfo * BlastQueryInfoFree(BlastQueryInfo *query_info)
Deallocate memory for query information structure.
EMagicBlastSegmentInfo
Information about paired segments (for mapping short reads)
@ eFirstSegment
The first sequence of a pair with both sequences read and accepted.
@ fPartialFlag
The other segment is not present (did not pass quality filtering.
@ fFirstSegmentFlag
The first sequence of a pair.
@ fLastSegmentFlag
The last sequence of a pair.
@ eNoSegments
Sequence is not part of a pair.
@ eLastSegment
Int4 Blast_GetQueryIndexFromContext(Int4 context, EBlastProgramType program)
Given a context from BLAST engine core, return the query index.
Int2 Blast_GetOneQueryStructs(BlastQueryInfo **one_query_info_ptr, BLAST_SequenceBlk **one_query_ptr, const BlastQueryInfo *query_info, BLAST_SequenceBlk *query, Int4 query_index)
Create auxiliary query structures with all data corresponding to a single query sequence within a con...
Int8 BlastQueryInfoGetEffSearchSpace(const BlastQueryInfo *qinfo, EBlastProgramType program, Int4 query_index)
Retrieve a query sequence's search space.
struct BlastQueryInfo BlastQueryInfo
The query related information.
Int4 BSearchContextInfo(Int4 n, const BlastQueryInfo *A)
Search BlastContextInfo structures for the specified offset.
Int4 * ContextOffsetsToOffsetArray(const BlastQueryInfo *info)
Copy the context query offsets to an allocated array of Int4.
void OffsetArrayToContextOffsets(BlastQueryInfo *info, Int4 *new_offsets, EBlastProgramType prog)
Copy the context query offsets from an array of Int4, allocating the context array if needed.
void BlastQueryInfoSetEffSearchSpace(BlastQueryInfo *qinfo, EBlastProgramType program, Int4 query_index, Int8 eff_searchsp)
Set a query sequence's search space.
Uint4 QueryInfo_GetSeqBufLen(const BlastQueryInfo *qinfo)
Get the number of bytes required for the concatenated sequence buffer, given a query info structure.
struct BlastContextInfo BlastContextInfo
The context related information.
Int4 BlastQueryInfoGetQueryLength(const BlastQueryInfo *qinfo, EBlastProgramType program, Int4 query_index)
Obtains the sequence length for a given query in the query, without taking into consideration any app...
BlastQueryInfo * BlastQueryInfoNew(EBlastProgramType program, int num_queries)
Allocate memory for query information structure.
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
int8_t Int1
1-byte (8-bit) signed integer
Definition: ncbitype.h:98
yy_size_t n
static MDB_envinfo info
Definition: mdb_load.c:37
static char * prog
Definition: mdb_load.c:33
Type and macro definitions from C toolkit that are not defined in C++ toolkit.
Uint1 Boolean
bool replacment for C
Definition: ncbi_std.h:94
#define A
Structure to hold a sequence.
Definition: blast_def.h:242
The context related information.
Int4 query_length
Length of this query, strand or frame.
Boolean is_valid
Determine if this context is valid or not.
Int4 segment_flags
Flags describing segments for paired reads.
Int4 query_offset
Offset of this query, strand or frame in the concatenated super-query.
Int4 length_adjustment
Length adjustment for boundary conditions.
Int8 eff_searchsp
Effective search space for this context.
Int4 query_index
Index of query (same for all frames)
Int1 frame
Frame number (-1, -2, -3, 0, 1, 2, or 3)
The query related information.
Int4 first_context
Index of the first element of the context array.
BlastContextInfo * contexts
Information per context.
int num_queries
Number of query sequences.
Uint4 min_length
Length of the shortest among the concatenated queries.
struct SPHIQueryInfo * pattern_info
Counts of PHI BLAST pattern occurrences, used in PHI BLAST only.
Int4 last_context
Index of the last element of the context array.
Uint4 max_length
Length of the longest among the concatenated queries.
In PHI BLAST, structure containing information about all pattern occurrences in query.
Definition: blast_def.h:300
static string query
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Fri Sep 20 14:58:15 2024 by modify_doxy.py rev. 669887