NCBI C Toolkit Cross Reference

C/api/alignmgr.h


  1 /* ===========================================================================
  2 *
  3 *                            PUBLIC DOMAIN NOTICE
  4 *            National Center for Biotechnology Information (NCBI)
  5 *
  6 *  This software/database is a "United States Government Work" under the
  7 *  terms of the United States Copyright Act.  It was written as part of
  8 *  the author's official duties as a United States Government employee and
  9 *  thus cannot be copyrighted.  This software/database is freely available
 10 *  to the public for use. The National Library of Medicine and the U.S.
 11 *  Government do not place any restriction on its use or reproduction.
 12 *  We would, however, appreciate having the NCBI and the author cited in
 13 *  any work or product based on this material.
 14 *
 15 *  Although all reasonable efforts have been taken to ensure the accuracy
 16 *  and reliability of the software and data, the NLM and the U.S.
 17 *  Government do not and cannot warrant the performance or results that
 18 *  may be obtained by using this software or data. The NLM and the U.S.
 19 *  Government disclaim all warranties, express or implied, including
 20 *  warranties of performance, merchantability or fitness for any particular
 21 *  purpose.
 22 *
 23 * ===========================================================================
 24 *
 25 * File Name:  alignmgr.h
 26 *
 27 * Author:  Sarah Wheelan
 28 *
 29 * Version Creation Date:   7/99
 30 *
 31 * $Revision: 6.72 $
 32 *
 33 * File Description: SeqAlign indexing and messaging functions 
 34 *
 35 * Modifications:
 36 * --------------------------------------------------------------------------
 37 * $Log: alignmgr.h,v $
 38 * Revision 6.72  2001/07/10 11:12:27  wheelan
 39 * added AlnMgrIndexIndexedChain
 40 *
 41 * Revision 6.71  2001/03/08 17:07:11  wheelan
 42 * added AlnMgrGetParent and structure to support it
 43 *
 44 * Revision 6.70  2001/02/16 13:29:49  wheelan
 45 * Added AMFreeAllIndexes
 46 *
 47 * Revision 6.69  2000/09/26 14:23:49  lewisg
 48 * use AlnMgrSortbyID instead of AlnMgrSortSeqAligns
 49 *
 50 * Revision 6.68  2000/09/20 12:18:31  wheelan
 51 * added new field to AM_msms structure
 52 *
 53 * Revision 6.67  2000/09/08 20:34:31  lewisg
 54 * hacks to speed up bioseq to align coord computation
 55 *
 56 * Revision 6.66  2000/08/29 20:12:09  lewisg
 57 * speed up color by alignment
 58 *
 59 * Revision 6.65  2000/08/28 16:18:21  sicotte
 60 * moved AlnMgrSeqAlignMergeTwoPairwiseEx AlnMgrSeqAlignMergeTwoPairwise AlnMgrSeqAlignMergePairwiseSet to actutils.c
 61 *
 62 * Revision 6.64  2000/08/25 19:24:32  sicotte
 63 * Add many functions to deal with merging alignment to go from pairwise sets to a single global (or local) alignment
 64 *
 65 * Revision 6.63  2000/08/18 14:20:51  lewisg
 66 * add startsize field to AMAlignIndex so that lnMgrCopyIndexedParentIntoSap knows how big starts is
 67 *
 68 * Revision 6.62  2000/07/26 17:26:26  lewisg
 69 * fix code for c++ inclusion
 70 *
 71 * Revision 6.61  2000/07/26 14:58:14  sicotte
 72 * bug fixes to AlnMgrGetNextAlnBit. bug fix (overlapping fuzz) in AlnMgrMakeMultipleByScore, Added AlnMgrMakeMultipleByScoreExEx and AlnMgrRemoveInconsistentEx and AlnMgrDeleteHiddenEx to allow optional deletion of sealigns when converting indexes to seqaligns
 73 *
 74 * Revision 6.60  2000/07/25 18:55:54  sicotte
 75 * Added AlnMgrDeleteHiddenEx and AlnMgrRemoveInconsistentFromPairwiseSetEx to make optional deleting of SeqAligns. Needed for Sequence Update
 76 *
 77 * Revision 6.59  2000/07/08 20:43:54  vakatov
 78 * Get all "#include" out of the 'extern "C" { }' scope;  other cleanup...
 79 *
 80 * Revision 6.58  2000/06/01 14:17:55  wheelan
 81 * added AlnMgrCheckOrdered and AlnMgrMakeRowsForOrdered
 82 *
 83 * Revision 6.57  2000/05/24 15:46:27  wheelan
 84 * added AlnMgrRemoveInconsistentFromPairwiseSet and AlnMgrSortAlnSetByNthRowPos
 85 *
 86 * Revision 6.56  2000/05/16 17:14:38  wheelan
 87 * added AlnMgrIsIBMable, AlnMgrIsEditable; made am_guess_numrows extern
 88 *
 89 * Revision 6.55  2000/05/09 14:23:01  wheelan
 90 * added AlnMgrMakeMultipleByScoreEx
 91 *
 92 * Revision 6.54  2000/05/08 13:16:44  wheelan
 93 * added AlnMgrGetNumAlnBlocks and AlnMgrGetNthBlockRange
 94 *
 95 * Revision 6.53  2000/05/05 11:53:53  wheelan
 96 * added comment
 97 *
 98 * Revision 6.52  2000/05/03 19:30:59  wheelan
 99 * added AM_NULL define
100 *
101 * Revision 6.51  2000/05/02 19:50:38  hurwitz
102 * fixed some bugs with launching DDE from DDV, added new alnMgr fn for positioning DDE on proper column
103 *
104 * Revision 6.50  2000/05/02 11:59:51  wheelan
105 * added SASeqDatFree
106 *
107 * Revision 6.49  2000/05/01 12:12:51  wheelan
108 * AlnMgrMapBioseqToSeqAlign now takes Int4 instead of Uint4
109 *
110 * Revision 6.48  2000/04/22 15:53:41  wheelan
111 * added AlnMgrIndexLite
112 *
113 * Revision 6.47  2000/04/10 19:33:27  wheelan
114 * added AlnMgrIsSAPNULL
115 *
116 * Revision 6.46  2000/04/05 17:41:47  wheelan
117 * added AlnMgrAddBlock and AlnMgrReplaceBlock
118 *
119 * Revision 6.45  2000/04/03 12:50:44  wheelan
120 * added AlnMgrGetSubAlignSpecial
121 *
122 * Revision 6.44  2000/03/17 14:25:25  wheelan
123 * changes to AlnMgrGetSubAlign
124 *
125 * Revision 6.43  2000/03/03 19:58:36  wheelan
126 * added AlnMgrDupTopNByScore
127 *
128 * Revision 6.42  2000/02/28 17:18:15  wheelan
129 * Added AlnMgrTossNeatRows for Cn3D
130 *
131 * Revision 6.41  2000/02/23 18:44:21  wheelan
132 * added AlnMgrNeatlyIndex for structure alignments
133 *
134 * Revision 6.40  2000/02/16 15:47:38  wheelan
135 * changed behavior of AlnMgrMakeMultByIntersectOnMaster
136 *
137 * Revision 6.39  2000/02/11 17:30:50  kans
138 * AlnMgrForcePairwiseContinuous moved to tools/actutils (SW)
139 *
140 * Revision 6.38  2000/02/09 20:22:25  wheelan
141 * added structure for AlnMgrDeleteNthRow
142 *
143 * Revision 6.37  2000/02/07 16:14:29  wheelan
144 * added AlnMgrTruncateSAP for structure-based indexing
145 *
146 * Revision 6.36  2000/02/02 14:37:30  wheelan
147 * added AlnMgrGetNthAlignedSegInNthRow and AlnMgrGetNthSegmentRange to make alignment editing easier
148 *
149 * Revision 6.35  2000/01/31 16:08:34  wheelan
150 * added unpacking functions, and AlnMgrMakeMultByIntersectOnMaster (does not work yet
151 *
152 * Revision 6.34  2000/01/29 14:02:12  wheelan
153 * added AlnMgrDeleteHidden and AlnMgrForcePairwiseContinuous
154 *
155 * Revision 6.33  2000/01/12 17:43:20  wheelan
156 * added AlnMgrGetNumSegments, AlnMgrDeleteRow
157 *
158 * Revision 6.32  1999/11/30 14:36:27  wheelan
159 * added AlnMgrMakeMultipleByScore
160 *
161 * Revision 6.31  1999/11/26 15:42:21  vakatov
162 * Fixed for the C++ and/or MSVC DLL compilation
163 *
164 * Revision 6.30  1999/11/18 19:30:24  wheelan
165 * added AlnMgrDeleteChildByPointer
166 *
167 * Revision 6.29  1999/10/25 18:16:44  wheelan
168 * Added AlnMgrGetUniqueSeqs
169 *
170 * Revision 6.28  1999/10/19 19:25:57  wheelan
171 * added is_aligned return to AlnMgrGetNextNthSeqRange; removed static functions; changed structures for AlnMgrMakeSegmentedMasterSlave
172 *
173 * Revision 6.27  1999/10/15 21:51:03  durand
174 * add AlnMgrIsSAPDiscAli()
175 *
176 * Revision 6.26  1999/10/15 15:41:20  wheelan
177 * fixed typo
178 *
179 * Revision 6.25  1999/10/15 15:15:05  wheelan
180 * added defines for AlnMgrGetNthRowTail
181 *
182 * Revision 6.24  1999/10/15 13:48:32  wheelan
183 * added AlnMgrGetNthRowTail
184 *
185 * Revision 6.23  1999/10/14 16:10:31  kans
186 * new includes and prototypes added
187 *
188 * Revision 6.22  1999/10/13 19:28:35  wheelan
189 * added speedup for segmented master-slave creation
190 *
191 * Revision 6.21  1999/10/07 13:37:33  wheelan
192 * added AlnMgrIndexSingleSeqAlign
193 *
194 * Revision 6.20  1999/10/06 19:34:49  wheelan
195 * added several viewer and editor management functions (AlnMgrCopy . . . )
196 *
197 * Revision 6.19  1999/10/05 15:15:18  wheelan
198 * added AlnMgrGetNthUnalignedForNthRow
199 *
200 * Revision 6.18  1999/10/04 14:58:17  wheelan
201 * added AlnMgrMapBioseqToSeqAlign
202 *
203 * Revision 6.17  1999/09/23 16:03:28  wheelan
204 * Added structures and functions to support segmented master-slave alignments
205 *
206 * Revision 6.16  1999/09/22 13:20:04  wheelan
207 * Added AlnMgrGetNextNthSeqRange and structures for segmented master-slave handling
208 *
209 * Revision 6.15  1999/09/21 19:14:15  wheelan
210 * added functions to make segmented master-slave, added fields to AlnMsg and AMAlignIndex structures
211 *
212 * Revision 6.14  1999/09/17 16:55:59  wheelan
213 * added AlnMgrPropagateSeqIdsBySapList
214 *
215 * Revision 6.13  1999/09/13 14:34:13  wheelan
216 * added more functions to support accessing the alignment by row number
217 *
218 * Revision 6.12  1999/09/06 16:37:36  wheelan
219 * added AlnMgrGetNextLengthBit and associated function
220 *
221 * Revision 6.11  1999/09/06 15:51:31  wheelan
222 * added row management functions, new structure for storing row information
223 *
224 * Revision 6.10  1999/09/01 20:12:18  wheelan
225 * added new merge function and the typedef for the structure it uses
226 *
227 * Revision 6.9  1999/09/01 14:38:46  wheelan
228 * added AlnMgrGetStrand
229 *
230 * Revision 6.8  1999/08/30 19:28:52  wheelan
231 * Added AlnMgrGetSapForSip for master-slave alignments
232 *
233 * Revision 6.7  1999/08/26 20:35:54  wheelan
234 * added parent indexing and pairwise-to-multiple functions
235 *
236 * Revision 6.6  1999/08/19 17:24:46  wheelan
237 * changed AMAlignIndex structure, added more api functions
238 *
239 * Revision 6.5  1999/08/12 20:56:57  vakatov
240 * [WIN32] Added missed LIBCALLBACK
241 *
242 * Revision 6.4  1999/08/12 12:41:56  wheelan
243 * added comments, and functions to index the parent
244 *
245 * Revision 6.3  1999/08/06 13:43:48  wheelan
246 * added several api functions; changed all names to AlnMgr..
247 *
248 * Revision 6.2  1999/07/30 14:08:41  wheelan
249 * added api functions to access indexes
250 *
251 * Revision 6.1  1999/07/29 12:56:45  wheelan
252 * initial checkin
253 *
254 
255 * ==========================================================================
256 */
257 
258 #ifndef _ALIGNMGR_
259 #define _ALIGNMGR_
260 
261 #include <ncbi.h>
262 #include <seqmgr.h>
263 #include <salutil.h>
264 #include <sequtil.h>
265 #include <salpedit.h>
266 #include <samutil.h>
267 
268 #undef NLM_EXTERN
269 #ifdef NLM_IMPORT
270 #define NLM_EXTERN NLM_IMPORT
271 #else
272 #define NLM_EXTERN extern
273 #endif
274 
275 #ifdef __cplusplus
276 extern "C" {
277 #endif
278 
279 /* for SAIndex indextype field */
280 #define INDEX_SEGS 1
281 #define INDEX_PARENT 2
282 
283 /* return values for AlnMgrCheckAlignForParent */
284 #define AM_CHILD 1
285 #define AM_PARENT 2
286 
287 /* return values for AlnMgrCheckOverlapping and AlnMgrCheckOrdered */
288 #define AM_NOTORDERED -4
289 #define AM_ORDERED -3
290 #define CHECK_ERROR -2
291 #define NO_OVERLAP -1
292 
293 /* values for amaip->mstype */
294 #define AM_MASTERSLAVE 1
295 #define AM_SEGMENTED_MASTERSLAVE 2
296 #define AM_NEATINDEX 3
297 #define AM_LITE 4
298 #define AM_NULL 5
299 
300 /* values for AlnMgrGetNthRowTail */
301 #define LEFT_TAIL 1
302 #define RIGHT_TAIL 0
303 
304 /* values for AlnMgrIsIBMable and AlnMgrIsEditable */
305 #define AM_ERROR        0
306 #define AM_NOIBM        1
307 #define AM_IBMCHANGE    2
308 #define AM_IBMNOCHANGE  3
309 #define AM_NOEDIT       4
310 #define AM_EDITGAPS     5
311 #define AM_EDITNOGAP    6
312 
313 /***************************************************************************
314 *
315 *  Each child seqalign (segtype SAS_DENSEG) has an SAIndex structure, 
316 *  (in the sap->saip field -- the SAIndex is saip->indextype INDEX_SEGMENT
317 *  and may be accessed by casting the sap->saip pointer to an SAIndexPtr)
318 *  which records the alignment coordinates (each child must be a 
319 *  continuous alignment, so each will have obvious coordinates).  
320 *  The SAIndex structure has an array of SASeqDat structures, one 
321 *  for each "row" of the alignment, and each SASeqDat structure 
322 *  contains an array of Uint2s representing the segment numbers that 
323 *  the sequence in that row participates in (not gapped).
324 *
325 ***************************************************************************/
326 
327 typedef struct saseqdat {
328    Uint2Ptr  sect;
329    Uint2Ptr  unsect;
330    Uint2     numsect;
331    Uint2     numunsect;
332 } SASeqDat, PNTR SASeqDatPtr;
333 
334 typedef struct saindex{
335    Uint1 indextype;
336    SeqAlignIndexFreeFunc freefunc;
337    Uint4Ptr     aligncoords;
338    Int4         master;
339    SASeqDatPtr  PNTR ssdp;
340    Int4         numseqs;
341    SeqAlignPtr  parent;
342 } SAIndex, PNTR SAIndexPtr;
343 
344 NLM_EXTERN SASeqDatPtr SASeqDatNew(void);
345 NLM_EXTERN void SASeqDatFree(SASeqDatPtr ssdp);
346 NLM_EXTERN SAIndexPtr SAIndexNew(void);
347 NLM_EXTERN Boolean SAIndexFree(VoidPtr index);
348 
349 /***************************************************************************
350 *
351 *  Each parent seqalign (segtype SAS_DISC) has an AMAlignIndex structure
352 *  (in the sap->saip field -- the AMAlignIndex is saip->indextype 
353 *  INDEX_PARENT and may be accessed by casting the sap->saip pointer to
354 *  an AMAlignIndexPtr).  The AMAlignIndex has alignment coordinates across
355 *  all children, if possible, or across a subset of the children.  The
356 *  saps field is an array of SeqAlignPtrs, each of which appears in the 
357 *  order that it occurs in the combined alignment -- this means that a given
358 *  pointer may occur more than once.  The AMAlignDatPtr PNTR
359 *  points to an array of AMAlignDat structure, one per bioseq, each of
360 *  which has a sorted list of saps that the bioseq participates in.
361 *
362 ***************************************************************************/
363 typedef struct row_source {
364    SeqIdPtr    id;
365    Uint4Ptr    which_saps;
366    Uint4Ptr    num_in_sap;
367    Uint4       numsaps;
368    Uint1       strand;
369    struct row_source PNTR next;
370 } RowSource, PNTR RowSourcePtr;
371 
372 NLM_EXTERN RowSourcePtr RowSourceNew(void);
373 NLM_EXTERN RowSourcePtr RowSourceFree(RowSourcePtr rsp);
374 
375 typedef struct amaligndat {
376    SeqIdPtr    sip;
377    SeqAlignPtr PNTR saps;
378    Int4        numsaps;
379    Uint2Ptr    segments;
380    Uint2       numseg;
381 } AMAlignDat, PNTR AMAlignDatPtr;
382 
383 typedef struct amalignindex {
384    Uint1 indextype;
385    SeqAlignIndexFreeFunc freefunc;
386    Int2 mstype;
387    Uint4Ptr aligncoords;
388    SeqAlignPtr PNTR  saps;
389    Uint4 numseg;
390    Int4Ptr lens;
391    Int4Ptr ulens;
392    Int4Ptr starts;
393    Int4 startsize;  /* length of the starts field in ints */
394    Int4 alnsaps; /* the number of child seqaligns contained in the multiple */
395    Int4 numsaps; /* the total number of child seqaligns */
396    SeqIdPtr ids;
397    Int4 numbsqs;
398    RowSourcePtr PNTR rowsource;
399    Uint4 numrows;
400    Int4 master; /*tells which row is the master row*/
401    AMAlignDatPtr PNTR amadp;
402    SeqAlignPtr parent;
403 } AMAlignIndex, PNTR AMAlignIndexPtr;
404 
405 NLM_EXTERN AMAlignIndexPtr AMAlignIndexNew(void);
406 NLM_EXTERN Boolean AMAlignIndexFree(VoidPtr index);
407 NLM_EXTERN AMAlignDatPtr AMAlignDatNew(void);
408 NLM_EXTERN AMAlignDatPtr AMAlignDatFree(AMAlignDatPtr amadp);
409 
410 NLM_EXTERN void AMFreeAllIndexes(SeqAlignPtr sap);
411 
412 /***************************************************************************
413 *
414 *  The AlnMsg structure is used by the function AlnMgrGetNextAlnBit.  The
415 *  calling function sets the fields which_master (NULL means alignment
416 *  coordinates), from_m, to_m (in alignment or master coordinates) and
417 *  either which_bsq or row_num (row_num avoids the repeated SeqId problem).  If
418 *  from_m and to_m are not set, the entire alignment is returned.  The function
419 *  fills in the AlnMsg structure and returns TRUE if there are more
420 *  segments of that bioseq in the region requested, FALSE if not. Be sure
421 *  not to set any other field -- many of these are used by the function
422 *  to indicate what has already been returned.  Also, make sure to call
423 *  AlnMsgNew instead of MemNew to allocate a new structure, as a couple of
424 *  fields must be initialized for the function to work correctly.
425 *
426 **************************************************************************/
427 
428 typedef struct messagestruct {
429 /* set by function asking for alignment info */
430    SeqIdPtr  which_master;
431    Int4      from_m;
432    Int4      to_m;
433    SeqIdPtr  which_bsq;
434    Int4      row_num;  /*  1-based numbering  */
435 /* ONLY set by AlnMgrGetNextAlnBit*/
436    Int4      from_b;
437    Int4      to_b;
438    Uint1     gap;
439    Uint1     strand;
440    Int4      prev;
441    Int4      real_from;
442    Int4      prev_sap;
443    Int4      len_left;
444    Boolean   send_space;
445    Uint2     place;
446    Boolean   flag;
447 } AlnMsg, PNTR AlnMsgPtr;
448 
449 NLM_EXTERN AlnMsgPtr AlnMsgNew(void);
450 NLM_EXTERN AlnMsgPtr AlnMsgFree(AlnMsgPtr amp);
451 NLM_EXTERN AlnMsgPtr AlnMsgReNew(AlnMsgPtr amp);
452 
453 /* used by AlnMgrMakeMultSegments */
454 typedef struct am_tinyinfo {
455    Int4   start;
456    Int4   stop;
457    Uint4  numgap;
458    Uint2  which;
459    Int4   numsap;
460    struct am_tinyinfo PNTR next;
461 } AMTinyInfo, PNTR AMTinyInfoPtr;
462 
463 typedef struct am_aligninfo {
464    SeqAlignPtr  align;
465    Int4 align_len;
466 } AMAlignInfo, PNTR AMAlignInfoPtr;
467 
468 typedef struct am_alignkeeper {
469    SeqAlignPtr  align;
470    Boolean      am_delete;
471 } AMAlnKeeper, PNTR AMAlnKeeperPtr;
472 
473 
474 /* used by AlnMgrMakeSegmentedMasterSlave */
475 typedef struct am_msms {
476    Int4         start;
477    Int4         stop;
478    Int4         sstart;
479    Int4         sstop;
480    Uint1        strand;
481    SeqIdPtr     sip;
482    SeqAlignPtr  sap;
483    Int4         nsap;
484    Int4         n;
485    Int4         j;
486    Int4         count;
487    Int4         masternum;
488    struct am_msms PNTR next;
489 } AMmsms, PNTR AMmsmsPtr;
490 
491 typedef struct am_tinymsinfo {
492    Int4       start;
493    AMmsmsPtr  ams;
494 } AMTinyMSInfo, PNTR AMTinyMSInfoPtr;
495 
496 typedef struct am_siplist {
497    SeqIdPtr  sip;
498    Int4      first_row;
499    struct am_siplist PNTR next;
500 } AMsiplist, PNTR AMsiplistPtr;
501 
502 typedef struct am_bittystruct {
503    Int4  num1;
504    Int4  num2;
505    struct am_bittystruct PNTR next;
506 } AMBitty, PNTR AMBittyPtr;
507 
508 NLM_EXTERN SeqAlignIndexPtr SeqAlignIndexNew(void);
509 
510 /********************************************************************************
511 *
512 *  AlnMgrIndexSingleSeqAlign indexes (in place) only the first seqalign or
513 *  seqalign set in the chain that is passed in.  It will extensively
514 *  rearrange the first seqalign given.
515 *
516 ********************************************************************************/
517 NLM_EXTERN Boolean AlnMgrIndexSingleSeqAlign(SeqAlignPtr sap);
518 
519 NLM_EXTERN Boolean AlnMgrIndexSingleChildSeqAlign(SeqAlignPtr sap);
520 
521 /********************************************************************************
522 *
523 *  AlnMgrReIndexSeqAlign frees the parent indexes, indexes any child
524 *  seqaligns that are not indexed (it assumes that any indexed child 
525 *  seqaligns are correctly indexed), and reindexes the set.
526 *
527 ********************************************************************************/
528 NLM_EXTERN Boolean AlnMgrReIndexSeqAlign(SeqAlignPtr sap);
529 
530 /***************************************************************************
531 *
532 *  AlnMgrIndexIndexedChain takes a linked list of indexed seqaligns and
533 *  indexes them as a set.
534 *
535 ***************************************************************************/
536 NLM_EXTERN SeqAlignPtr AlnMgrIndexIndexedChain(SeqAlignPtr sap);
537 
538 /********************************************************************************
539 *
540 *  AlnMgrIndexSeqAlign indexes (in place) the ENTIRE chain of seqaligns
541 *  and seqalign sets passed in, and extensively rearranges the seqalign.   
542 *
543 ********************************************************************************/
544 NLM_EXTERN Boolean AlnMgrIndexSeqAlign(SeqAlignPtr sap);
545 
546 /**********************************************************************
547 *
548 *  AlnMgrIndexLite disassembles the input alignment, indexes all child
549 *  alignments, and then puts them in the amaip->saps array.  It does
550 *  not attempt to create alignment coordinates across the whole set.
551 *  This is useful to keep sets of child alignments together (managing
552 *  BLAST hits, for example) when creating an overall alignment is
553 *  unnecessary.  This alignment can be freed normally, but many 
554 *  alignmgr functions will not work on the parent alignment (they 
555 *  will work on the child alignments).
556 *
557 **********************************************************************/
558 NLM_EXTERN Boolean AlnMgrIndexLite(SeqAlignPtr sap);
559 
560 NLM_EXTERN SeqAlignPtr AlnMgrGetParent(SeqAlignPtr sap);
561 
562 /***************************************************************************
563 *
564 *  AlnMgrUnpackSeqAlign rearranges any seqalign (except alignments with
565 *  more than two levels of nested discontinuous alignments) to a simple
566 *  discontinuous alignment or a linked list of alignments.
567 *
568 ***************************************************************************/
569 NLM_EXTERN Boolean AlnMgrUnpackSeqAlign(SeqAlignPtr sap);
570 
571 
572 /***************************************************************************
573 *
574 *  AlnMgrRearrangeUnpacked transforms all child seqaligns into dense-seg
575 *  types, requiring some rearrangement for dense-diag sets.  This function
576 *  presumes that AlnMgrUnpackSeqAlign has already been called on the
577 *  alignment.
578 *
579 ***************************************************************************/
580 NLM_EXTERN Boolean AlnMgrRearrangeUnpacked(SeqAlignPtr sap);
581 
582 
583 /***************************************************************************
584 *
585 *  AlnMgrAnythingToSeg takes any SeqAlign and does an in-place transformation
586 *  to the parent-child structure.  Each dense-seg, dense-diag and std-seg 
587 *  is put into its own seqalign, and the child seqaligns are linked 
588 *  together in no particular order and put in the sap->segs field of the
589 *  new parent (which takes over the pointer passed in).  The parent
590 *  has segtype SAS_DISC, and each child has segtype SAS_DENSEG or SAS_STD.
591 *  Each child, then, is a continuous, nonoverlapping alignment and therefore
592 *  may be indexed.
593 *
594 ***************************************************************************/
595 
596 NLM_EXTERN Boolean AlnMgrAnythingToSeg (SeqAlignPtr sap);
597 
598 /***********************************************************************
599 *
600 *  AlnMgrIndexLinkedSegs and AlnMgrIndexParentSA create and fill in the
601 *  SASeqIndex and AMAlignIndex structures on the children and the parent,
602 *  respectively.  IndexLinkedSegs is called on the sap->segs field of
603 *  the parent, so that the pointer of the first child in the list
604 *  gets passed in.  AlnMgrIndexParentSA is called on the parent, and 
605 *  the children must already be indexed (the function does check) in order
606 *  for it to work.  AlnMgrIndexParentSA calls AlnMgrPropagateUpSeqIdPtrs
607 *  to create a list of all SeqIdPtrs present in all the children (each
608 *  is only listed once, in the order that its AMAlignDat structure occurs
609 *  in).
610 *
611 ***********************************************************************/
612 NLM_EXTERN Boolean AlnMgrIndexLinkedSegs (SeqAlignPtr sap);
613 NLM_EXTERN Boolean AlnMgrIndexParentSA(SeqAlignPtr sap);
614 NLM_EXTERN SeqIdPtr AlnMgrPropagateUpSeqIdPtrs(SeqAlignPtr sap, Int4Ptr num);
615 NLM_EXTERN SeqIdPtr  AlnMgrPropagateSeqIdsBySapList(AMAlignIndexPtr amaip);
616 NLM_EXTERN SeqIdPtr  AlnMgrPropagateSeqIdsByRow(AMAlignIndexPtr amaip);
617 
618 /***************************************************************************
619 *
620 *  AlnMgrRemoveInconsistentFromPairwiseSet is a greedy function to make
621 *  a consistent (nonoverlapping, linear) subset of alignments from a
622 *  set of pairwise alignments (often BLAST output, gapped or ungapped).
623 *  The input seqalign should either not be indexed or indexed using
624 *  AlnMgrIndexLite (just call it on the BLAST output).  fuzz specifies
625 *  how much overlap, if any, is allowed between alignments that are kept (for
626 *  example, if fuzz = 5, any alignments that overlap by 5 or less are
627 *  considered consistent).  If fuzz is less than 0, this will force spaces
628 *  between alignments (not sure why someone would want to do that, but
629 *  it is allowed).
630 *
631 *  The "Ex" version, also returns the rejected SeqAligns (in score order)
632 *     in 3 different lists according to the reason for rejection.
633 *
634 ***************************************************************************/
635 NLM_EXTERN void AlnMgrRemoveInconsistentFromPairwiseSet(SeqAlignPtr sap, Int4 fuzz);
636 NLM_EXTERN void AlnMgrRemoveInconsistentFromPairwiseSetEx(SeqAlignPtr sap, Int4 fuzz, SeqAlignPtr PNTR wrong_strand, SeqAlignPtr PNTR overlaps_m,SeqAlignPtr PNTR overlaps_s);
637 
638 NLM_EXTERN Boolean AlnMgrMakeMultipleByScore(SeqAlignPtr sap);
639 NLM_EXTERN Boolean AlnMgrMakeMultipleByScoreEx(SeqAlignPtr sap, Int4 fuzz);
640 NLM_EXTERN Boolean AlnMgrMakeMultipleByScoreExEx(SeqAlignPtr sap, Int4 fuzz,SeqAlignPtr PNTR wrong_strand, SeqAlignPtr PNTR overlaps_m,SeqAlignPtr PNTR overlaps_s);
641 NLM_EXTERN SeqAlignPtr AlnMgrDupTopNByScore(SeqAlignPtr sap, Int4 n);
642 
643 /***************************************************************************
644 *
645 *  AlnMgrSortAlnSetByNthRowPos sorts a set of alignments so that they
646 *  are in (increasing) order along the specified row (to make sense, this
647 *  set of alignments should all have the same rows).
648 *
649 ***************************************************************************/
650 NLM_EXTERN void AlnMgrSortAlnSetByNthRowPos(SeqAlignPtr sap, Int4 row);
651 
652 
653 /**********************************************************************
654 *
655 *  am_print_seqalign_indexes is a useful function for debugging; 
656 *  given a parent or child seqalign it prints a text summary of the
657 *  indexes for that seqalign.
658 *
659 ***********************************************************************/
660 NLM_EXTERN void am_print_seqalign_indexes(SeqAlignPtr sap);
661 
662 
663 /**********************************************************************
664 *
665 *  AlnMgrCheckAlignForParent is called by almost every other function;
666 *  it checks whether the parents and children are correctly labeled
667 *  and indexed, and it returns AM_CHILD to indicate that the sap 
668 *  passed in is a child, AM_PARENT for a parent, or -1 for an error.
669 *  If the indexes aren't present, it will try to create them.
670 *
671 **********************************************************************/
672 NLM_EXTERN Int4 AlnMgrCheckAlignForParent(SeqAlignPtr sap);
673 
674 
675 /***********************************************************************
676 *
677 *  AlnMgrSortSeqAligns is a variant of the ValNodeSort function, and
678 *  calls very similar heapsort functions.  It can take a comparison
679 *  function that needs userdata, so more specific sorts are possible
680 *  without defining special structures for every type of sort.
681 *
682 ***********************************************************************/
683 NLM_EXTERN SeqAlignPtr PNTR AlnMgrSortSeqAligns (SeqAlignPtr sap, int (LIBCALLBACK *compare)(VoidPtr, VoidPtr, VoidPtr), VoidPtr userdata, Int4Ptr numsap);
684 NLM_EXTERN SeqAlignPtr PNTR AlnMgrSortbyID (SeqAlignPtr sap, SeqId *sip, Int4Ptr numsap);
685 
686 /**********************************************************************
687 *
688 *  AlnMgrCompareIncreasingBySeqIdPtr takes a SeqIdPtr as userdata,
689 *  and sorts the alignments in increasing order according to the 
690 *  region of the bioseq indicated that is contained in the alignment.
691 *  If the bioseq is not in the alignment, the alignment will be put
692 *  first, so all alignments in which the given bioseq does not 
693 *  participate occur at the beginning of the list, making it easy to
694 *  check for them and remove them.
695 *
696 **********************************************************************/
697 NLM_EXTERN int LIBCALLBACK AlnMgrCompareIncreasingBySeqIdPtr (VoidPtr base, VoidPtr large_son, VoidPtr userdata);
698 
699 /*********************************************************************
700 *
701 *  AlnMgrFindFirst is crucial to the AlnMgrMakeFakeMultiple function;
702 *  it uses the sorted order of the seqaligns in each AMAlignDat
703 *  structure to guide a heapsort of all the seqaligns.
704 *
705 *********************************************************************/
706 NLM_EXTERN int LIBCALLBACK AlnMgrFindFirst(VoidPtr base, VoidPtr large_son, VoidPtr userdata);
707 NLM_EXTERN int LIBCALLBACK AlnMgrCompareTips(VoidPtr base, VoidPtr large_son);
708 
709 
710 /************************************************************************
711 *
712 *  AlnMgrGetNextLengthBit should be called iteratively on an alignment
713 *  to return the lengths of all the aligned and unaligned pieces in
714 *  the alignment.  Don't change the value in r, just pass in a pointer
715 *  to an allocated Int4 set to 0 initially.  The lengths of the unaligned
716 *  pieces are precomputed using AlnMgrGetMaxUnalignedLength; if no
717 *  precomputed values are found, this function is used to compute the
718 *  lengths on the fly.
719 *
720 ************************************************************************/
721 NLM_EXTERN Boolean AlnMgrGetNextLengthBit(SeqAlignPtr sap, Int4Ptr length, Int4Ptr r);
722 NLM_EXTERN Int4 AlnMgrGetMaxUnalignedLength(SeqAlignPtr sap1, SeqAlignPtr sap2);
723 
724 
725 /*************************************************************************
726 *
727 *  AlnMgrGetNextAlnBit takes an AlnMsgPtr, with (at the minimum) the
728 *  which_bsq field filled in to indicate which bioseq should be returned.
729 *  The function returns the segments of the bioseq which span the region
730 *  of the alignment indicated, and can return them according to either
731 *  alignment coordinates (if which_master is NULL) or a master coordinate
732 *  system (need to fill in the SeqIdPtr of the master).  The function
733 *  returns TRUE if there are more segments of the bioseq to retrieve,
734 *  and FALSE if not.  It uses the two binary search functions to quickly
735 *  retrieve the required data from the indexes.
736 *
737 *************************************************************************/
738 NLM_EXTERN Boolean AlnMgrGetNextAlnBit(SeqAlignPtr sap, AlnMsgPtr amp);
739 
740 /********************************************************************************
741 *
742 *  binary search functions
743 *
744 ********************************************************************************/
745 NLM_EXTERN Uint4 binary_search_on_uint4_list(Uint4Ptr list, Uint4 pos, Uint4 listlen);
746 NLM_EXTERN Int4 binary_search_on_uint2_list(Uint2Ptr list, Uint2 ele, Uint2 listlen);
747 NLM_EXTERN Int4 binary_search_by_chunk(Int4Ptr list, Int4 ele, Int4 listlen, Int4 chunksize, Int4 offset);
748 NLM_EXTERN Int4 binary_search_segment_array(SASeqDatPtr ssdp, Int4 pos, Int4 numseq, Int4 offset, DenseSegPtr dsp);
749 
750 
751 /************************************************************************
752 *
753 *  These are several utility functions which get needed data from the
754 *  indexes.  "N" refers to row number (using a 1-based numbering system).
755 *
756 ************************************************************************/
757 NLM_EXTERN Int4 AlnMgrGetAlnLength(SeqAlignPtr sap, Boolean fill_in);
758 NLM_EXTERN Int4 AlnMgrGetNumSeqs(SeqAlignPtr sap);
759 NLM_EXTERN SeqIdPtr AlnMgrGetUniqueSeqs(SeqAlignPtr sap, Int4Ptr n);
760 NLM_EXTERN SeqIdPtr AlnMgrGetNthSeqIdPtr(SeqAlignPtr sap, Int4 n);
761 NLM_EXTERN void AlnMgrGetNthSeqRangeInSA(SeqAlignPtr sap, Int4 n, Int4Ptr start, Int4Ptr stop);
762 NLM_EXTERN Int4 AlnMgrGetNumSegments(SeqAlignPtr sap);
763 
764 /***************************************************************************
765 *
766 *  AlnMgrGetNumAlnBlocks returns the number of separate aligned regions
767 *  in the seqalign.  A return value of -1 indicates an error; a return
768 *  value of 0 indicates a NULL alignment (only one unaligned region and
769 *  no aligned regions.
770 *
771 ***************************************************************************/
772 NLM_EXTERN Int4 AlnMgrGetNumAlnBlocks(SeqAlignPtr sap);
773 NLM_EXTERN Boolean AlnMgrGetNthBlockRange(SeqAlignPtr sap, Int4 n, Int4Ptr from, Int4Ptr to);
774 
775 
776 /***************************************************************************
777 *
778 *  AlnMgrGetNthAlignedSegInNthRow is similar to AlnMgrGetNextAlignBit,
779 *  but it takes an extra argument -- the number (1-based) of the segment
780 *  for which you want the alignment.  Fill in the AlnMsg structure as for
781 *  AlnMgrGetNextAlignBit, but leave out the from_m and to_m; and as usual,
782 *  don't modify the AlnMsg structure in between calls, and call AlnMsgReNew
783 *  for a new segment.  The from_b and to_b fields will work as in 
784 *  AlnMgrGetNextAlnBit -- if there is a gap, these are alignment coordinates;
785 *  otherwise they're sequence coordinates.
786 *
787 ***************************************************************************/
788 NLM_EXTERN Boolean AlnMgrGetNthAlignedSegInNthRow(SeqAlignPtr sap, AlnMsgPtr amp, Int4 segnum);
789 
790 NLM_EXTERN Boolean AlnMgrGetNthSegmentRange(SeqAlignPtr sap, Int4 n, Int4Ptr from, Int4Ptr to);
791 
792 /********************************************************************************
793 *
794 *  AlnMgrGetNextNthSeqRange is called recursively to return the lengths of
795 *  all aligned and all internal unaligned regions of any row in a seqalign.
796 *  If there is an error, or if the function is called past the last block,
797 *  the function returns FALSE.  Set where to point to an allocated integer
798 *  equal to 0 on the first call and don't change it during the loop.  Set
799 *  the boolean unaligned to FALSE to get only the aligned regions, and TRUE to
800 *  get the aligned regions plus all internal unaligned regions.  For unaligned
801 *  regions, *is_aligned will be FALSE.
802 *
803 ********************************************************************************/
804 NLM_EXTERN Boolean AlnMgrGetNextNthSeqRange(SeqAlignPtr sap, Int4 n, Int4Ptr start, Int4Ptr stop, Int4Ptr where, BoolPtr is_aligned, Boolean unaligned);
805 
806 
807 /********************************************************************************
808 *
809 *  AlnMgrGetNthRowTail retrieves the blocks of sequence on either end of the
810 *  alignment, by row.  which_tail is LEFT_TAIL to retrieve the ends which come
811 *  before alignment coordinate 0, and RIGHT_TAIL to retrieve the other ends.
812 *  The function returns TRUE if successful, FALSE for an error.
813 *
814 ********************************************************************************/
815 NLM_EXTERN Boolean AlnMgrGetNthRowTail(SeqAlignPtr sap, Int4 n, Uint1 which_tail, Int4Ptr start, Int4Ptr stop, Uint1Ptr strand);
816 NLM_EXTERN Int4 AlnMgrGetMaxTailLength (SeqAlignPtr sap, Uint1 which_tail);
817 NLM_EXTERN Boolean AlnMgrGetNthUnalignedForNthRow(SeqAlignPtr sap, Int4 unaligned, Int4 row, Int4Ptr start, Int4Ptr stop);
818 NLM_EXTERN Uint1 AlnMgrGetStrand(SeqAlignPtr sap, SeqIdPtr sip);
819 NLM_EXTERN Uint1 AlnMgrGetNthStrand(SeqAlignPtr sap, Int4 n);
820 NLM_EXTERN Int4 AlnMgrGetNForSip(SeqAlignPtr sap, SeqIdPtr sip);
821 NLM_EXTERN Int4 AlnMgrGetNForSap(AMAlignIndexPtr amaip, SeqAlignPtr sap);
822 
823 /********************************************************************************
824 *
825 *  AlnMgrGetAllNForSip is called in a while loop to return all the rows that a
826 *  seqid appears in in a given seqalign.  Use n = 0 to start, and then on
827 *  return, if the return is TRUE, n will be the row number of the next row
828 *  that the seqid appears in.  If the return is FALSE, either there was an
829 *  error or there are no (more) rows containing that seqid.
830 *
831 ********************************************************************************/
832 NLM_EXTERN Boolean AlnMgrGetAllNForSip(SeqAlignPtr sap, SeqIdPtr sip, Int4Ptr n);
833 
834 NLM_EXTERN Int4 AlnMgrGetSapForSip(AMAlignIndexPtr amaip, SeqIdPtr sip, Int4 which);
835 NLM_EXTERN Int4 AlnMgrMapToBsqCoords(SeqAlignPtr sap, Uint4 pos, SeqIdPtr sip, SeqIdPtr master); 
836 
837 /********************************************************************************
838 *
839 *  AlnMgrMapRowCoords maps a position in a given row to the bioseq coordinate
840 *  of that row.  If master is NULL, the alignment is taken to be flattened;
841 *  otherwise it is an alignment according to that master (this will change the
842 *  correspondence between row coordinates and bioseq coordinates).  The return
843 *  value will be either a positive bioseq coordinate, or -1 if the bioseq is
844 *  gapped at that row position.
845 *
846 ********************************************************************************/
847 NLM_EXTERN Int4 AlnMgrMapRowCoords(SeqAlignPtr sap, Uint4 pos, Int4 row, SeqIdPtr master);
848 
849 /********************************************************************************
850 *
851 *  AlnMgrMapBioseqToSeqAlign takes a position in bioseq coordinates in a
852 *  row and maps it to seqalign coordinates, using the given master as
853 *  the alignment master (if master is NULL the alignment is flat).  A
854 *  return value of -1 indicates an error; a return value of -2 indicates
855 *  that the given bioseq coordinates are not contained in the alignment
856 *  specified.
857 *
858 ********************************************************************************/
859 NLM_EXTERN Int4 AlnMgrMapBioseqToSeqAlign(SeqAlignPtr sap, Int4 pos, Int4 row_num, SeqIdPtr master);
860 NLM_EXTERN Int4 AlnMgrMapBioseqToSeqAlignEx(SeqAlignPtr sap, Int4 pos, Int4 row_num,
861                                             SeqIdPtr master, Int4 *oldj);
862 
863 
864 /***********************************************************************
865 *
866 *  AlnMgrMakeFakeMultiple calls AlnMgrCheckOverlapping to decide whether
867 *  an alignment is linear.  Then, if possible, it calls AlnMgrMakeAlignCoords
868 *  to create alignment coordinates across all children contained in the
869 *  parent.
870 *
871 ***********************************************************************/
872 NLM_EXTERN Boolean AlnMgrMakeFakeMultiple(SeqAlignPtr sap);
873 
874 /**********************************************************************
875 *
876 *  AlnMgrNeatlyIndex is a very specialized function for structure
877 *  alignments and other alignments that have an implied row order.
878 *  It puts an index on the first seqalign in the set, and that index
879 *  only designates which seqaligns belong in which rows.  The input
880 *  alignments are not changed at all, and only the first alignment is
881 *  indexed.  This alignment cannot be displayed or accessed; it's only
882 *  a way to designate rows.
883 *
884 **********************************************************************/
885 NLM_EXTERN Boolean AlnMgrNeatlyIndex(SeqAlignPtr sap);
886 
887 /**********************************************************************
888 *
889 *  AlnMgrTossNeatRows is called to create a subset of the NeatlyIndexed
890 *  alignment, only containing certain rows.  The array throwarray, of
891 *  length len, contains the (1-based) numbers of the rows to be left
892 *  out.  The function returns a duplicated alignment, which is not
893 *  yet indexed.  This function assumes a very strict row structure --
894 *  each row is represented by a single seqalign or seqalign set, and
895 *  the first row is the master.
896 *
897 **********************************************************************/
898 NLM_EXTERN SeqAlignPtr AlnMgrTossNeatRows(SeqAlignPtr sap, Int4Ptr throwarray, Int4 len);
899 
900 /***************************************************************************
901 *
902 *   AlnMgrMakeMultByIntersectOnMaster is a specialized function that 
903 *   truncates the segments of segmented master-slave alignments to
904 *   force them to line up:
905 *
906 *   Master   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
907 *   seq1        XXXXXXXX       XXXXXXXXXXXXXX
908 *   seq2       XXXXXXXXXX        XXXXXXX
909 *   seq3          XXXXXXXXXXXXXXXXXXXXXXX
910 *
911 *   becomes
912 *
913 *   Master        XXXXXX         XXXXXXX
914 *   seq1          XXXXXX         XXXXXXX
915 *   seq2          XXXXXX         XXXXXXX
916 *   seq3          XXXXXX         XXXXXXX
917 *
918 *   This indexing is different from the other type -- the input
919 *   alignments may actually be truncated, instead of just rearranged.
920 *   If allinblock is TRUE, then the function throws away any blocks that
921 *   have a missing sequence.
922 *
923 ***************************************************************************/
924 NLM_EXTERN Boolean AlnMgrMakeMultByIntersectOnMaster(SeqAlignPtr sap, Boolean allinblock);
925 NLM_EXTERN Int4 am_guess_numrows(SeqAlignPtr sap);
926 
927 /***************************************************************************
928 *
929 *   AlnMgrTruncateSAP truncates a given seqalign to contain only the
930 *   bioseq coordinates from start to stop on the indicated row.  Anything
931 *   before those coordinates is discarded; anything remaining afterwards
932 *   is made into another seqalign and put in sap->next (the original next,
933 *   if any, is now at sap->next->next). Doesn't work on parent seqaligns.
934 *   The function returns TRUE if the orignal alignment extended past stop.
935 *
936 ***************************************************************************/
937 NLM_EXTERN Boolean AlnMgrTruncateSAP(SeqAlignPtr sap, Int4 start, Int4 stop, Int4 row);
938 
939 
940 NLM_EXTERN void AlnMgrMakeAlignCoords(SeqAlignPtr sap);
941 NLM_EXTERN Boolean AlnMgrMergeIntoMSMultByMaster(AMAlignIndexPtr amaip, Int4Ptr lens, Uint4Ptr numseg);
942 NLM_EXTERN Boolean AlnMgrMergeSegments(Int4Ptr lens, SeqAlignPtr sap, SeqIdPtr master, Int4Ptr where, Int4 which);
943 NLM_EXTERN Boolean AlnMgrFillInStarts(SeqAlignPtr PNTR saparray, Int4Ptr starts, Int4 numseg, Int4Ptr lens, Int4 numsaps, Uint4Ptr aligncoords);
944 NLM_EXTERN Int4 AlnMgrGetStartFromMaster(SeqAlignPtr sap, Int4 start);
945 NLM_EXTERN Uint4 AlnMgrGetMasterGapStartForSeg(SeqAlignPtr sap, Int4 which_gap, Uint4Ptr aligncoord);
946 NLM_EXTERN Boolean AlnMgrReconcileGaps(Int4Ptr lens, Uint4Ptr aligncoords, Int4 num);
947 NLM_EXTERN Boolean AlnMgrMakeMultSegments(AMAlignIndexPtr amaip);
948 
949 NLM_EXTERN Int4 AlnMgrCheckOrdered(SeqAlignPtr sap);
950 NLM_EXTERN Int4 AlnMgrCheckOverlapping(SeqAlignPtr sap);
951 
952 /******************************************************************************
953 *
954 *  AlnMgrGetMaxSegments simply adds up the number of segments for each
955 *  SeqAlign in a linked list, to get the maximum number of segments
956 *  for the merge of the list (for memory allocation in AlnMgrMakeFakeMultiple).
957 *
958 *******************************************************************************/
959 NLM_EXTERN Int4 AlnMgrGetMaxSegments(SeqAlignPtr sap);
960 
961 /*******************************************************************************
962 *
963 *  Row Management functions:
964 *
965 *******************************************************************************/
966 NLM_EXTERN Int4 AlnMgrGetNumRows(SeqAlignPtr sap);
967 NLM_EXTERN Boolean AlnMgrMakeRowsForOrdered(SeqAlignPtr sap);
968 NLM_EXTERN Int4 AlnMgrGetMaxRowsForParentPartial(SeqAlignPtr sap);
969 NLM_EXTERN Boolean AlnMgrGetRowsForPartial(SeqAlignPtr sap);
970 NLM_EXTERN Boolean AlnMgrGetRowsForMasterSlave(SeqAlignPtr sap);
971 
972 
973 /*******************************************************************************
974 *
975 *  AlnMgrFindMaster returns the SeqIdPtr of the first bioseq present in all
976 *  child alignments, unless the sap->master field is set in the child alignments,
977 *  in which case that SeqIdPtr is returned (if it's the same in all children).
978 *
979 *******************************************************************************/
980 NLM_EXTERN SeqIdPtr AlnMgrFindMaster(SeqAlignPtr sap);
981 
982 /*******************************************************************************
983 *
984 *  AlnMgrCheckRealMaster makes sure that the master seqid given appears
985 *  once and only once in each seqalign in the set if a parent is given,
986 *  or once and only one in the seqalign if a child is given.
987 *
988 *******************************************************************************/
989 NLM_EXTERN Boolean AlnMgrCheckRealMaster(SeqAlignPtr sap, SeqIdPtr master);
990 
991 NLM_EXTERN Boolean AlnMgrMakeSegmentedMasterSlave(SeqAlignPtr sap);
992 NLM_EXTERN int LIBCALLBACK AlnMgrCompareAMS(VoidPtr base, VoidPtr large_son);
993 NLM_EXTERN int LIBCALLBACK AlnMgrCompareMasterAMS(VoidPtr base, VoidPtr large_son);
994 
995 NLM_EXTERN Boolean AlnMgrForceMasterSlave(SeqAlignPtr sap);
996 
997 NLM_EXTERN void AlnMgrSetMaster(SeqAlignPtr sap, SeqIdPtr master);
998 NLM_EXTERN void AlnMgrMakeMasterPlus(SeqAlignPtr sap);
999 
1000 /***************************************************************************
1001 *
1002 *  AlnMgrGetSubAlign returns a flattened multiple or pairwise alignment
1003 *  corresponding to the indexed input alignment.  To get the entire
1004 *  alignment, set from = 0 and to = -1.  (SUBALIGN)
1005 *
1006 ***************************************************************************/
1007 NLM_EXTERN SeqAlignPtr AlnMgrGetSubAlign(SeqAlignPtr sap, SeqIdPtr which_master, Int4 from, Int4 to);
1008 NLM_EXTERN SeqAlignPtr AlnMgrGetSubAlignSpecial(SeqAlignPtr sap, Int4 master, Int4 from, Int4 to);
1009 
1010 /********************************************************************************
1011 *
1012 *   viewer and editor management functions  
1013 * 
1014 ********************************************************************************/ 
1015 
1016 NLM_EXTERN SeqAlignPtr AlnMgrCopyIndexedParentSeqAlign(SeqAlignPtr sap);
1017 NLM_EXTERN RowSourcePtr AlnMgrCopyRowSource(RowSourcePtr rsp);
1018 NLM_EXTERN AMAlignDatPtr AlnMgrCopyamadp(AMAlignDatPtr amadp, SeqAlignPtr sap_tmp, SeqAlignPtr seg_head);
1019 NLM_EXTERN SeqAlignIndexPtr AlnMgrCopyIndexesForChildSeqAlign(SeqAlignPtr sap);
1020 NLM_EXTERN SASeqDatPtr  AlnMgrCopySASeqDat(SASeqDatPtr ssdp);
1021 NLM_EXTERN SeqAlignPtr AlnMgrCopyAndIndexSingleAlignment(SeqAlignPtr sap);
1022 NLM_EXTERN Boolean AlnMgrCopyIndexedParentIntoSap(SeqAlignPtr sap, SeqAlignPtr target);
1023 
1024 /**********************************************************************
1025 *
1026 *  AlnMgrDeleteChildByPointer removes the specified child seqalign
1027 *  from the set.  Note that this function does not reindex the seqalign;
1028 *  the calling function must do that if the return is TRUE (use 
1029 *  AlnMgrReIndexSeqAlign).
1030 *
1031 **********************************************************************/
1032 NLM_EXTERN Boolean AlnMgrDeleteChildByPointer(SeqAlignPtr parent, SeqAlignPtr child);
1033 
1034 /**********************************************************************
1035 *
1036 *  AlnMgrDeleteNthRow deletes the specified row from either a parent 
1037 *  or a child seqalign.  Note that with a parent seqalign, this may
1038 *  result in the deletion of a child seqalign.  The function does NOT
1039 *  reindex the alignment; the calling function must do that upon a 
1040 *  TRUE return (use AlnMgrReIndexSeqAlign).
1041 *
1042 **********************************************************************/
1043 NLM_EXTERN Boolean AlnMgrDeleteNthRow(SeqAlignPtr sap, Int4 row);
1044 
1045 /***************************************************************************
1046 *  AlnMgrDeleteHiddenEx
1047 *
1048 *  Reads the Index, and updates the ->segs SeqAligns according
1049 *  to the content of the index. If DeleteSalp then either 
1050 *  Frees unused SeqAligns.. OR 
1051 *  deletes them from the Object Manager.
1052 *
1053 *  AlnMgrDeleteHidden  calls the EX function with DeleteSalp=TRUE;
1054 *  
1055 ****************************************************************************/
1056 
1057 NLM_EXTERN void AlnMgrDeleteHidden(SeqAlignPtr sap, Boolean UseOM);
1058 NLM_EXTERN void AlnMgrDeleteHiddenEx(SeqAlignPtr sap, Boolean UseOM, Boolean DeleteSalp);
1059 
1060 /***************************************************************************
1061 *
1062 *  Both AlnMgrReplaceBlock and AlnMgrAddBlock require a flattened multiple
1063 *  alignment plus a dense-seg structure (with the same number of rows
1064 *  as the multiple alignment.  Discontinuous multiple alignments are fine,
1065 *  and gapped alignments can also be edited; multiple pairwise alignments
1066 *  cannot be edited (first call AlnMgrGetSubAlign to flatten the alignment,
1067 *  or only edit one of the alignments in the set).  If the addition,
1068 *  removal, or replacement of a block causes an unaligned region to
1069 *  disappear, the functions will merge adjacent blocks to get rid of
1070 *  unaligned regions of length 0.
1071 *
1072 ***************************************************************************/
1073 NLM_EXTERN Boolean AlnMgrReplaceBlock(SeqAlignPtr sap, DenseSegPtr new_block, Int4 block_num);
1074 NLM_EXTERN Boolean AlnMgrAddBlock(SeqAlignPtr sap, DenseSegPtr new_block);
1075 
1076 /********************************************************************************
1077 *
1078 *   SeqAlign types  
1079 * 
1080 ********************************************************************************/ 
1081 NLM_EXTERN  Boolean AlnMgrIsSAPDiscAli(SeqAlignPtr sap);
1082 
1083 NLM_EXTERN Boolean AlnMgrIsSAPNULL(SeqAlignPtr sap);
1084 NLM_EXTERN Int4 AlnMgrIsIBMable(SeqAlignPtr sap);
1085 NLM_EXTERN Int4 AlnMgrIsEditable(SeqAlignPtr sap);
1086 
1087 
1088 NLM_EXTERN Int4  AlnMgrMapBioseqToBioseq(SeqAlignPtr salp,Int4 pos,Int4 source_row,Int4 target_row,Boolean GetNextNonGap,Int4Ptr PostGap) ;
1089 
1090 /*********************************************************************************
1091 *
1092 *   Pairwise to Global Alignment Functions: AlnMgrSeqAlignMergeTwoPairwise
1093 *
1094 *********************************************************************************/
1095 NLM_EXTERN DenseSegPtr DenseDiagToGlobalDenseSeg(DenseDiagPtr ddp_head);
1096 NLM_EXTERN DenseDiagPtr AlnMgrSeqAlignToDDP(SeqAlignPtr salp,Int4 aln_cut_from,Int4 aln_cut_to,Int4Ptr numseg_ptr);
1097 NLM_EXTERN SeqAlignPtr AlnMgrMerge3OverlappingSeqAligns(SeqAlignPtr salp1,SeqAlignPtr salp_merging,SeqAlignPtr salp2,Int4 master_cut_pos1, Int4 master_cut_pos2);
1098 
1099 #ifdef __cplusplus
1100 }
1101 #endif
1102 
1103 #undef NLM_EXTERN
1104 #ifdef NLM_EXPORT
1105 #define NLM_EXTERN NLM_EXPORT
1106 #else
1107 #define NLM_EXTERN
1108 #endif
1109 
1110 #endif
1111 

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.