NCBI C Toolkit Cross Reference

C/api/edutil.h


  1 /*  edutil.h
  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:  edutil.h
 27 *
 28 * Author:  James Ostell
 29 *   
 30 * Version Creation Date: 2/2/94
 31 *
 32 * $Revision: 6.21 $
 33 *
 34 * File Description:  Sequence editing utilities
 35 *
 36 * Modifications:  
 37 * --------------------------------------------------------------------------
 38 * Date       Name        Description of modification
 39 * -------  ----------  -----------------------------------------------------
 40 *
 41 * $Log: edutil.h,v $
 42 * Revision 6.21  2009/03/04 16:34:15  bollin
 43 * Added function for removing contigs from scaffolds.
 44 *
 45 * Revision 6.20  2007/05/08 17:18:32  bollin
 46 * Added functions for identifying AGP gap DeltaSeqs
 47 *
 48 * Revision 6.19  2007/05/07 17:43:03  bollin
 49 * Made functions IsDeltaSeqGap and IsDeltaSeqUnknownGap extern.
 50 *
 51 * Revision 6.18  2006/07/13 17:06:38  bollin
 52 * use Uint4 instead of Uint2 for itemID values
 53 * removed unused variables
 54 * resolved compiler warnings
 55 *
 56 * Revision 6.17  2006/02/07 13:41:29  bollin
 57 * added function AdjustFeatureForGapChange, which changes a feature to accommodate
 58 * a change in the length of a gap
 59 *
 60 * Revision 6.16  2005/05/02 14:21:15  bollin
 61 * removed function prototypes for PlayJournal and UnplayJournal, since these
 62 * functions live in desktop/seqpanel.c and are only used there
 63 *
 64 * Revision 6.15  2005/04/28 20:10:32  bollin
 65 * added new function AdjustFeaturesForInsertion which is called by BioseqInsert
 66 * and also by a new function in sequin3.c for converting a raw bioseq to a delta
 67 * and inserting gaps
 68 *
 69 * Revision 6.14  2005/04/06 19:33:15  bollin
 70 * made it possible to insert and remove gaps from delta sequences
 71 *
 72 * Revision 6.13  2004/10/08 16:04:16  bollin
 73 * added ability to check when an action will remove a feature
 74 *
 75 * Revision 6.12  2004/09/29 18:49:57  bollin
 76 * fixed bugs in sequence editing, can now undo a nucleotide deletion that
 77 * removes an entire feature location (feature will be restored)
 78 *
 79 * Revision 6.11  2004/09/23 14:59:51  bollin
 80 * moved functions that depend on functions that depend on BLAST functions
 81 * into seqpanel.c, made function scalled by those functions extern
 82 *
 83 * Revision 6.10  2004/09/22 18:20:32  bollin
 84 * added functions for playing and unplaying a sequence editor action to translate
 85 * a CDS
 86 *
 87 * Revision 6.9  2004/07/30 18:46:55  bollin
 88 * added function for reordering intervals after they have been dragged by
 89 * the sequence editor
 90 *
 91 * Revision 6.8  2004/07/28 20:06:19  bollin
 92 * added journaling for undo/redo of dragged sequence location changes
 93 *
 94 * Revision 6.7  2004/07/28 15:22:15  bollin
 95 * moved functions for moving feature locations around to edutil.c from
 96 * seqpanel.c
 97 *
 98 * Revision 6.6  2004/07/22 15:34:41  bazhin
 99 * Added function prototype GapToSeqLocEx() to handle gaps of unknown
100 * lengths within locations.
101 *
102 * Revision 6.5  2004/07/12 12:29:45  bollin
103 * moved new sequence editor editing functions here
104 *
105 * Revision 6.4  2003/02/10 22:57:45  kans
106 * added BioseqCopyEx, which takes a BioseqPtr instead of a SeqIdPtr for the source
107 *
108 * Revision 6.3  2002/07/02 13:23:43  kans
109 * added SeqLocDeleteEx
110 *
111 * Revision 6.2  1997/11/10 19:50:23  kans
112 * Fixed incorrect comment for ISAGappedSeqLoc() function (SB).
113 *
114 * Revision 6.1  1997/10/24 19:15:01  bazhin
115 * Added descriptors for three easy functions GapToSeqLoc(...),
116 * ISAGappedSeqLoc(...) and GappedSeqLocsToDeltaSeqs(...) for
117 * processing "gap(...)" tokens in CONTIG line.
118 *
119 * Revision 6.0  1997/08/25 18:05:28  madden
120 * Revision changed to 6.0
121 *
122 * Revision 5.6  1997/07/25 20:34:56  kans
123 * added SegLocToPartsEx
124 *
125 * Revision 5.5  1997/06/19 18:37:34  vakatov
126 * [WIN32,MSVC++]  Adopted for the "NCBIOBJ.LIB" DLL'ization
127 *
128 * Revision 5.4  1996/10/09 17:31:37  kans
129 * was missing an ifdef cplusplus at the bottom
130 *
131  * Revision 5.3  1996/10/09  16:34:59  chappey
132  * added SeqLocReplaceID() that replaces the Seq-Id of a Seq-Loc
133  *
134  * Revision 5.2  1996/06/12  18:29:34  epstein
135  * move SeqLocIntNew() and SeqLocPntNew() from edutil to sequtil
136  *
137  * Revision 5.1  1996/06/10  15:07:22  epstein
138  * replace make_seq_loc() with SeqLocIntNew() and make_pnt_loc with SeqLocPntNew()
139  *
140  * Revision 5.0  1996/05/28  13:23:23  ostell
141  * Set to revision 5.0
142  *
143  * Revision 4.7  1996/03/12  22:14:22  ostell
144  * added SeqLocToParts()
145  *
146  * Revision 4.5  1996/01/30  16:24:04  ostell
147  * changed name of SeqLocPack() to SeqLocPackage()
148  *
149  * Revision 4.4  1996/01/29  22:03:52  ostell
150  * revised SeqLocAdd
151  * added SeqLocPack
152  *
153  * Revision 4.3  1996/01/10  22:25:25  ostell
154  * added SeqLocIntNew()
155  *
156  * Revision 4.2  1995/12/29  21:31:44  ostell
157  * added mapping functions between delta seq and seq loc, for editing utilities
158  *
159  * Revision 4.1  1995/11/15  20:40:20  ostell
160  * fixed SeqLocCopyPart so it correctly handles SEQLOC_NULL in segmented
161  * records
162  *
163  * Revision 4.0  1995/07/26  13:49:01  ostell
164  * force revision to 4.0
165  *
166  * Revision 1.6  1995/05/15  21:46:05  ostell
167  * added Log line
168  *
169 *
170 *
171 *
172 * ==========================================================================
173 */
174 #ifndef _NCBI_EdUtil_
175 #define _NCBI_EdUtil_
176 
177 #ifndef _NCBI_SeqPort_
178 #include <seqport.h>           /* other utilities */
179 #endif
180 
181 #undef NLM_EXTERN
182 #ifdef NLM_IMPORT
183 #define NLM_EXTERN NLM_IMPORT
184 #else
185 #define NLM_EXTERN extern
186 #endif
187 
188 #ifdef __cplusplus
189 extern "C" {
190 #endif
191 
192 #include "explore.h"
193 
194 /*****************************************************************************
195 *
196 *   Sequence Editing Utilties
197 *       High Level Cut, Copy, Paste
198 *
199 *****************************************************************************/
200 
201 
202 /*****************************************************************************
203 *
204 *   BioseqDelete (target, from, to, do_feat, do_split)
205 *      Deletes the region of sequence between from-to, inclusive, on the
206 *        Bioseq whose SeqId is target.
207 *      If do_feat, the feature table is updated to reflect the deletion
208 *        using SeqEntryDelFeat()
209 *      If do_split, the features across the deleted region are split into
210 *        two intervals on either side. If not, the feature is just shortened.
211 *
212 *****************************************************************************/
213 NLM_EXTERN Boolean LIBCALL BioseqDelete (SeqIdPtr target, Int4 from, Int4 to, Boolean do_feat, Boolean do_split);
214 
215 
216 
217 /*****************************************************************************
218 *
219 *   BioseqCopy(newid, sourceid, from, to, strand, do_feat)
220 *      Creates a new Bioseq from sourceid in the range from-to inclusive.
221 *      If strand==Seq_strand_minus, reverse complements the sequence in
222 *        the copy and (if do_feat) corrects the feature table appropriately.
223 *      Names new Bioseq as newid, if not NULL
224 *        else Creates seqid.local = "Clipboard" if newid is NULL
225 *      If do_feat == TRUE copies appropriate region of feature table from
226 *        sourceid to new copy using SeqFeatsCopy().
227 *
228 *
229 *   BioseqCopyEx(newid, oldbsp, from, to, strand, do_feat)
230 *      Internal function called by BioseqCopy that takes BioseqPtr
231 *
232 *****************************************************************************/
233 NLM_EXTERN BioseqPtr LIBCALL BioseqCopy (SeqIdPtr newid, SeqIdPtr sourceid, Int4 from, Int4 to,
234                                Uint1 strand, Boolean do_feat);
235 
236 NLM_EXTERN BioseqPtr LIBCALL BioseqCopyEx (SeqIdPtr newid, BioseqPtr oldbsp, Int4 from, Int4 to,
237                                Uint1 strand, Boolean do_feat);
238 
239 /*****************************************************************************
240 *
241 *       SeqLocCopyPart (the_segs, from, to, strand, group, first_segp, last_segp)
242 *      cuts out from the_segs the part from offset from to offset to
243 *      reverse complements resulting seqloc if strand == Seq_strand_minus
244 *      if (group) puts resulting intervals into a new Seq-loc (of type
245 *        PACKED_INT if no SEQLOC_NULL, else SEQLOC_MIX).
246 *      Currently this always makes intervals or nulls. Is really for segmented and
247 *        reference sequence extensions
248 *      If first_segp and last_segp are not NULL, then they are filled in with the
249 *        ordinal number of the source segments that remain in the copy, based
250 *        on SeqLocFindNext, where 1 is the first one. Thus if the third and
251 *        fourth segments were copied, first is 3 and last is 4. If the
252 *        location was reverse complemented, first is 4 and last is 3.
253 *
254 *****************************************************************************/
255 NLM_EXTERN SeqLocPtr LIBCALL SeqLocCopyPart PROTO((SeqLocPtr the_segs, Int4 from, Int4 to,
256          Uint1 strand, Boolean group, Int2Ptr first_segp, Int2Ptr last_segp));
257 
258 /* This function is used by BioseqInsert to adjust features on a sequence after
259  * an insertion.  pos indicates the start of the insertion, len indicates
260  * the length of the inserted sequence, and do_split indicates whether features
261  * that cover the insertion should be split at either side of the insertion.
262  */
263 extern void 
264 AdjustFeaturesForInsertion 
265 (BioseqPtr tobsp, 
266  SeqIdPtr  to_id,
267  Int4 pos, 
268  Int4 len, 
269  Boolean do_split);
270 
271 /*****************************************************************************
272 *
273 * BioseqInsert (from_id, from, to, strand, to_id, pos, from_feat, to_feat,
274 *                                                                     do_split)
275 *       Inserts a copy the region "from"-"to" on "strand" of the Bioseq
276 *          identified by "from_id" into the Bioseq identified by "to_id"
277 *          before "pos".
278 *          To append to the end of the sequence, use APPEND_RESIDUE for "pos".
279 *       if from_feat = TRUE, copies the feature table from "from" and updates
280 *          to locations to point to the proper residues in "to_id"
281 *       If to_feat = TRUE, updates feature table on "to_id" as well.
282 *          if do_split == TRUE, then splits features in "to_id" (to_feat must
283 *             be TRUE as well). Otherwise expands features at insertion.
284 *
285 *       All operations are copies. "frombsp" is unchanged.
286 *       Insert will only occur between certain Bioseq.repr classes as below
287 *
288 *   From Bioseq.repr                      To Bioseq.repr
289 *   
290 *                          virtual       raw      segmented        map
291 *                       +---------------------------------------------------
292 *             virtual   |   length       inst      SeqLoc         length
293 *                       +---------------------------------------------------
294 *                 raw   |   error        copy      SeqLoc         error
295 *                       +---------------------------------------------------
296 *           segmented   |   error        inst      SeqLoc*        error
297 *                       +---------------------------------------------------
298 *                 map   |   error        inst*     SeqLoc         copy
299 *                       +---------------------------------------------------
300 *
301 *   length = changes length of "to" by length of "from"
302 *   error  = insertion not allowed
303 *   inst   = "from" instantiated as residues ("N" or "X" for virtual "from")
304 *   inst*  = as above, but a restriction map can instantiate other bases
305 *            than "N" for known restriction recognition sites.
306 *   copy   = copy of "from" inserted into "to"
307 *   SeqLoc = a SeqLoc added to "to" which points to "from". No copy of residues.
308 *   SeqLoc* = as above, but note that "to" points to "from" directly, not
309 *             what "from" itself may point to.
310 *   
311 *****************************************************************************/
312 NLM_EXTERN Boolean LIBCALL BioseqInsert (SeqIdPtr from_id, Int4 from, Int4 to, Uint1 strand, SeqIdPtr to_id, Int4 pos,
313             Boolean from_feat, Boolean to_feat, Boolean do_split);
314 
315 
316 /*****************************************************************************
317 *
318 *   BioseqOverwrite (target, pos, residue, seqcode)
319 *      Overwrites the residue at pos with residue in the
320 *        Bioseq whose SeqId is target.
321 *      residue is iupacna for DNA or ncbieaa for protein
322 *      target MUST be a raw Bioseq right now
323 *      no changes are made to the feature table
324 *
325 *****************************************************************************/
326 NLM_EXTERN Boolean LIBCALL BioseqOverwrite (SeqIdPtr target, Int4 pos, Uint1 residue);
327 
328 /*****************************************************************************
329 *
330 *       Some defined values are provided for the Int4 values passed as
331 *           from, to, and pos in functions above. Defined in seqport.h
332 *   
333 *       FIRST_RESIDUE   0       (first residue of sequence)
334 *       LAST_RESIDUE    -1  (last residue of sequence.. interpreted as
335 *                              length - 1)
336 *       APPEND_RESIDUE  -2  (interpreted as length.. off the end of the
337 *                              sequence. Only for "pos" in BioseqInsert
338 *                              to append to the end of the sequence )
339 *   
340 *
341 *****************************************************************************/
342 
343 
344 
345 
346 
347 /*****************************************************************************
348 *
349 *   Sequence Editing Utilties
350 *       Lower Level Support Routines
351 *
352 *****************************************************************************/
353 
354 
355 /*****************************************************************************
356 *
357 *   SeqFeatDelete()
358 *     0 = no changes made to location or product
359 *     1 = changes made but feature still has some location
360 *     2 = all of sfp->location in deleted interval
361 *
362 *   if (merge)
363 *      1) correct numbers > to by subtraction
364 *      2) do not split intervals spanning the deletion
365 *   else
366 *      1) do not change numbers > to
367 *      2) split intervals which span the deletions
368 *
369 *****************************************************************************/
370 NLM_EXTERN Int2 LIBCALL SeqFeatDelete (SeqFeatPtr sfp, SeqIdPtr target, Int4 from, Int4 to, Boolean merge);
371 
372 NLM_EXTERN Boolean LIBCALL SeqInsertByLoc (SeqIdPtr target, Int4 offset, SeqLocPtr fragment);
373 
374 /*****************************************************************************
375 *
376 *   SeqDeleteByLoc (slp, do_feat, do_split)
377 *       deletes regions referenced by slp
378 *       if do_feat, deletes features in those regions as well
379 *       if do_split, splits intervals crossing the deletion
380 *         else just shortens them.
381 *
382 *****************************************************************************/
383 NLM_EXTERN Boolean LIBCALL SeqDeleteByLoc (SeqLocPtr slp, Boolean do_feat, Boolean do_split);
384 
385 
386 /*****************************************************************************
387 *
388 *   SeqLocAdd(headptr, slp, merge, do_copy)
389 *       creates a linked list of SeqLocs.
390 *       returns a pointer to the last SeqLoc in the chain
391 *       if (merge)
392 *         deletes double NULLs or Nulls at start (application must delete at stop)
393 *         merges adjacent intervals on the same strand
394 *       if (do_copy)
395 *         Makes copies of incoming SeqLocs
396 *         if incoming is merged, deletes the incoming SeqLoc
397 *
398 *       call SeqLocPack(head) to turn into a SeqLoc from a linked list
399 *
400 *****************************************************************************/
401 NLM_EXTERN SeqLocPtr LIBCALL SeqLocAdd (SeqLocPtr PNTR head, SeqLocPtr slp, Boolean merge, Boolean do_copy);
402 
403 /*****************************************************************************
404 *
405 *   SeqLocPackage(head)
406 *     head is a chain of 1 or more SeqLocs connected by slp->next
407 *     Assumes was built by SeqLocAdd to remove redundancy
408 *     Frees the last element if it is a NULL.
409 *     If more than one element left, then packages the chain into a SEQLOC_MIX,
410 *       or SEQLOC_PACKED_INT as appropriate
411 *     returns pointer to the head of the resulting single SeqLoc
412 *
413 *****************************************************************************/
414 NLM_EXTERN SeqLocPtr LIBCALL SeqLocPackage (SeqLocPtr head);
415 
416 /*****************************************************************************
417 *
418 *   SegLocToPartsEx(BioseqPtr seg, SeqLocPtr slp, Boolean nullsBetween)
419 *   SegLocToParts(BioseqPtr seg, SeqLocPtr slp)
420 *       seg must be a segmented Bioseq
421 *       slp must be a SeqLoc on it
422 *       nullsBetween makes order instead of join
423 *       function maps slp to the components of seg
424 *       returns a new SeqLocPtr
425 *       does not delete slp
426 *
427 *****************************************************************************/
428 NLM_EXTERN SeqLocPtr LIBCALL SegLocToPartsEx (BioseqPtr seg, SeqLocPtr slp, Boolean nullsBetween);
429 
430 NLM_EXTERN SeqLocPtr LIBCALL SegLocToParts (BioseqPtr seg, SeqLocPtr slp);
431 
432 
433 
434 /*****************************************************************************
435 *
436 *   SeqLocDelete()
437 *       returns altered head or NULL if nothing left.
438 *   sets changed=TRUE if all or part of loc is deleted
439 *   does NOT set changed if location coordinates are only moved
440 *   if (merge) then corrects coordinates upstream of to
441 *   else
442 *     splits intervals covering from-to, does not correct upstream of to
443 *
444 *****************************************************************************/
445 NLM_EXTERN SeqLocPtr LIBCALL SeqLocDelete (SeqLocPtr head, SeqIdPtr target, Int4 from, Int4 to, Boolean merge, BoolPtr changed);
446 
447 NLM_EXTERN SeqLocPtr LIBCALL SeqLocDeleteEx (SeqLocPtr head, SeqIdPtr target, Int4 from, Int4 to, Boolean merge, BoolPtr changed, BoolPtr partial5, BoolPtr partial3);
448 
449 NLM_EXTERN SeqLocPtr LIBCALL SeqLocSubtract (SeqLocPtr head, SeqLocPtr piece);
450 
451 
452 /*****************************************************************************
453 *
454 *   DeltaSeqsToSeqLocs(dsp)
455 *       converts a chain of delta seqs to seqlocs
456 *       each SeqLit is converted to SeqLoc of type Int with a SeqId of type
457 *          Dbtag where db="Seq\tLit" and objectId.id which is the index of the
458 *          element in the delta seq chain where 1 is the first one.
459 *       Returned SeqLoc is of type "mix" and must be freed by caller.
460 *
461 *****************************************************************************/
462 NLM_EXTERN SeqLocPtr LIBCALL DeltaSeqsToSeqLocs (DeltaSeqPtr dsp);
463 
464 /*****************************************************************************
465 *
466 *   SeqLocsToDeltaSeqs(dsp, slp)
467 *       converts a chain of seqlocs     generated by DeltaSeqToSeqLocs() back into
468 *         delta seqs. dsp is the original chain of DeltaSeqs, which is required
469 *         to convert the delta seqs back.
470 *
471 *****************************************************************************/
472 NLM_EXTERN DeltaSeqPtr LIBCALL SeqLocsToDeltaSeqs (DeltaSeqPtr dsp, SeqLocPtr slp);
473 
474 /*****************************************************************************
475 *
476 *   ISADeltaSeqsToSeqLoc(slp)
477 *       returns Index (> 0) if this (one) SeqLoc was converted from a Delta Seq by
478 *         DeltaSeqsToSeqLocs() by looking for the special Dbtag name
479 *
480 *****************************************************************************/
481 NLM_EXTERN Int4 LIBCALL ISADeltaSeqsToSeqLoc (SeqLocPtr slp);
482 
483 
484 /*****************************************************************************
485 *
486 *   SeqEntryDelFeat(sep, id, from, to, do_split)
487 *       Deletes or truncates features on Bioseq (id) in the range
488 *       from-to, inclusive
489 *       
490 *               Moves features > to left to account for decrease in length
491 *       if do_split, breaks intervals across the deletion
492 *       else just reduces their size
493 *
494 *       If sep == NULL, then calls SeqEntryFind(id) to set scope to look
495 *       for features.
496 *   
497 *****************************************************************************/
498 NLM_EXTERN Boolean      LIBCALL SeqEntryDelFeat PROTO((SeqEntryPtr sep, SeqIdPtr sip, Int4 from, Int4 to, Boolean do_split));
499 
500 /*****************************************************************************
501 *
502 *   SeqFeatCopy(new, old, from, to, strand)
503 *
504 *****************************************************************************/
505 NLM_EXTERN Int2 LIBCALL SeqFeatsCopy (BioseqPtr newbsp, BioseqPtr oldbsp, Int4 from, Int4 to, Uint1 strand);
506 
507 NLM_EXTERN SeqLocPtr LIBCALL SeqLocCopyRegion(SeqIdPtr newid, SeqLocPtr head, BioseqPtr oldbsp,
508     Int4 from, Int4 to, Uint1 strand, BoolPtr split);
509 
510 /*****************************************************************************
511 *
512 *   IntFuzzClip()
513 *       returns TRUE if clipped range values
514 *       in all cases, adjusts and/or complements IntFuzz
515 *       Designed for IntFuzz on SeqLocs
516 *
517 *****************************************************************************/
518 NLM_EXTERN void LIBCALL IntFuzzClip(IntFuzzPtr ifp, Int4 from, Int4 to, Uint1 strand, BoolPtr split);
519 
520 /*****************************************************************************
521 *
522 *   SeqLocInsert()
523 *       alters "head" by inserting "len" residues before "pos" in any SeqLoc
524 *         on the Bioseq "target"
525 *       all SeqLocs not on "target" are unaltered
526 *       for SeqLocs on "target"
527 *          all SeqLocs before "pos" are unaltered
528 *          all SeqLocs >= "pos" are incremented by "len"
529 *          all SeqLocs spanning "pos"
530 *             if "split" == TRUE, are split into two SeqLocs, one to the
531 *               left of the insertion, the other to right
532 *             if "split" != TRUE, the SeqLoc is increased in length to cover
533 *               the insertion
534 *       returns altered head or NULL if nothing left.
535 *       if ("newid" != NULL) replaces "target" with "newid" whether the
536 *          SeqLoc is altered on not.
537 *
538 *       Usage hints:
539 *          1) To update a feature location on "target" when 10 residues of
540 *               sequence have been inserted before position 5
541 *          SeqFeatPtr->location = SeqLocInsert ( SeqFeatPtr->location ,
542 *                "target", 5, 10, TRUE, NULL);  [for some feature types
543 *                      you may want "split" equal FALSE]
544 *   
545 *          2) To insert the complete feature table from "source" into a
546 *                different Bioseq "dest" before position 20 in "dest"
547 *          SFP->location = SeqLocInsert(SFP->location, "source", 0, 20,
548 *                FALSE, "dest");
549 *   
550 *
551 *****************************************************************************/
552 NLM_EXTERN SeqLocPtr LIBCALL SeqLocInsert (SeqLocPtr head, SeqIdPtr target, Int4 pos, Int4 len,
553                                                Boolean split, SeqIdPtr newid);
554 
555 
556 /********************************************************************
557 *
558 * SeqLocReplaceID
559 *   replaces the Seq-Id in a Seq-Loc (slp) with a new Seq-Id (new_sip)
560 *
561 **********************************************************************/
562 NLM_EXTERN SeqLocPtr SeqLocReplaceID (SeqLocPtr slp, SeqIdPtr new_sip);
563 
564 /**********************************************************
565  *
566  *   NLM_EXTERN SeqLocPtr LIBCALL GapToSeqLoc(range):
567  *
568  *      Gets the size of gap and constructs SeqLoc block with
569  *   $(seqlitdbtag) value as Dbtag.db and Dbtag.tag.id = 0.
570  *
571  **********************************************************/
572 NLM_EXTERN SeqLocPtr LIBCALL GapToSeqLoc(Int4 range);
573 
574 /**********************************************************
575  *
576  *   NLM_EXTERN SeqLocPtr LIBCALL GapToSeqLocEx(range, unknown):
577  *
578  *      Gets the size of gap and constructs SeqLoc block with
579  *   $(seqlitdbtag) value in case of gap of known length or
580  *   $(unkseqlitdbtag) value if length is unknown as Dbtag.db
581  *   and Dbtag.tag.id = 0.
582  *
583  **********************************************************/
584 NLM_EXTERN SeqLocPtr LIBCALL GapToSeqLocEx(Int4 range, Boolean unknown);
585 
586 /**********************************************************
587  *
588  *   NLM_EXTERN Boolean LIBCALL ISAGappedSeqLoc(slp):
589  *
590  *      Looks at a single SeqLoc item. If it has the SeqId
591  *   of type GENERAL with Dbtag.db == $(seqlitdbtag) and
592  *   Dbtag.tag.id == 0, then returns TRUE, otherwise
593  *   returns FALSE.
594  *
595  **********************************************************/
596 NLM_EXTERN Boolean LIBCALL ISAGappedSeqLoc(SeqLocPtr slp);
597 
598 /**********************************************************
599  *
600  *   NLM_EXTERN DeltaSeqPtr LIBCALL GappedSeqLocsToDeltaSeqs(slp):
601  *
602  *      This functions is used only in the case, if ISAGappedSeqLoc()
603  *   has returned TRUE.
604  *      Converts SeqLoc set to the sequence of DeltaSeqs.
605  *   Gbtag'ed SeqLocs it turns into SeqLits with the only "length"
606  *   element. The regular SeqLocs saves as they are. Returns
607  *   obtained DeltaSeq.
608  *
609  **********************************************************/
610 NLM_EXTERN DeltaSeqPtr LIBCALL GappedSeqLocsToDeltaSeqs(SeqLocPtr slp);
611 
612 /* the following typedefs and functions are used by the new sequence editor 
613  * in desktop/seqpanel.c
614  */
615 typedef enum { eSeqEdInsert, eSeqEdDelete, eSeqEdFeatMove, eSeqEdTranslate,
616                eSeqEdInsertGap, eSeqEdDeleteGap,
617                eSeqEdJournalStart, eSeqEdJournalEnd } ESeqEdJournalAction ;
618 
619 typedef struct seqedjournaldata
620 {
621   ESeqEdJournalAction action;              /* indicates action taken */
622   Int4                offset;              /* position to the left of deletion or right of insertion */
623   Int4                num_chars;           /* number of characters inserted or deleted */
624   CharPtr             char_data;           /* characters inserted or removed */
625                                            /* when creating a journal entry for deletion, allocate
626                                             * space for char_data but do not populate it - it will
627                                             * be populated when the journal entry is played */
628   Boolean             spliteditmode;       /* if insertion occurs and spliteditmode is true and
629                                             * a feature overlaps the insertion position, the location
630                                             * of the feature will be discontinuous at the point of
631                                             * insertion. */
632   SeqFeatPtr          sfp;                 /* A feature that was moved - should be NULL
633                                             * unless action == eSeqEdFeatMove */
634   SeqLocPtr           slp;                 /* A location for sfp - if the journal has
635                                             * already been played, this is the previous
636                                             * location, if the journal has been undone,
637                                             * this is the location before the redo. */
638   ValNodePtr          affected_feats;      /* This is a list of features which were shortened by
639                                             * an eSeqEdDelete operation - their locations will
640                                             * need to be reconstructed if the operation is undone. */
641   Boolean             unknown_gap;         /* This is used only when action is eSeqEdInsertGap
642                                             * or eSeqEdDeleteGap.  It indicates whether the gap
643                                             * being inserted (or deleted) from a delta sequence
644                                             * is unknown. */                                            
645   BioseqPtr           bsp;                 /* The Bioseq for which the action is to be/was applied. */
646   Uint1               moltype;             /* Molecule type for bsp.  Stored for convenience. */
647   Uint2               entityID;            /* entityID for bsp.  Stored for convenience. */
648   Pointer             next;                /* Journal entries are a doubly-linked list so that */
649   Pointer             prev;                /* we can traverse the list in both directions for  */
650                                            /* undo and redo. */
651 } SeqEdJournalData, PNTR SeqEdJournalPtr;
652 
653 NLM_EXTERN SeqLocPtr LIBCALL 
654 SeqEdSeqLocInsert 
655 (SeqLocPtr head,
656  BioseqPtr target, 
657  Int4 pos,
658  Int4 len,
659  Boolean split,
660  SeqIdPtr newid);
661 
662 NLM_EXTERN void 
663 SeqEdInsertAdjustRNA 
664 (SeqFeatPtr sfp,
665  BioseqPtr  bsp,
666  Int4       insert_pos,
667  Int4       len,
668  Boolean    do_split);
669 
670 NLM_EXTERN void 
671 SeqEdInsertAdjustCdRgn 
672 (SeqFeatPtr sfp,
673  BioseqPtr  bsp,
674  Int4       insert_pos,
675  Int4       len,
676  Boolean    do_split);
677  
678 NLM_EXTERN SeqLocPtr 
679 SeqEdSeqLocDelete 
680 (SeqLocPtr head,
681  BioseqPtr target,
682  Int4      from,
683  Int4      to,
684  Boolean   merge,
685  BoolPtr   changed,
686  BoolPtr   partial5,
687  BoolPtr   partial3);
688 
689 NLM_EXTERN Int2 LIBCALL 
690 SeqEdSeqFeatDelete 
691 (SeqFeatPtr sfp,
692  BioseqPtr  target,
693  Int4       from,
694  Int4       to,
695  Boolean merge);
696 
697 NLM_EXTERN void SeqEdJournalFree (SeqEdJournalPtr sejp);
698 NLM_EXTERN SeqEdJournalPtr SeqEdJournalNewSeqEdit 
699 (ESeqEdJournalAction action,
700  Int4                offset,
701  Int4                num_chars,
702  CharPtr             char_data,
703  Boolean             spliteditmode,
704  BioseqPtr           bsp,
705  Uint1               moltype,
706  Uint2               entityID);
707  
708 NLM_EXTERN SeqEdJournalPtr SeqEdJournalNewFeatEdit
709 (ESeqEdJournalAction action,
710  SeqFeatPtr          sfp,
711  SeqLocPtr           slp,
712  BioseqPtr           bsp,
713  Uint1               moltype,
714  Uint2               entityID);
715  
716 NLM_EXTERN SeqEdJournalPtr SeqEdJournalNewTranslate
717 (SeqFeatPtr sfp,
718  BioseqPtr  bsp,
719  Uint2      entityID);
720 
721 NLM_EXTERN SeqFeatPtr 
722 SeqEdGetNextFeature 
723 (BioseqPtr              bsp, 
724  SeqFeatPtr             curr,
725  Uint1                  seqFeatChoice,
726  Uint1                  featDefChoice,
727  SeqMgrFeatContext PNTR context,
728  Boolean                byLabel,
729  Boolean                byLocusTag,
730  Uint2                  entityID);
731 
732 /* this enum describes the kind of motion for feature adjusts */
733 typedef enum { eLeftEnd=1, eRightEnd, eSlide } EMoveType;
734 
735 /* This function moves a feature location */
736 NLM_EXTERN void SeqEdFeatureAdjust
737 (SeqFeatPtr sfp,
738  SeqLocPtr  orig_loc,
739  Int4       change,
740  EMoveType  move_type,
741  Int4       interval_offset,
742  BioseqPtr  bsp);
743 
744 /* This function locates the endpoints of the Nth interval in a SeqLoc */
745 NLM_EXTERN Boolean SeqEdGetNthIntervalEndPoints 
746 (SeqLocPtr slp, Int4 n, Int4Ptr left, Int4Ptr right);
747 
748 /* this function is used to repair the interval order after a feature location
749  * interval has been dragged around.
750  */
751 NLM_EXTERN void SeqEdRepairIntervalOrder (SeqFeatPtr sfp, BioseqPtr bsp);
752 NLM_EXTERN Boolean SeqEdInsert (SeqEdJournalPtr sejp);
753 NLM_EXTERN void SeqEdReindexAffectedFeatures (Int4 shift_start, Int4 shift_amt, 
754                                           Boolean split, BioseqPtr bsp);
755 NLM_EXTERN void SeqEdReindexFeature (SeqFeatPtr sfp, BioseqPtr bsp);
756 NLM_EXTERN Boolean SeqEdDeleteFromBsp (SeqEdJournalPtr sejp, BoolPtr pfeats_deleted);
757 
758 NLM_EXTERN void 
759 AdjustFeatureForGapChange 
760 (SeqFeatPtr sfp,
761  BioseqPtr  bsp, 
762  Int4       offset, 
763  Int4       len_diff);
764 
765 extern Boolean IsDeltaSeqGap (DeltaSeqPtr dsp);
766 extern Boolean IsDeltaSeqUnknownGap (DeltaSeqPtr dsp);
767 extern Boolean IsDeltaSeqKnownGap (DeltaSeqPtr dsp);
768 extern Boolean DoesSeqLitHaveGapTypeOrLinkage (SeqLitPtr slip);
769 extern Boolean DoesDeltaSeqHaveGapTypeOrLinkage (DeltaSeqPtr dsp);
770 
771 
772 #ifdef __cplusplus
773 }
774 #endif
775 
776 #undef NLM_EXTERN
777 #ifdef NLM_EXPORT
778 #define NLM_EXTERN NLM_EXPORT
779 #else
780 #define NLM_EXTERN
781 #endif
782 
783 #endif
784 

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.