1 /* $Id: txalign.h,v 6.21 2006/07/13 17:06:39 bollin 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:  $RCSfile: txalign.h,v $
27 *
28 * Author:  Jinghui Zhang
29 *
30 * Initial Version Creation Date: 03/13/94
31 *
32 * $Revision: 6.21 $
33 *
34 * File Description:
35 *         External include file for various alignments
36 * Revision 5.13  1997/06/05 20:55:34  madden
37  * Added PrintDefLinesFromSeqAlign prototype
38 *
39 *
40 * $Log: txalign.h,v $
41 * Revision 6.21  2006/07/13 17:06:39  bollin
42 * use Uint4 instead of Uint2 for itemID values
43 * removed unused variables
44 * resolved compiler warnings
45 *
46 * Revision 6.20  2006/05/30 13:50:48  kans
47 * set define to include BlastDefLineSet* functions in fdlobj.h
48 *
49 * Revision 6.19  2004/08/16 19:36:52  dondosha
50 * Made CreateMaskByteStore function public: needed by web BLAST 2 sequences
51 *
52 * Revision 6.18  2004/06/24 21:15:44  dondosha
53 * Changed last Boolean argument in ScoreAndEvalueToBuffers to Uint1, to allow different options for formatting
54 *
55 * Revision 6.17  2004/05/14 15:38:09  dondosha
56 * Made function ScoreAndEvalueToBuffers public
57 *
58 * Revision 6.16  2003/11/20 22:09:26  dondosha
59 * Added a PrindDefLinesFromSeqAlignWithPath function with an argument to provide root path for image links
60 *
61 * Revision 6.15  2002/12/11 16:24:51  jianye
62 * added structure linkout
63 *
64 * Revision 6.14  2002/10/17 16:57:50  jianye
65 * added option for get sequence feature
66 *
67 * Revision 6.13  2002/03/26 23:26:38  dondosha
68 * Added a possibility of a link to Blast 2 sequences from megablast output
69 *
70 * Revision 6.12  2002/02/15 14:18:24  camacho
71 * Added RDBTaxNamesClone function
72 *
73 * Revision 6.11  2002/02/01 20:04:57  jianye
74 * Fixed getting wrong blast defline struct for non-redundant bioseq and adding utility function getBlastDefLineForSeqId(bdlp, sip)
75 *
76 * Revision 6.10  2002/01/24 18:47:49  camacho
77 * Moved RDBTaxNamesFree from readdb.[ch] to txalign.[ch]
78 *
79 * Revision 6.9  2002/01/23 19:32:25  jianye
80 * Added checkLinkoutType()
81 *
82 * Revision 6.8  2002/01/23 17:54:50  jianye
83 * Added SHOW_LINKOUT def
84 *
85 * Revision 6.7  2001/07/23 20:20:12  dondosha
86 * Made replace_bytestore_data function public for use in web blast2seq
87 *
88 * Revision 6.6  2001/06/21 19:42:18  shavirin
89 * Moved here definitions related to Taxonomy names.
90 *
91 * Revision 6.5  2001/06/21 18:26:27  shavirin
92 * Moved here functions to get Taxonomy names information encoded in
93 * the Bioseq returned from the Blast database.
94 *
95 * Revision 6.4  2001/05/15 17:18:26  egorov
96 * Added txalign_options to AlignStatOption structure
97 *
98 * Revision 6.3  2001/03/23 17:24:44  madden
99 * Add FDGetDeflineAsnFromBioseq from readdb.[ch]
100 *
101 * Revision 6.2  2000/12/14 17:08:53  shavirin
102 * Added additinal label "<name=" for the single alignment. This link will
103 * be shown only in Human Genome viewer.
104 *
105 * Revision 6.1  2000/11/16 22:20:16  shavirin
106 * File moved to distrib/tools from distrib/api .
107 *
108 * Revision 6.28  2000/10/06 17:55:46  shavirin
109 * Added usage of correct matrix in OOF case.
110 *
111 * Revision 6.27  2000/07/11 20:51:06  shavirin
112 * Added major functions for displaying Out-Of-Frame alignments.
113 *
114 * Revision 6.26  2000/07/10 20:45:54  shavirin
115 * Added parameter ooframe for Out-Of-frame alignment and corresponding changes
116 * to accomodate this parameter.
117 *
118 * Revision 6.25  2000/06/09 19:00:06  shavirin
119 * Function GetGeneticCodeFromSeqId() made external and added to header file.
120 *
121 * Revision 6.24  2000/06/08 20:44:50  shavirin
122 * Added calculation of start/stop values in the function find_score_in_align().
123 *
124 * Revision 6.23  2000/03/07 21:58:41  shavirin
125 * Now will use PSSM Matrix to show positives in PSI Blast
126 *
127 * Revision 6.22  1999/11/24 21:24:33  vakatov
128 * Fixed for the C++ and/or MSVC DLL compilation
129 *
130 * Revision 6.21  1999/11/09 22:15:08  shavirin
131 * Added parameter follower to the Blast score printing function
132 *
133 * Revision 6.20  1999/10/07 16:08:05  shavirin
134 * Passed matrix to the function FormatScoreFromSeqAlign().
135 *
136 * Revision 6.19  1999/09/29 17:15:38  shavirin
137 * Added new funtion FormatScoreFromSeqAlign()
138 *
139 * Revision 6.18  1999/06/07 18:43:17  madden
140 * added TXALIGN_NO_DUMPGNL if dumpgnl is not desired
141 *
142 * Revision 6.17  1999/04/15 20:57:23  madden
143 * overview printing for vector stuff
144 *
145 * Revision 6.16  1999/04/06 15:13:25  madden
146 * Add support for non-gnl queries with dumpgnl syntax
147 *
148 * Revision 6.15  1999/02/26 21:28:06  victorov
149 * taking different sections of config file depending on WWW_BLAST_TYPE
150 *
151 * Revision 6.14  1999/02/19 20:51:07  victorov
152 * changed URL to the tool reporting incomplete
153 * sequences. URL now includes starts/stops for all hits
154 *
155 * Revision 6.13  1999/01/13 21:52:43  victorov
156 * added links to incomplete genomes in hit details
157 *
158 * Revision 6.12  1999/01/06 22:51:00  victorov
159 * added hyperlinks for incomplete sequences
160 *
161 * Revision 6.11  1999/01/05 14:52:04  madden
162 * Add frame and strand information
163 *
164 * Revision 6.10  1998/11/09 19:06:47  vakatov
165 * Added "NLM_EXTERN" to the ShowTextAlignFromAnnotExtra() prototype
166 *
167 * Revision 6.9  1998/09/01 13:27:02  madden
168 * PrintDefLinesExtra function
169 *
170 * Revision 6.8  1998/08/26 21:32:23  madden
171 * Added ShowTextAlignFromAnnotExtra for PHI-BLAST
172 *
173 * Revision 6.7  1998/07/23 13:35:29  egorov
174 * Allow print specified number of descriptions in PrintDefLinesFromSeqAlign()
175 *
176 * Revision 6.6  1998/07/02 21:22:56  madden
177 * Changes for random-access BLAST
178 *
179 * Revision 6.5  1998/03/25 22:38:50  egorov
180 * Change prototypes for PrintDefLinesFromAnnot and PrintDefLinesFromSeqAlign
181 *
182 * Revision 6.4  1997/10/06 14:01:11  zjing
183 * move TxGetSubjectId, GetScoreAndEvalue to sequtil.ch
184 *
185 * Revision 6.3  1997/09/25 17:17:37  zjing
186 * Add the option for showing blunt-end alignment
187 *
188 * Revision 6.2  1997/09/25 02:00:27  vakatov
189 * Added NLM_EXTERN specifier to some functions(necessary for MS-Win DLLs)
190 *
191 * Revision 6.1  1997/09/18 22:24:23  madden
192 * Made TxGetSubjectIdFromSeqAlign public
193 *
194 * Revision 6.0  1997/08/25 18:08:14  madden
195 * Revision changed to 6.0
196 *
197 * Revision 5.20  1997/08/14 17:55:49  zjing
198 * minor changes
199 *
200 * Revision 5.18  1997/07/28 13:55:46  madden
201 * Added mask_loc to prototypes.
202 *
203 * Revision 5.17  1997/07/11 15:28:13  madden
204 * Added TXALIGN_HTML_RELATIVE define
205 *
206 * Revision 5.16  1997/07/07 20:22:26  madden
207 * changes to show the results as query-subect
208 *
209 * Revision 5.15  1997/06/19 18:39:42  vakatov
210 * [WIN32,MSVC++]  Adopted for the "NCBIOBJ.LIB" DLL'ization
211 *
212 * Revision 5.14  1997/06/09 21:47:25  madden
213 * Added Boolean follower to AlignStatOptions
214 *
215  * Revision 5.12  1997/03/13  21:43:13  shavirin
216  * Added protection for C++ compiler
217  *
218 *
219 * ==========================================================================
220 */
221 #ifndef _TXALIGN_
222 #define _TXALIGN_
223 
224 /****************************************************************************/
225 /* INCLUDES */
226 /****************************************************************************/
227 
228 #include <jzcoll.h>
229 #include <ffprint.h>
230 
231 /* This define should be added to include BlastDefLineSet* functions in fdlobj.h */
232 #ifndef NLM_GENERATED_CODE_PROTO
233 #define NLM_GENERATED_CODE_PROTO
234 #endif
235 
236 #include <fdlobj.h>
237 
238 /****************************************************************************/
239 /* DEFINES */
240 /****************************************************************************/
241 
242 #define WEBB_asize 23		/* webb's matrix */
243 #define TX_MATRIX_SIZE 128	/*size of the matrix for showing the
244                                   text alignment*/
245 
246 #define TXALIGN_LOCUS_NAME	((Uint4)0x00000100)	/*display the locus name*/
247 #define TXALIGN_MASTER		((Uint4)0x00000002)	/*display the alignment as multiple pairwise alignment*/
248 #define TXALIGN_MISMATCH	((Uint4)0x00000004)	/*display the mismatched residue of the sequence */
249 #define TXALIGN_MATRIX_VAL	((Uint4)0x00000008)	/*display the matrix of the alignment */
250 #define TXALIGN_HTML		((Uint4)0x00000010)	/*display the format in a HTML page*/
251 #define TXALIGN_HTML_RELATIVE	((Uint4)0x00002000)	/*the HTML (if enabled by TXALIGN_HTML) should be relative*/
252 #define TXALIGN_SHOW_RULER	((Uint4)0x00000020)	/*display the ruler for the text alignment*/
253 #define TXALIGN_COMPRESS	((Uint4)0x00000040)	/*make the space for label smaller*/
254 #define TXALIGN_END_NUM		((Uint4)0x00000080)	/*show the number at the end */
255 #define TXALIGN_FLAT_INS	((Uint4)0x00000001)	/*flat the insertions in multiple pairwise alignment */
256 #define TXALIGN_SHOW_GI         ((Uint4)0x00000200)    /*show the gi in the defline. */
257 #define TXALIGN_SHOW_NO_OF_SEGS ((Uint4)0x00000400)    /*show the number of (sum statistics) segments in the one-line descriptions? */
258 
259 #define TXALIGN_BLASTX_SPECIAL  ((Uint4)0x00000800)	/*display the BLASTX results
260 						  as protein alignment */
261 #define	TXALIGN_SHOW_QS		((Uint4)0x00001000)	/*show the results as query-subect*/
262 #define TXALIGN_SPLIT_ANNOT	((Uint4)0x00004000)	/*for Seq-annot from the same alignment, split the
263 												the display into individual panel*/
264 #define TXALIGN_SHOW_STRAND	((Uint4)0x00008000)	/*for displaying the stradn even in the compact form*/
265 #define TXALIGN_BLUNT_END	((Uint4)0x00010000)	/*showing the blunt-end for the end gaps*/
266 #define TXALIGN_DO_NOT_PRINT_TITLE	((Uint4)0x00020000)	/* do not print title before list of deflines */
267 #define TXALIGN_CHECK_BOX	((Uint4)0x00040000)	/* place checkbox before the line (HTML only) */
268 #define TXALIGN_CHECK_BOX_CHECKED	((Uint4)0x00080000)	/* make default value for checkboxes ON (HTML only) */
269 #define TXALIGN_NEW_GIF		((Uint4)0x00100000)	/* print new.gif near new alignments (HTML only) */
270 #define TXALIGN_NO_ENTREZ	((Uint4)0x00200000)	/* Use dumpgnl syntax instead of ENTREZ. */
271 #define TXALIGN_NO_DUMPGNL	((Uint4)0x00400000)	/* No dumpgnl output, even if GNL. */
272 #define TXALIGN_TARGET_IN_LINKS	((Uint4)0x00800000)	/* Put TARGET in Entrez links */
273 #define TXALIGN_SHOW_LINKOUT ((Uint4)0x01000000)        /*print linkout info*/
274 #define TXALIGN_BL2SEQ_LINK ((Uint4) 0x02000000)        /* Add link to Blast 2 Sequences */
275 #define TXALIGN_GET_SEQUENCE ((Uint4)0x04000000)        /*get sequence ability*/
276 
277 
278 
279 /*
280 	Used by psi-blast to distinguish first from subsequent passes.
281 */
282 
283 #define FIRST_PASS 1
284 #define NOT_FIRST_PASS_REPEATS 2
285 #define NOT_FIRST_PASS_NEW  3
286 
287 #define ASN_DEFLINE_OBJ_LABEL "ASN1_BlastDefLine"
288 #define TAX_DATA_OBJ_LABEL    "TaxNamesData"
289 
290 /* Bit meanings in membership element of ASN.1 structured
291    definition lines */
292 #define EST_HUMAN_BIT 0x1
293 #define EST_MOUSE_BIT 0x2
294 #define SWISSPROT_BIT 0x4
295 #define PDB_BIT       0x8
296 #define REFSEQ_BIT    0x10
297 #define CONTIG_BIT    0x20
298 
299 #define NUM_TAX_NAMES 4
300 #define SCI_NAME_POS    0
301 #define COMMON_NAME_POS 1
302 #define BLAST_NAME_POS  2
303 #define S_KING_POS      3
304 
305 
306 
307 /* ---------------------------------------------------------------------*/
308 /* -- Here is set of definitions used with taxonomy info database ----- */
309 /* ---------------------------------------------------------------------*/
310 typedef	struct _RDBTaxNames {
311     Int4 tax_id;
312     CharPtr sci_name;
313     CharPtr common_name;
314     CharPtr blast_name;
315     Char  s_king[3];
316 } RDBTaxNames, *RDBTaxNamesPtr;
317 
318 void RDBTaxNamesFree(RDBTaxNamesPtr tnames);
319 RDBTaxNamesPtr RDBTaxNamesClone(RDBTaxNamesPtr orig);
320 
321 /****************************************************************************/
322 /* TYPEDEFS */
323 /****************************************************************************/
324 
325 typedef struct text_buf{	/*for a generic feature comment*/
326 	Int4 pos;	        /*position for label*/
327 	Uint1 strand;	        /*the orientation*/
328 	CharPtr label;	        /*label for the feature*/
329 	CharPtr buf;	   /*the buffer for features other than cds for aa*/
330 	Int2Ptr matrix_val;	/*the value of each residue from the matrix */
331 	CharPtr codon[3];	/*for features such as cds for aa*/
332 	Int2 frame;	        /*for cds for feature*/
333 	Int4 f_pos;	        /*position of the current buf*/
334 	Uint2 exonCount;	/*count the number of exons, useded in
335                                   cds for aa*/
336         Uint4 itemID;	/*feature's itemID. It is used to check identity*/
337 	Uint2 feattype;
338 	Uint2 subtype;
339 	Uint2 entityID;
340 	Uint2 seqEntityID;	/*the entityID for the sequence*/
341 	Uint4 bsp_itemID;	/*itemID for the Bioseqs*/
342 	Boolean extra_space;
343 }TextAlignBuf, PNTR TextAlignBufPtr;
344 
345 typedef struct align_summary {
346     Int4 positive;	        /*number of positive residues*/
347     Int4 identical;	        /*number of identical residues*/
348     Int4 gaps;		        /*number of the gaps*/
349     Int4 totlen;	        /*total length of the alignemtns*/
350     Int4Ptr PNTR matrix;	/*matrix for protein alignments*/
351     Int4Ptr PNTR posMatrix;	/*matrix for PSSM protein alignments*/
352     SeqIdPtr master_sip;	/*the Seq-id of the master sequence*/
353     SeqIdPtr target_sip;	/*the Seq-id for the target sequence*/
354     Boolean is_aa;              /*are the sequences nucleotide or protein?*/
355     Uint1 m_strand,	        /* strand of the query. */
356           t_strand;	        /* strand of the database sequence. */
357     Int4  m_frame,	        /* Frame of the query. */
358         t_frame;	        /* Frame of the database sequence. */
359     Boolean	m_frame_set,	/* query frame was set. */
360         t_frame_set;	        /* database sequence frame was set. */
361     Int4 master_from;           /* from for master sequence */
362     Int4 master_to;             /* to for master sequence */
363     Int4 target_from;           /* from for target sequence */
364     Int4 target_to;             /* to region for master sequence */
365     Boolean ooframe;            /* Is this out-of-frame alignment ? */
366 }AlignSum, PNTR AlignSumPtr;
367 
368 typedef struct align_stat_option { /*options for printing the statistics*/
369     Int2 line_len;
370     Int2 indent_len;
371     Boolean html_hot_link;			/* Prepare HTML output. */
372     Boolean html_hot_link_relative;		/* Make the HTML link relative. */
373     Boolean show_gi;
374     Boolean no_entrez;			/* Do not use Entrez format for HTML links. */
375     Boolean no_dumpgnl;			/* Do not use dumpgnl format even if GNL. */
376     FILE *fp;
377     CharPtr buf;
378     BioseqPtr bsp;
379     ScorePtr sp;
380     Int4 identical;             /*number of identical residues*/
381     Int4 gaps;		        /*number of the gaps*/
382     Int4 positive;	        /*number of the positive residues*/
383     Int4 align_len;	        /*the length of the alignment. EXCLUDE the GAPS*/
384     Boolean follower;           /* If TRUE, this is NOT the first alignment for this sequences. */
385     Uint1 	m_strand,	/* strand of the query. */
386         t_strand;	        /* strand of the database sequence. */
387     Int2	m_frame,	/* Frame of the query. */
388         t_frame;	        /* Frame of the database sequence. */
389 
390     /* This information was added first only for creation of very
391        specific links to the single alignment. However - may be it will
392        be used later for something else */
393 
394     Int4 master_from;           /* from for master sequence */
395     Int4 master_to;             /* to for master sequence */
396     Int4 target_from;           /* from for target sequence */
397     Int4 target_to;             /* to region for master sequence */
398 
399     CharPtr segs; /* <start> "-" <stop> ("," <start> "-" <stop>)* */
400     CharPtr db_name; /* searched databases list */
401     CharPtr blast_type; /* string used to choose proper config parms */
402     Uint4	txalign_options;/* the TXALIGN_* options */
403 }AlignStatOption, PNTR AlignStatOptionPtr;
404 
405 /****************************************************************************/
406 /* FINCTION DEFINITIONS */
407 /****************************************************************************/
408 
409 #undef NLM_EXTERN
410 #ifdef NLM_IMPORT
411 #define NLM_EXTERN NLM_IMPORT
412 #else
413 #define NLM_EXTERN extern
414 #endif
415 
416 #ifdef __cplusplus
417 extern "C" {
418 #endif
419 
420 /*****************************************************************
421 *
422 *	find_score_in_align(align, chain, asp)
423 *	align: the Seq-align point
424 *	chain: for multiple segment Seq-aligns, such as DenseDiag and
425 *	StdSeg, the order within the Seq-align
426 *	asp:   the structure that records and stores the positive,
427 *			identical residues
428 *	the function only works for DenseDiag and Stdseg for now
429 *
430 *****************************************************************/
431 NLM_EXTERN ScorePtr find_score_in_align PROTO((SeqAlignPtr align,
432                                                Uint2 chain, AlignSumPtr asp));
433 
434 /*the default formatting function for printing the scores*/
435 
436 NLM_EXTERN int LIBCALLBACK FormatScoreFunc PROTO((AlignStatOptionPtr asop));
437 
438 /**********************************************************************************
439 *
440 *       Given a chain of annots (ValNodePtrs) they are all printed out, one pattern
441 *       at a time.
442 *
443 *************************************************************************************/
444 
445 NLM_EXTERN Boolean LIBCALL ShowTextAlignFromAnnotExtra PROTO((BioseqPtr bsp, ValNodePtr vnp, SeqLocPtr seqloc,
446         Int4 line_len, FILE *fp,
447         Uint1Ptr featureOrder, Uint1Ptr groupOrder, Uint4 option, Int4Ptr PNTR matrix,
448         ValNodePtr mask_loc, int (LIBCALLBACK *fmt_score_func)PROTO((AlignStatOptionPtr))));
449 
450 /*****************************************************************************
451 *
452 *	ShowTextAlignFromAnnot(annot, locus, line_len, fp, master, f_order)
453 *	display the alignment stored in a Seq-annot in a text file
454 *	annot: the Seq-annot pointer
455 *	locus: if TRUE, show the locus name as the sequence label, otherwise,
456 *		use the accession
457 *	line_len: the number of sequence char per line
458 *	fp: The file pointer to store the text output
459 *	master: if TRUE, show the result as a master-slave type multiple pair
460 *	wise alignment. if FALSE, display one alignment after the other
461 *	f_order: the user selected feature type and order to be shown together
462 *	with the alignment
463 *	return TRUE for success, FALSE for fail
464 *
465 *****************************************************************************/
466 NLM_EXTERN Boolean ShowTextAlignFromAnnot PROTO((
467                     SeqAnnotPtr hannot, Int4 line_len,
468                     FILE *fp, Uint1Ptr featureOrder,
469                     Uint1Ptr groupOrder, Uint4 option,
470                     Int4Ptr PNTR matrix, ValNodePtr mask_loc,
471                     int (LIBCALLBACK *fmt_score_func)
472                     PROTO((AlignStatOptionPtr))
473                     ));
474 /**
475  * same as ShowTextAlignFromAnnot
476  * the db_name argument is used to make links to
477  * incomplete genomes
478  */
479 NLM_EXTERN Boolean ShowTextAlignFromAnnot2 PROTO((
480                     SeqAnnotPtr hannot, Int4 line_len,
481                     FILE *fp, Uint1Ptr featureOrder,
482                     Uint1Ptr groupOrder, Uint4 option,
483                     Int4Ptr PNTR matrix, ValNodePtr mask_loc,
484                     int (LIBCALLBACK *fmt_score_func)
485                     PROTO((AlignStatOptionPtr)),
486                     CharPtr db_name,
487                     CharPtr blast_type
488                     ));
489 /**
490  * same as ShowTextAlignFromAnnot
491  * the posMatrix used to show alignments using PSSM
492  */
493 NLM_EXTERN Boolean ShowTextAlignFromAnnot3 PROTO((
494                     SeqAnnotPtr hannot, Int4 line_len,
495                     FILE *fp, Uint1Ptr featureOrder,
496                     Uint1Ptr groupOrder, Uint4 option,
497                     Int4Ptr PNTR matrix, ValNodePtr mask_loc,
498                     int (LIBCALLBACK *fmt_score_func)
499                     PROTO((AlignStatOptionPtr)),
500                     CharPtr db_name,
501                     CharPtr blast_type,
502                     Int4Ptr PNTR posMatrix
503                     ));
504 /* Simple printing function:
505    Can be used while debugging.. options kept to a minimum
506    fp==NULL ==> stdout
507 */
508 NLM_EXTERN void LIBCALL SeqAlignPrint(SeqAlignPtr salp,FILE* fp);
509 
510 /***********************************************************************
511 *
512 *	ShowAlignNodeText(anp_list, num_node, line_len, locus,
513 *	fp)
514 *	convert the alignment data in the list of AlignNode into text written
515 *	to a file
516 *	anp_list: a list (ValNodePtr) of AlignNode processed from Seq-aligns
517 *	num_node: the number of AlignNode to be processed currently. It can
518 *	be used in the cases where only the top num_node in the anp_list is
519 *	going to be processed. This can be useful to make vertically cashed
520 *	buffer
521 *	line_len: the length of sequence char per line
522 *	locus: if TRUE, show the locus name
523 *	fp: the file Pointer
524 *	left: the leftmost position for display
525 *	right: the rightmost position for display
526 *	align_type:	the type of alignment. DNA-protein alignment?
527 *
528 *	return TRUE for success, FALSE for fail
529 *
530 ************************************************************************/
531 
532 NLM_EXTERN Boolean ShowAlignNodeText PROTO((
533                      ValNodePtr anp_list, Int2 num_node,
534                      Int4 line_len, FILE *fp, Int4 left,
535                      Int4 right, Uint4 option,
536                      Int4Ptr PNTR u_matrix,
537                      int (LIBCALLBACK *fmt_score_func)
538                      PROTO((AlignStatOptionPtr))
539                      ));
540 
541 NLM_EXTERN Boolean ShowAlignNodeText2 PROTO((
542                      ValNodePtr anp_list, Int2 num_node,
543                      Int4 line_len, FILE *fp, Int4 left,
544                      Int4 right, Uint4 option,
545                      Int4Ptr PNTR u_matrix,
546                      int (LIBCALLBACK *fmt_score_func)
547                      PROTO((AlignStatOptionPtr)),
548                      CharPtr db_name,
549                      CharPtr blast_type,
550                      Int4Ptr PNTR posMatrix
551                      ));
552 
553 /*
554   Print a summary of the Sequences producing significant alignments.
555 */
556 
557 NLM_EXTERN Boolean LIBCALL PrintDefLinesExtra PROTO((
558 		ValNodePtr vnp, Int4 line_length, FILE *outfp, Uint4 options,
559 		Int4 mode, Int2Ptr marks, SeqLocPtr seqloc));
560 
561 
562 NLM_EXTERN Boolean LIBCALL PrintDefLinesFromAnnot PROTO((
563                     SeqAnnotPtr seqannot,
564                     Int4 line_length, FILE *fp,
565                     Uint4 options, Int4 mode,
566                     Int2Ptr marks
567                     ));
568 
569 NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlign PROTO((
570                     SeqAlignPtr seqalign,
571                     Int4 line_length, FILE *fp,
572                     Uint4 options, Int4 mode,
573                     Int2Ptr marks
574                     ));
575 
576 NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlignEx PROTO((
577 		    SeqAlignPtr seqalign,
578 		    Int4 line_length,
579 		    FILE *outfp,
580 		    Uint4 options,
581 		    Int4 mode,
582 		    Int2Ptr marks,
583 		    Int4 number_of_descriptions
584 		    ));
585 
586 NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlignEx2 PROTO((
587 		    SeqAlignPtr seqalign,
588 		    Int4 line_length,
589 		    FILE *outfp,
590 		    Uint4 options,
591 		    Int4 mode,
592 		    Int2Ptr marks,
593 		    Int4 number_of_descriptions,
594 		    CharPtr db_name,
595 		    CharPtr blast_type
596 		    ));
597 
598 NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlignWithPath PROTO((
599 		    SeqAlignPtr seqalign,
600 		    Int4 line_length,
601 		    FILE *outfp,
602 		    Uint4 options,
603 		    Int4 mode,
604 		    Int2Ptr marks,
605 		    Int4 number_of_descriptions,
606 		    CharPtr db_name,
607 		    CharPtr blast_type,
608                     CharPtr www_root_path
609 		    ));
610 
611 
612 #define TX_KNOCK_OFF_ALLOWED 0x01
613 #define TX_INTEGER_BIT_SCORE 0x02
614 
615 NLM_EXTERN void LIBCALL
616 ScoreAndEvalueToBuffers PROTO((FloatHi bit_score, FloatHi evalue,
617                         CharPtr bit_score_buf, CharPtr PNTR evalue_buf,
618                         Uint1 format_options));
619 
620 /*
621 	Fills in the slots with score, bit_score, etc. from the SeqAlign.
622 */
623 
624 /*options for display of the text alignment*/
625 #define TEXT_MP_MISMATCH	1	/*multiple pairwise alignment with mismatch*/
626 #define TEXT_MP			2	/*multiple pairwise without mismatch*/
627 #define TEXT_MPFLAT_MISMATCH	3	/*flat multile with mismatch*/
628 #define TEXT_MPFLAT		4	/*flat multiple without mismatch*/
629 #define TEXT_BLAST		5	/*traditional blast output*/
630 
631 
632 /*can the current alignnode be printed for text view*/
633 NLM_EXTERN Boolean PrintAlignForText PROTO((AnnotInfoPtr info, AlignNodePtr anp));
634 
635 /*
636 *
637 *	determine the option for alignment based on the named tx_option
638 *
639 */
640 NLM_EXTERN Uint4 GetTxAlignOptionValue PROTO((Uint1 tx_option, BoolPtr hide_feature,
641 	BoolPtr print_score, BoolPtr split_display));
642 
643 /*
644         Gets the SeqIdPtr for the subject sequence from the first SeqAlign.
645         The SeqIdPtr is not saved  and should not be deleted.
646 */
647 
648 /* Marks structure is used for PSI Blast to print .gif marsk
649    near alignments and to check for convergence */
650 
651 #define	SEQ_ALIGN_MARK_PREVGOOD		1
652 #define	SEQ_ALIGN_MARK_PREVCHECKED	2
653 /* the following serves only for old stuff which uses posRepeat... */
654 #define	SEQ_ALIGN_MARK_REPEAT		4
655 
656 
657 typedef struct MarkSeqAlign {
658     Int4		kind;	/* bitmask for the mark */
659     struct MarkSeqAlign	*next;
660 } MarkSeqAlign, PNTR MarkSeqAlignPtr;
661 
662 
663 NLM_EXTERN Boolean LIBCALL FilterTheDefline PROTO((BioseqPtr bsp, SeqIdPtr gi_list_head, CharPtr buffer_id, Int4 buffer_id_length, CharPtr PNTR titlepp));
664 
665 NLM_EXTERN Boolean FormatScoreFromSeqAlign
666 (SeqAlignPtr sap, Uint4 option, FILE *fp,
667 Int4Ptr PNTR matrix, Boolean follower);
668 
669 NLM_EXTERN SeqFeatPtr make_fake_cds(BioseqPtr m_bsp, Int4 start, Int4 stop, Uint1 strand);
670 
671 /*
672   Obtains the genetic code from a BioseqPtr, assuming that a fetch function
673   has been enabled.
674 */
675 NLM_EXTERN CharPtr GetGeneticCodeFromSeqId (SeqIdPtr sip);
676 
677 /*
678    Translate DNA sequence in all frames and create protein
679    sequence for Out-Of-Frame gap algorithm
680 */
681 NLM_EXTERN CharPtr OOFTranslateDNAInAllFrames(Uint1Ptr dna, Int4 length,
682                                               SeqIdPtr query_id);
683 
684 /*************************************************************************
685 
686   Function : OOFShowBlastAlignment();
687 
688   Purpose : function to display a BLAST output with Out-of-Frame
689             information
690 
691   Parameters : 	sap; seqalign
692                 mask; list of masked regions in the query
693                 fp; output file;
694                 tx_option; some display options
695 
696   Return value : FALSE if failure
697 
698 ***************************************************************************/
699 NLM_EXTERN Boolean OOFShowBlastAlignment(SeqAlignPtr sap, ValNodePtr mask,
700                                          FILE *fp, Uint4 tx_option,
701                                          Int4Ptr PNTR matrix);
702 /*
703    Test functions to display Out-of-Frame traceback
704 */
705 NLM_EXTERN void OOFDisplayTraceBack1(Int4Ptr a, CharPtr dna,
706                                      CharPtr pro, Int4 ld, Int4 lp,
707                                      Int4 q_start, Int4 p_start);
708 NLM_EXTERN void OOFDisplayTraceBack2(Int4Ptr a, CharPtr dna, CharPtr pro,
709                                      Int4 ld, Int4 lp,
710                                      Int4 q_start, Int4 p_start);
711 
712 BlastDefLinePtr FDGetDeflineAsnFromBioseq(BioseqPtr bsp);
713 RDBTaxNamesPtr FDGetTaxNamesFromBioseq(BioseqPtr bsp, Int4 taxid);
714 
715 NLM_EXTERN Boolean replace_bytestore_data PROTO((BioseqPtr bsp, ValNodePtr bs_list, Uint1 frame));
716 
717 NLM_EXTERN Boolean checkLinkoutType(BlastDefLinePtr bdfl, Uint1 linkoutType);
718 
719 /* return bdlp containing the sip from a chain of bdlp*/
720 NLM_EXTERN BlastDefLinePtr getBlastDefLineForSeqId(BlastDefLinePtr bdlp, SeqIdPtr sip);
721 Boolean PairwiseSeqAlignHasLinkout(SeqAlignPtr sap, Uint1 linkoutType);
722 
723 ValNodePtr CreateMaskByteStore (ValNodePtr mask_list);
724 
725 #ifdef __cplusplus
726 }
727 #endif
728 
729 #undef NLM_EXTERN
730 #ifdef NLM_EXPORT
731 #define NLM_EXTERN NLM_EXPORT
732 #else
733 #define NLM_EXTERN
734 #endif
735 
736 #endif
737