NCBI C Toolkit Cross Reference

C/algo/blast/api/blast_format.h


  1 /* $Id: blast_format.h,v 1.46 2006/10/06 12:22:00 madden 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 offical 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: Ilya Dondoshansky
 27 *
 28 */
 29 
 30 /** @file blast_format.h
 31  * Functions needed for formatting of BLAST results
 32  */
 33 
 34 #ifndef __BLAST_FORMAT__
 35 #define __BLAST_FORMAT__
 36 
 37 #ifdef __cplusplus
 38 extern "C" {
 39 #endif
 40 
 41 #ifndef NCBI_C_TOOLKIT
 42 #define NCBI_C_TOOLKIT
 43 #endif
 44 
 45 #include <ncbi.h>
 46 #include <asn.h>
 47 #include <bxmlobj.h>
 48 #include <algo/blast/core/blast_options.h>
 49 #include <algo/blast/core/blast_hits.h>
 50 #include <algo/blast/core/blast_diagnostics.h>   
 51 #include <algo/blast/api/twoseq_api.h>
 52 #include <algo/blast/api/blast_options_api.h>
 53 #include <algo/blast/api/blast_seqalign.h>
 54 #include <xmlblast.h>
 55 
 56 /** @addtogroup CToolkitAlgoBlast
 57  *
 58  * @{
 59  */
 60 
 61 /** Enums for selecting view type (query-anchored, pairwise, etc.)
 62 */
 63 typedef enum EAlignView {
 64     /** Pairwise. */
 65     eAlignViewPairwise                   = 0,
 66     /** Query anchored with identities. */
 67     eAlignViewQueryAnchoredIdent         = 1,
 68     /** Query anchored without identities. */
 69     eAlignViewQueryAnchoredNoIdent       = 2,
 70     /** Flat query anchored with identities. */
 71     eAlignViewFlatQueryAnchoredIdent     = 3,
 72     /** Flat query anchored without identities. */
 73     eAlignViewFlatQueryAnchoredNoIdent   = 4,
 74     /** Query anchored with blunt ends. */
 75     eAlignViewQueryAnchoredBluntEnds     = 5,
 76     /** Flat query anchored with blunt ends. */ 
 77     eAlignViewFlatQueryAnchoredBluntEnds = 6,
 78     /** XML. */
 79     eAlignViewXml                        = 7,
 80     /** Tabular without comments. */
 81     eAlignViewTabular                    = 8,
 82     /** Tabular with per-query comments. */
 83     eAlignViewTabularWithComments        = 9,
 84     /** ASN.1 in text form. */
 85     eAlignViewAsnText                    = 10,
 86     /** ASN.1 in binary form. */
 87     eAlignViewAsnBinary                  = 11,
 88     /** Sentinel value, binding the allowed range. */
 89     eAlignViewMax
 90 } EAlignView;
 91 
 92 
 93 /** Options for formatting BLAST results 
 94  */
 95 typedef struct BlastFormattingOptions {
 96    EAlignView align_view;       /**< How to show alignments? */
 97    Uint4 align_options;         /**< Options for showing alignments. */
 98    Uint4 print_options;         /**< Printing options. */
 99    Boolean believe_query;       /**< Should query defline be trusted? */
100    Boolean html;                /**< Create an HTML output? */
101    Int4 number_of_descriptions; /**< Number of descriptions to show. */
102    Int4 number_of_alignments;   /**< Number of alignments to show. */
103    Boolean is_megablast;        /**< Is this a megablast search? Needed for
104                                    determination of which reference to use. */
105 } BlastFormattingOptions;
106 
107 /** Structure containing all information necessary for producing the
108  * formatted BLAST output. 
109  */
110 typedef struct BlastFormattingInfo { 
111     const SBlastOptions* search_options; /**< Search options. */
112     char* program_name;          /**< Program name as a sting. */
113     char* db_name;               /**< Database name. Null for a 2 sequences 
114                                     search. */
115     int num_formatted;           /**< Number of queries formatted so far. */
116     BlastFormattingOptions* format_options; /**< Formatting options. */
117     FILE* outfp;                 /**< Output stream for text output. */
118     AsnIo* aip;                  /**< Output stream for ASN.1 output */
119     MBXml* xmlp;                 /**< Output stream for XML output */
120     Boolean is_seqalign_null;    /**< flag indicating absence of seqalign */
121     Boolean head_on_every_query; /**< Flag indicating that reference, db, etc. should appear
122                                       on every entry. */
123 } BlastFormattingInfo;
124 
125 /** Allocates and initializes the formatting information structure.
126  * @param align_view Alignment view option [in]
127  * @param search_options BLAST search options [in]
128  * @param program_name BLAST program name [in]
129  * @param db_name BLAST database name (NULL for non-database search) [in]
130  * @param outfile_name Name of the output file. [in]
131  * @param info_ptr Initialized structure. [out]
132  */
133 Int2 BlastFormattingInfoNew(EAlignView align_view,
134                             const SBlastOptions* search_options,
135                             const char* program_name, const char* db_name, 
136                             const char* outfile_name, 
137                             BlastFormattingInfo* *info_ptr);
138 
139 /** Allocate and initialize the formatting information structure, given the 
140  * basic two sequences search options.
141  * @param align_view What kind of formatted output to show? [in]
142  * @param basic_options Basic two sequences search options [in]
143  * @param query_seqloc Query Seq-loc [in]
144  * @param outfile_name Name of the output file [in]
145  * @param advanced_options Advanced BLAST search options structure. Must be 
146  *                         returned to avoid memory leak. [out]
147  * @param info_ptr The initialized formatting info structure [out]
148 */
149 Int2 BlastFormattingInfoNewBasic(EAlignView align_view, 
150                                  const BLAST_SummaryOptions* basic_options,
151                                  SeqLoc* query_seqloc,
152                                  const char* outfile_name, 
153                                  SBlastOptions* *advanced_options,
154                                  BlastFormattingInfo* *info_ptr);
155 
156 /** Fill the formatting options in the formatting info structure.
157  * @param info The structure to work with [in]
158  * @param num_descriptions Number of descriptions to show in the formatted
159  *                         output. [in]
160  * @param num_alignments Number of alignments to show in the formatted
161  *                       output. [in]
162  * @param html Format with HTML tags or in plain text? [in]
163  * @param is_megablast Is this a megablast search, needed for correct 
164  *                     reference? [in]
165  * @param show_gi Should gis be shown in database sequence descriptions? [in]
166  * @param believe_defline Should query def-lines be parsed? [in]
167  */ 
168 void 
169 BlastFormattingInfoSetUpOptions(BlastFormattingInfo* info, Int4 num_descriptions,
170                                 Int4 num_alignments, Boolean html, 
171                                 Boolean is_megablast, Boolean show_gi,
172                                 Boolean believe_defline);
173 
174 /** Deallocates the formatting information structure. In particular, closes the
175  * output stream(s).
176  * @param info The structure to free. [in]
177  */
178 BlastFormattingInfo* BlastFormattingInfoFree(BlastFormattingInfo* info);
179 
180 /** Print formatted output.
181  * @param seqalign_arr object with arrays of seqaligns [in]
182  * @param num_queries Number of query sequences [in]
183  * @param query_slp Linked list of query SeqLocs [in]
184  * @param mask_loc Masking locations for all queries [in]
185  * @param format_info Formatting options and other information [in]
186  * @param sum_returns Summary data returned from the search. [in]
187  */
188 Int2 BLAST_FormatResults(SBlastSeqalignArray* seqalign_arr, Int4 num_queries, 
189                          SeqLocPtr query_slp, SeqLoc* mask_loc, 
190                          BlastFormattingInfo* format_info,
191                          Blast_SummaryReturn* sum_returns);
192 
193 /** Print the summary at the end of the BLAST report.
194  * @param format_info Formatting options and other information. [in]
195  * @param sum_returns infor from inside blast engine [in]
196  */
197 Int2 Blast_PrintOutputFooter(const BlastFormattingInfo* format_info, 
198                              const Blast_SummaryReturn* sum_returns);
199 
200 /** Prints the top part of the traditional BLAST output, including version, 
201  * reference(s) and database information.
202  * @param format_info Formatting options and other information [in]
203  */
204 Int2 BLAST_PrintOutputHeader(const BlastFormattingInfo* format_info);
205 
206 /** Prints the "log info" at the bottom of the megablast output, looks something
207  * like:
208  * "Mega BLAST run finished, processed 2 queries"
209  *
210  * @param outfp output file pointer [in]
211  * @param num_processed number of records proceessed [in]
212  *                    stream pointer. [in]
213  * @return 0 on success 
214  */
215 Int2 BlastPrintLogReport(FILE* outfp, Int4 num_processed);
216 
217 /** Given a Seq-id structure, returns a buffer in requested form.
218  * @param sip Seq-id to get information from. [in]
219  * @param buffer_ptr Buffer to fill. [out]
220  * @param ncbi_gi Should the NCBI gi be included in the id buffer? [in]
221  * @param accession_only Should only accession be returned (only gi if ncbi_gi
222  *                       is TRUE)? [in]
223  * @param search_for_id If TRUE, attempt to find a sequence identifier.
224  *                  If FALSE, the first token in the defline is treated
225  *                  as an identifier, even if it is not an actual ID [in]
226  */
227 void 
228 Blast_SeqIdGetDefLine(SeqIdPtr sip, char** buffer_ptr, Boolean ncbi_gi, 
229                       Boolean accession_only, Boolean search_for_id);
230 
231 /** Posts an error message from the summary returns, if any, to a provided
232  * output stream. If no stream provided, nothing is written. 
233  * @param sum_return Summary returns structure. [in]
234  */
235 Int2 
236 Blast_SummaryReturnsPostError(Blast_SummaryReturn* sum_return);
237 
238 /** Format the PHI BLAST report.
239  * @param phivnps List of ValNode's, containing PHI BLAST Seq-aligns 
240  *                corresponding to different pattern occurrences in query. [in]
241  * @param query_slp Query Seq-loc [in]
242  * @param format_info Formatting information structure [in]
243  * @param sum_returns Search summary returns [in]
244  */
245 Int2 PHIBlastFormatResults(ValNode* phivnps, SeqLocPtr query_slp,
246                            const BlastFormattingInfo* format_info, 
247                            Blast_SummaryReturn* sum_returns);
248 
249 /** Frees a chain of ValNode's containing PHI BLAST results.
250  * @param phivnps Head of chain to be freed. [in]
251  * @return NULL.
252  */
253 ValNode* PHIBlastResultsFree(ValNode* phivnps);
254 
255 /** Returns the integer alignment type value used in the C toolkit 
256  * formatting code, given the EBlastProgramType enumeration value.
257  * @param prog The BLAST program enumeration value [in]
258  * @param db_is_na Is database nucleotide or protein for this program? [out]
259  * @return Integer alignment type for use in old formatting code.
260  */      
261 Uint1 
262 GetOldAlignType(EBlastProgramType prog, Boolean* db_is_na);
263 
264 /* @} */
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif /* !__BLAST_FORMAT__ */
271 
272 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.