1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
|
/* sequtil.h
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* File Name: sequtil.h
*
* Author: James Ostell
*
* Version Creation Date: 4/1/91
*
* $Revision: 6.6 $
*
* File Description: Sequence Utilities for objseq and objsset
*
* Modifications:
* --------------------------------------------------------------------------
* Date Name Description of modification
* ------- ---------- -----------------------------------------------------
*
*
* $Log: sequtil.h,v $
* Revision 6.6 1999/01/12 18:00:19 kans
* SeqIdComp now ignores version if < 1, and added PRINTID_TEXTID_ACC_VER and PRINTID_TEXTID_ACC_ONLY formats for SeqIdWrite
*
* Revision 6.5 1998/07/28 16:41:09 kans
* added MakeNewProteinSeqIdEx for faster creation of many new protein products
*
* Revision 6.4 1998/02/27 17:10:15 vakatov
* [WIN32 DLL] Declared some functions as NLM_EXTERN(DLL-exportable)
*
* Revision 6.3 1998/02/26 19:14:08 madden
* Added AdjustOffSetsInSeqAlign
*
* Revision 6.2 1998/01/26 17:25:36 madden
* Added TxGetQueryIdFromSeqAlign function
*
* Revision 6.1 1997/10/06 14:01:28 zjing
* move TxGetSubjectId, GetScoreAndEvalue to sequtil.ch
*
* Revision 6.0 1997/08/25 18:07:27 madden
* Revision changed to 6.0
*
* Revision 5.17 1997/08/12 21:25:19 kans
* removed semicolons from SeqEntryList and BioseqList
*
* Revision 5.16 1997/06/19 18:39:03 vakatov
* [WIN32,MSVC++] Adopted for the "NCBIOBJ.LIB" DLL'ization
*
* Revision 5.15 1997/05/19 19:25:53 shavirin
* Added definition for the function CorrectGeneFeatLocation()
*
* Revision 5.14 1997/04/09 18:43:50 tatiana
* *** empty log message ***
*
* Revision 5.13 1997/04/09 18:00:34 tatiana
* added MolTypeForGI()
*
* Revision 5.12 1997/03/28 21:18:38 shavirin
* Added definition for a function BSRebuildDNA_4na()
*
* Revision 5.11 1997/03/06 22:48:21 shavirin
* Moved definitions of SPCompress functions to seqport.h
*
* Revision 5.10 1997/03/06 21:28:25 shavirin
* Added definitions for new set of functions: SPCompressDNA(), SPRebuildDNA(),
* SPCompressNew(), SPCompressFree()
*
* Revision 5.9 1997/03/04 21:59:08 shavirin
* Added definition of function GenericCompressDNA()
*
* Revision 5.8 1997/03/03 22:28:14 shavirin
* Added definition for Compress DNA read/Write function
*
* Revision 5.7 1996/10/15 14:48:08 shavirin
* Added definitions for new functions BSCompressDNA() and
* BSRebuildDNA() handling ambiguity characters.
*
* Revision 5.6 1996/10/10 21:08:25 shavirin
* Added definition for new function Convert4NaRandom(), that randomly
* convert ncbi4na to ncbi2na encoding without SeqMapTable usage
*
* Revision 5.5 1996/08/07 20:12:59 epstein
* move MuskSeqIdWrite, seqid_name, local_id_make and update_seq_loc from jzmisc to sequtil, to untangle the desktop and tools libraries from one another
*
* Revision 5.4 1996/07/15 14:42:42 epstein
* add SeqEntryContainsSeqIdOfMolType() and FindCodingRegion()
*
* Revision 5.3 1996/06/24 18:38:33 epstein
* move splicing functionality to sequtil.c
*
* Revision 5.2 1996/06/16 15:19:31 ostell
* added delta seq support to SeqEntryPack
*
* Revision 5.1 1996/06/12 18:29:25 epstein
* move SeqLocIntNew() and SeqLocPntNew() from edutil to sequtil
*
* Revision 5.0 1996/05/28 13:23:23 ostell
* Set to revision 5.0
*
* Revision 4.3 1996/03/11 19:06:43 ostell
* added MakeNewProteinSeqId()
*
* Revision 4.2 1996/01/31 16:09:15 tatiana
* StringForSeqTech() added by Tatiana
*
* Revision 4.1 1995/10/17 04:15:37 ostell
* added SeqLocFindPart()
* made SeqLocFindNext() call it
* added equiv_is_one to IS_one_loc()
*
* Revision 4.0 1995/07/26 13:49:01 ostell
* force revision to 4.0
*
* Revision 2.30 1995/07/18 19:54:32 tatiana
* add SeqIdWrite() to replace SeqIdPrint()
*
* Revision 2.29 1995/06/14 16:31:59 kans
* EntrezASN1Detected function added (to be used by Sequin and ID)
*
* Revision 2.28 1995/05/19 04:02:08 ostell
* added SeqLocAinB()
*
* Revision 2.27 1995/05/15 21:46:05 ostell
* added Log line
*
*
*
* ==========================================================================
*/
#ifndef _NCBI_SeqUtil_
#define _NCBI_SeqUtil_
#ifndef _NCBI_Seqset_
#include <objsset.h> /* the object loader interface */
#endif
#ifndef _NCBI_SeqMgr_
#include <seqmgr.h> /* the Bioseq and SeqEntry manager */
#endif
#undef NLM_EXTERN
#ifdef NLM_IMPORT
#define NLM_EXTERN NLM_IMPORT
#else
#define NLM_EXTERN extern
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
*
* What am I?
*
*****************************************************************************/
NLM_EXTERN Uint1 Bioseq_repr PROTO((BioseqPtr bsp));
NLM_EXTERN Uint1 BioseqGetCode PROTO((BioseqPtr bsp));
NLM_EXTERN ValNodePtr BioseqGetSeqDescr PROTO((BioseqPtr bsp, Int2 type, ValNodePtr curr));
NLM_EXTERN CharPtr BioseqGetTitle PROTO((BioseqPtr bsp));
NLM_EXTERN NumberingPtr BioseqGetNumbering PROTO((BioseqPtr bsp));
NLM_EXTERN Int4 BioseqGetLen PROTO((BioseqPtr bsp));
NLM_EXTERN Int4 BioseqGetGaps PROTO((BioseqPtr bsp));
NLM_EXTERN Int4 BioseqGetSegLens PROTO((BioseqPtr bsp, Int4Ptr lens));
#define BioseqCountSegs(x) BioseqGetSegLens(x, NULL)
NLM_EXTERN Boolean BioseqConvert PROTO((BioseqPtr bsp, Uint1 newcode));
NLM_EXTERN Boolean BioseqPack PROTO((BioseqPtr bsp));
NLM_EXTERN Boolean SeqLitPack PROTO((SeqLitPtr slp));
NLM_EXTERN Boolean BioseqRawConvert PROTO((BioseqPtr bsp, Uint1 newcode));
NLM_EXTERN Boolean BioseqRawPack PROTO((BioseqPtr bsp));
NLM_EXTERN ByteStorePtr BSConvertSeq PROTO((ByteStorePtr bsp, Uint1 newcode, Uint1 oldcode, Int4 seqlen));
NLM_EXTERN ByteStorePtr BSPack PROTO((ByteStorePtr from, Uint1 oldcode, Int4 length, Uint1Ptr newcodeptr));
NLM_EXTERN CharPtr StringForSeqMethod PROTO((Int2 method));
NLM_EXTERN CharPtr StringForSeqTech PROTO((Int2 tech));
/*****************************************************************************
*
* Hook function definition for DNA Compression
*
*****************************************************************************/
typedef Int4 (*CompressRWFunc) PROTO ((Pointer data,
Uint1Ptr buf, Int4 length));
/*****************************************************************************
*
* SeqCodeTable routines
* SeqMapTable routines
* Convert and Comp return INVALID_RESIDUE when a residue is out of range
*
*****************************************************************************/
#define INVALID_RESIDUE 255
/*****************************************************************************
*
* SeqCodeTablePtr SeqCodeTableFind(code)
* Sequence codes defined in objseq.h
*
*****************************************************************************/
NLM_EXTERN SeqCodeTablePtr LIBCALL SeqCodeTableFind PROTO((Uint1 code));
/*****************************************************************************
*
* SeqCodeTableComp(sctp, residue)
* returns complement of residue if possible
* or residue, if not
* assumes residue is in the same code as sctp
*
*****************************************************************************/
NLM_EXTERN Uint1 SeqCodeTableComp PROTO((SeqCodeTablePtr sctp, Uint1 residue));
/*****************************************************************************
*
* OneLetterCode(sctp)
* returns TRUE if sequence code table sctp uses one letter symbols
*
*****************************************************************************/
NLM_EXTERN Boolean OneLetterCode PROTO((SeqCodeTablePtr sctp));
/*****************************************************************************
*
* FirstResidueInCode(sctp)
* returns first valid residue code in sequence code table
*
*****************************************************************************/
NLM_EXTERN Uint1 FirstResidueInCode PROTO((SeqCodeTablePtr sctp));
/*****************************************************************************
*
* LastResidueInCode(sctp)
* returns last valid residue code in sequence code table
* nb: some codes have "holes", a range of invalid values between first
* and last.
*
*****************************************************************************/
NLM_EXTERN Uint1 LastResidueInCode PROTO((SeqCodeTablePtr sctp));
/*****************************************************************************
*
* GetSymbolForResidue(sctp, residue)
* returns the ONE LETTER symbol for residue if sequence code has one
* letter symbols. returns INVALID_RESIDUE if not a valid residue or if
* sequence code uses multi-letter symbols
*
*****************************************************************************/
NLM_EXTERN Uint1 GetSymbolForResidue PROTO((SeqCodeTablePtr sctp, Uint1 residue));
/*****************************************************************************
*
* GetResidueForSymbol(sctp, residue)
* returns the residue for a ONE LETTER if sequence code has one
* letter symbols. returns INVALID_RESIDUE if not a valid symbol or if
* sequence code uses multi-letter symbols
* CASE matters
*
*****************************************************************************/
NLM_EXTERN Uint1 GetResidueForSymbol PROTO((SeqCodeTablePtr sctp, Uint1 symbol));
/*****************************************************************************
*
* GetLongSymbolForResidue(sctp, residue)
* returns string symbol for residue if sequence code has string
* symbols. returns NULL if not a valid residue or if
* sequence code uses One letter symbols
*
*****************************************************************************/
NLM_EXTERN const char * GetLongSymbolForResidue PROTO((SeqCodeTablePtr sctp, Uint1 residue));
/*****************************************************************************
*
* GetResidueForLongSymbol(sctp, symbol)
* returns the residue for a STRING symbol if sequence code has string
* symbols. returns INVALID_RESIDUE if not a valid symbol or if
* sequence code uses one-letter symbols
* CASE matters
*
*****************************************************************************/
NLM_EXTERN Uint1 GetResidueForLongSymbol PROTO((SeqCodeTablePtr sctp, CharPtr symbol));
/*****************************************************************************
*
* const char * GetNameForResidue (sctp, residue)
* returns the descriptive name (eg. "Leucine") for a residue in the
* sequence code defined by sctp
* returns NULL if not a valid code in the alphabet
* nb: some codes have "holes" in them, regions of values that are
* invalid.
*
*****************************************************************************/
NLM_EXTERN const char * GetNameForResidue PROTO((SeqCodeTablePtr sctp, Uint1 residue));
/*****************************************************************************
*
* SeqMapTablePtr SeqMapTableFind(to, from)
* Map from sequence code "from" to sequence code "to"
* Sequence codes defined in objseq.h
*
*****************************************************************************/
NLM_EXTERN SeqMapTablePtr LIBCALL SeqMapTableFind PROTO((Uint1 to, Uint1 from));
/*****************************************************************************
*
* SeqMapTableConvert(smtp, from)
* returns conversion of "from" using SeqMapTable smtp
*
*****************************************************************************/
NLM_EXTERN Uint1 SeqMapTableConvert PROTO((SeqMapTablePtr smtp, Uint1 residue));
/*****************************************************************************
*
* Convert4NaRandom(from, to)
* Converts Seq_code_ncbi4na "from" to Seq_code_ncbi2na "to"
* with random conversions
* Return TRUE if conversion done without randomization
*****************************************************************************/
NLM_EXTERN Boolean Convert4NaRandom PROTO((Uint1 from, Uint1 PNTR to));
/*****************************************************************************
*
* BSCompressDNA(bytestoreptr, len, lbytes)
* converts a ncbi4na bytestore into ncbi2na
* returns pointer to ambiguity storage
* lbytes[0] == length of this storage
* frees old bytestore
* returns pointer to new one, or NULL on fail.
* len is residues
*
*****************************************************************************/
NLM_EXTERN ByteStorePtr BSCompressDNA PROTO((ByteStorePtr from, Int4 len,
Uint4Ptr PNTR lbytes));
/* To be removed */
NLM_EXTERN ByteStorePtr BSCompressDNAOld PROTO((ByteStorePtr from, Int4 len,
Uint4Ptr PNTR lbytes));
/*****************************************************************************
*
* GenericCompressDNA()
* converts from VoidPtr "from" in 4na encoding to
* VoidPtr "to" in 2Na encoding
* returns pointer to ambiguity storage
* lbytes[0] == length of this storage
* returns TRUE if succeded, or FALSE on fail.
* seq_len is maximum number of residues in sequence
* or ((Uint4) -1) if final length is unknown.
* read_func and write_func - hook functions to read from "from"
* and to write to "to"
*
* NOTE! read_func must return number of residues read, that usualy
* twice as much as returned number of bytes. Only last returned
* byte may have only one residue and this will be handled by
* seq_len value or returned value from read_func()
*****************************************************************************/
NLM_EXTERN Boolean GenericCompressDNA PROTO((VoidPtr from,
VoidPtr to,
Uint4 length,
CompressRWFunc read_func,
CompressRWFunc write_func,
Uint4Ptr PNTR lbytes));
/*****************************************************************************
*
* BSRebuildDNA(bytestoreptr, len, lbytes)
* restore ASCII sequence with abmiguity characters
* lbytes[0] == length of this storage
* frees old bytestore
* returns pointer to new one, or NULL on fail.
* len is residues
* lbytes is pointer to ambiguity storage
*
*****************************************************************************/
NLM_EXTERN ByteStorePtr BSRebuildDNA PROTO((ByteStorePtr from, Int4 len,
Uint4Ptr PNTR lbytes));
/*****************************************************************************
*
* BSRebuildDNA_4na(bytestoreptr, lbytes)
* restore ncbi4na sequence with abmiguity characters
* lbytes[0] == length of this storage
* frees old bytestore
* returns pointer to new one, or NULL on fail.
* lbytes is pointer to ambiguity storage
*
*****************************************************************************/
NLM_EXTERN ByteStorePtr BSRebuildDNA_4na (ByteStorePtr from, Uint4Ptr lbytes);
/*****************************************************************************
*
* void NaI2TableFree(void)
* Free allocated memory for
* Seq_code_iupacna --> Seq_code_ncbi2na transfer
*****************************************************************************/
NLM_EXTERN void NaI2TableFree(void);
/*****************************************************************************
*
* Numbering routines
*
*****************************************************************************/
/* convert any numbering value to seq offset */
NLM_EXTERN Int4 NumberingOffset PROTO((NumberingPtr np, DataValPtr avp));
/* convert seq offset to numbering value */
NLM_EXTERN Int2 NumberingValue PROTO((NumberingPtr np, Int4 offset, DataValPtr avp));
NLM_EXTERN Int2 NumberingValueBySeqId PROTO((SeqIdPtr sip, Int4 offset, DataValPtr avp));
NLM_EXTERN void NumberingDefaultLoad PROTO((void));
NLM_EXTERN NumberingPtr NumberingDefaultGet PROTO((void));
/*****************************************************************************
*
* SeqEntry and BioseqSet stuff
*
*****************************************************************************/
NLM_EXTERN Uint1 Bioseq_set_class PROTO((SeqEntryPtr sep));
/*****************************************************************************
*
* traversal routines
* SeqEntry - any type
*
*****************************************************************************/
typedef void (* SeqEntryFunc) PROTO((SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent));
NLM_EXTERN Int4 SeqEntryList PROTO((SeqEntryPtr sep, Pointer mydata, SeqEntryFunc mycallback, Int4 index, Int2 indent));
#define SeqEntryCount( a ) SeqEntryList( a ,NULL,NULL,0,0)
#define SeqEntryExplore(a,b,c) SeqEntryList(a, b, c, 0L, 0)
/*****************************************************************************
*
* void CorrectGeneFeatLocation(sep, data, n, m)
*
* Correct gene location for mRNA sequences, i.e.
* puts start = 0, end = total_length_of_sequence - 1.
*
*****************************************************************************/
NLM_EXTERN void CorrectGeneFeatLocation(SeqEntryPtr sep, Pointer data,
Int4 n, Int2 m);
/*****************************************************************************
*
* traversal routines
* Bioseq types only - "individual" sequences
* do NOT traverse component parts of seqmented or constructed types
*
*****************************************************************************/
NLM_EXTERN Int4 BioseqList PROTO((SeqEntryPtr sep, Pointer mydata, SeqEntryFunc mycallback, Int4 index, Int2 indent));
#define BioseqCount( a ) BioseqList( a ,NULL,NULL,0,0)
#define BioseqExplore(a,b,c) BioseqList(a, b, c, 0L, 0)
/*****************************************************************************
*
* Get parts routines
*
*****************************************************************************/
/* gets next Seqdescr after curr in sep of type type */
NLM_EXTERN ValNodePtr SeqEntryGetSeqDescr PROTO((SeqEntryPtr sep, Int2 type, ValNodePtr curr));
/* gets first title from sep */
NLM_EXTERN CharPtr SeqEntryGetTitle PROTO((SeqEntryPtr sep));
/*****************************************************************************
*
* Manipulations
*
*****************************************************************************/
NLM_EXTERN Boolean SeqEntryConvert PROTO((SeqEntryPtr sep, Uint1 newcode));
#define SeqEntryPack(x) SeqEntryConvert(x, (Uint1)0)
/*****************************************************************************
*
* SeqLoc stuff
*
*****************************************************************************/
#define PRINTID_FASTA_SHORT ( (Uint1)1)
#define PRINTID_FASTA_LONG ( (Uint1)2)
#define PRINTID_TEXTID_LOCUS ( (Uint1)3)
#define PRINTID_TEXTID_ACCESSION ( (Uint1)4)
#define PRINTID_REPORT ( (Uint1)5)
#define PRINTID_TEXTID_ACC_VER ( (Uint1)6)
#define PRINTID_TEXTID_ACC_ONLY ( (Uint1)7)
/*****************************************************************************
*
* SeqIdPtr SeqIdLocate (sip, order, num)
* Given a SeqId (sip):
* Locates the Bioseq in memory or cached
* Then calls SeqIdSelect with the Bioseq.id chain to find the
* SeqId type you want.
*
*****************************************************************************/
NLM_EXTERN SeqIdPtr SeqIdLocate PROTO((SeqIdPtr sip, Uint1Ptr order, Int2 num));
/*****************************************************************************
*
* SeqIdPtr SeqIdSelect (sip, order, num)
* takes an array (order) num long.
* goes down chain starting with sip.
* finds lowest value of order[sip->choice] and returns it.
* if order[] == 255, it is skipped.
* if nothing is found < 255, NULL is returned
* ErrorMessage if sip->choice >= num
*
*****************************************************************************/
NLM_EXTERN SeqIdPtr SeqIdSelect PROTO((SeqIdPtr sip, Uint1Ptr order, Int2 num));
NLM_EXTERN Int2 SeqIdBestRank PROTO((Uint1Ptr buf, Int2 num));
NLM_EXTERN SeqIdPtr SeqIdFindBest PROTO(( SeqIdPtr sip, Uint1 target));
NLM_EXTERN CharPtr SeqIdPrint PROTO((SeqIdPtr sip, CharPtr buf, Uint1 format));
NLM_EXTERN CharPtr SeqIdWrite PROTO((SeqIdPtr sip, CharPtr buf, Uint1 format, Int2 buflen));
NLM_EXTERN SeqIdPtr SeqIdParse PROTO((CharPtr buf));
/*****************************************************************************
*
* MakeNewProteinSeqId(SeqLocPtr slp, SeqIdPtr sip)
* Makes a new protein SeqId of attempting to keep it unique
* Trys to match it to the input seqid type
* slp is the location on the DNA of the coding region making the protein
* sip is the SeqId of the DNA coding for the protein
* if (sip != NULL) uses it for a "base" first
* else if (slp != NULL) uses a SeqId from it for a base
* else base is the string tmpprot
*
* id is then base_X where X is a number assigned as a serial number
* the returned id is guaranteed to be unique among all Bioseqs currently
* loaded in memory.
*
* MakeNewProteinSeqIdEx(SeqLocPtr slp, SeqIdPtr sip, Int2 ctrptr)
* Allows you to indicate a starting count for the X in base_X, and returns
* the next count for improved speed when allocating many protein bioseqs
*
*****************************************************************************/
NLM_EXTERN SeqIdPtr LIBCALL MakeNewProteinSeqIdEx PROTO((SeqLocPtr slp, SeqIdPtr sip, Int2Ptr ctrptr));
NLM_EXTERN SeqIdPtr LIBCALL MakeNewProteinSeqId PROTO((SeqLocPtr slp, SeqIdPtr sip));
/*****************************************************************************
*
* Boolean BioseqMatch(bsp, seqid)
* returns TRUE if bsp points to the Bioseq identified by seqid
*
*****************************************************************************/
NLM_EXTERN Boolean BioseqMatch PROTO((BioseqPtr bsp, SeqIdPtr sip));
NLM_EXTERN BioseqPtr BioseqFindInSeqEntry PROTO((SeqIdPtr sip, SeqEntryPtr sep));
/*****************************************************************************
*
* Boolean SeqIdMatch(a, b)
* returns TRUE if SeqIds could be compared and are the same
* returns FALSE both if SeqIds could not be compared OR if they were
* compared but are different
*
* WARNING!!!! use SeqIdComp() instead of SeqIdMatch() in most cases
*
* The code here must work the same is in two idloader
* context: function id_flatten_seq_obj (idsybase.c)
* and proc id_id_flatten_seq_obj
*
*****************************************************************************/
NLM_EXTERN Boolean SeqIdMatch PROTO((SeqIdPtr a, SeqIdPtr b));
/*****************************************************************************
*
* SeqIdComp(a, b)
* Compares a to b and returns
*
* SIC_DIFF = different types, could not be compared
* SIC_NO = types could be compared, and ids are different
* SIC_YES = types could be compared, and ids are the same
*
*****************************************************************************/
NLM_EXTERN Uint1 SeqIdComp PROTO((SeqIdPtr a, SeqIdPtr b));
#define SIC_DIFF 1
#define SIC_NO 0
#define SIC_YES 2
/*************************
SeqIdForSameBioseq(a,b)
trys to locate all ids for a or b and determine
if (a and b refer the the same Bioseq)
**************************/
NLM_EXTERN Boolean SeqIdForSameBioseq PROTO((SeqIdPtr a, SeqIdPtr b));
/*************************
* Boolean SeqIdIn (a,b)
* returns TRUE if a in list of b
******************/
NLM_EXTERN Boolean SeqIdIn PROTO((SeqIdPtr a, SeqIdPtr b));
/*****************************************************************************
*
* SeqLocFindNext()
* just calls SeqLocFindPart(seqlochead, currseqloc, EQUIV_IS_MANY)
*
*****************************************************************************/
NLM_EXTERN SeqLocPtr SeqLocFindNext PROTO((SeqLocPtr seqlochead, SeqLocPtr currseqloc));
/*****************************************************************************
*
* SeqLocFindPart(seqlochead, currseqloc, equiv_status)
* finds the next Seq-loc after currseqloc
* seqlochead is the first of a chain of Seq-locs
* equiv_status defines how to treat SEQLOC_EQUIV
* EQUIV_IS_MANY = treat same as SEQLOC_MIX
* EQUIV_IS_ONE = return SEQLOC_EQUIV as one Seq-loc
* FIRST_EQUIV_IS_MANY = if seqlochead is a SEQLOC_EQUIV, enter the
* the chain of Seq-locs, but treat any later EQUIVs as
* EQUIV_IS_ONE.
*
*****************************************************************************/
NLM_EXTERN SeqLocPtr SeqLocFindPart PROTO((SeqLocPtr seqlochead, SeqLocPtr currseqloc, Uint1 equiv_status));
#define EQUIV_IS_MANY 0 /* treat SEQLOC_EQUIV same as SEQLOC_MIX */
#define EQUIV_IS_ONE 1 /* treat SEQLOC_EQUIV as one Seq-loc */
#define FIRST_EQUIV_IS_MANY 2 /* treat only first EQUIV as SEQ_LOC_MIX */
NLM_EXTERN Boolean IS_one_loc PROTO((SeqLocPtr anp, Boolean equiv_is_one)); /* for SeqLoc */
NLM_EXTERN Int4 SeqLocStart PROTO((SeqLocPtr seqloc));
NLM_EXTERN Int4 SeqLocStop PROTO((SeqLocPtr seqloc));
NLM_EXTERN Uint1 SeqLocStrand PROTO((SeqLocPtr seqloc));
NLM_EXTERN Int4 SeqLocLen PROTO((SeqLocPtr seqloc));
NLM_EXTERN Int4 SeqLocGetSegLens PROTO((SeqLocPtr slp, Int4Ptr lens, Int4 ctr, Boolean gaps));
#define SeqLocCountSegs(x) SeqLocGetSegLens(x, NULL,0,FALSE)
#define SeqLocGetGaps(x) SeqLocGetSegLens(x,NULL,0,TRUE)
NLM_EXTERN SeqIdPtr SeqLocId PROTO((SeqLocPtr seqloc));
NLM_EXTERN Uint1 StrandCmp PROTO((Uint1 strand));
NLM_EXTERN Boolean SeqLocRevCmp PROTO((SeqLocPtr anp));
/**** defines for "which_end" below ****/
#define SEQLOC_LEFT_END 1 /* low numbered end of SeqLoc */
#define SEQLOC_RIGHT_END 2 /* high numbered end of SeqLoc */
#define SEQLOC_START 3 /* beginning of SeqLoc (low on plus, high on minus) */
#define SEQLOC_STOP 4 /* end of SeqLoc (high on plus, low on minus) */
NLM_EXTERN Int4 GetOffsetInLoc PROTO((SeqLocPtr of, SeqLocPtr in, Uint1 which_end));
NLM_EXTERN Int4 GetOffsetInBioseq PROTO((SeqLocPtr of, BioseqPtr in, Uint1 which_end));
NLM_EXTERN Int2 SeqLocOrder PROTO((SeqLocPtr a, SeqLocPtr b, BioseqPtr in));
NLM_EXTERN Int2 SeqLocMol PROTO((SeqLocPtr seqloc));
NLM_EXTERN CharPtr SeqLocPrint PROTO((SeqLocPtr slp));
/*****************************************************************************
*
* SeqLocCompare(a, b)
* returns
* 0 = no overlap
* 1 = a is completely contained in b
* 2 = b is completely contained in a
* 3 = a == b
* 4 = a and b overlap, but neither completely contained in the other
*
*****************************************************************************/
NLM_EXTERN Int2 SeqLocCompare PROTO((SeqLocPtr a, SeqLocPtr b));
#define SLC_NO_MATCH 0
#define SLC_A_IN_B 1
#define SLC_B_IN_A 2
#define SLC_A_EQ_B 3
#define SLC_A_OVERLAP_B 4
/*****************************************************************************
*
* SeqLocAinB(a, b)
* if a is completely contained in b, a positive number is returned
* if 0, a is identical with b
* if not 0, is the number of residues bigger b is than a
* if a negative number is returned, a is not contained in b
* could overlap or not
* used to find features contained in genes
*
*****************************************************************************/
NLM_EXTERN Int4 SeqLocAinB PROTO((SeqLocPtr a, SeqLocPtr b));
NLM_EXTERN Boolean SeqIntCheck PROTO((SeqIntPtr sip)); /* checks for valid interval */
NLM_EXTERN Boolean SeqPntCheck PROTO((SeqPntPtr spp)); /* checks valid pnt */
NLM_EXTERN Boolean PackSeqPntCheck PROTO ((PackSeqPntPtr pspp));
NLM_EXTERN Uint1 SeqLocCheck PROTO ((SeqLocPtr slp));
#define SEQLOCCHECK_OK 2 /* location is fine */
#define SEQLOCCHECK_WARNING 1 /* location ok, but has mixed strands */
#define SEQLOCCHECK_ERROR 0 /* error in location */
/*****************************************************************************
*
* SeqLocPartialCheck(head)
* sets bits for incomplete location and/or errors
* incomplete defined as Int-fuzz on start or stop with
* lim.unk, lim.gt, or lim.lt set
*
* SLP_COMPLETE = not partial and no errors
* SLP_START = incomplete on start (high number on minus strand, low on plus)
* SLP_STOP = incomplete on stop
* SLP_INTERNAL = lim set on internal intervals
* SLP_OTHER = partial location, but no details available
* SLP_NOSTART = start does not include end of sequence
* SLP_NOSTOP = stop does not include end of sequence
* SLP_NOINTERNAL = internal interval not on end of sequence
* SLP_LIM_WRONG = lim gt/lt used inconsistently with position in location
*
* SLP_HAD_ERROR = if AND with return, is TRUE if any errors encountered
*
*****************************************************************************/
#define SLP_COMPLETE 0
#define SLP_START 1
#define SLP_STOP 2
#define SLP_INTERNAL 4
#define SLP_OTHER 8
#define SLP_NOSTART 16
#define SLP_NOSTOP 32
#define SLP_NOINTERNAL 64
#define SLP_LIM_WRONG 128
#define SLP_HAD_ERROR 240
NLM_EXTERN Uint2 SeqLocPartialCheck PROTO((SeqLocPtr head));
NLM_EXTERN CharPtr TaxNameFromCommon PROTO((CharPtr common));
/*****************************************************************************
*
* QualLocCreate(from, to)
* creates a UserObject of _class NCBI, type 1
* adds a field of type "qual_loc"
* puts the from and to numbers in
* These should be offsets, as in a Seq-loc, not numbers starting from
* one.
* no range check, no strand, no seqid
* this just carries locations for the qualifiers anticodon and rpt_unit
* Intended to go on SeqFeat.ext
*
*****************************************************************************/
NLM_EXTERN UserObjectPtr QualLocCreate PROTO((Int4 from, Int4 to));
/*****************************************************************************
*
* QualLocWrite(uop, buf)
* Checks a SeqFeat.ext to see if it is
* 1) not null
* 2) has a UserObject of _class NCBI, type 1
* 3) has a field of label "qual_loc"
* 4) if so, prints the two integers as a qualifier location
* from..to and returns a pointer to the \0 after "to"
* Adds 1 to the internal numbers to convert from offset to
* number starting with 1
* If any of the above fail, returns NULL
*
*****************************************************************************/
NLM_EXTERN CharPtr QualLocWrite PROTO((UserObjectPtr uop, CharPtr buf));
/*****************************************************************************
*
* EntrezASN1Detected detects records retrieved from Entrez, which should
* not be edited by Sequin and replaced into ID.
*
*****************************************************************************/
NLM_EXTERN Boolean EntrezASN1Detected (SeqEntryPtr sep);
/*****************************************************************************
*
* SeqLocIntNew(Int4 from, Int4 to, Uint1 strand, SeqIdPtr sip)
* creates a new SeqLoc of type SeqInt
* makes copy of incoming SeqId
*
*****************************************************************************/
NLM_EXTERN SeqLocPtr LIBCALL SeqLocIntNew (Int4 from, Int4 to, Uint1 strand, SeqIdPtr sip);
/*****************************************************************************
*
* SeqLocPntNew(Int4 pos, Uint1 strand, SeqIdPtr sip, Boolean is_fuzz)
* creates a new SeqLoc of type SeqPnt
* makes copy of incoming SeqId
*
*****************************************************************************/
NLM_EXTERN SeqLocPtr LIBCALL SeqLocPntNew (Int4 pos, Uint1 strand, SeqIdPtr sip, Boolean is_fuzz);
/*****************************************************************************
*
* SeqLocPtr FindSpliceSites(SeqEntryPtr sep, Boolean findOnProtein)
* Finds the splice sites on this SeqEntry and returns them as a
* SeqLoc.
*
*****************************************************************************/
NLM_EXTERN SeqLocPtr LIBCALL FindSpliceSites(SeqEntryPtr sep, Boolean findOnProtein);
/***************************************************************************
**
*
* SeqFeatPtr FindCodingRegion(SeqEntryPtr sep)
* Finds the coding region feature on this protein SeqEntry and
* returns a copy of it.
*
****************************************************************************
*/
NLM_EXTERN SeqFeatPtr LIBCALL FindCodingRegion(SeqEntryPtr sep);
/*****************************************************************************
*
* Boolean LIBCALL SeqEntryContainsSeqIdOfMolType(SeqEntryPtr sep, SeqIdPtr sip, Boolean isProtein)
* Tests to see if this SeqEntry contains a bioseq of the specified moltype
* (protein or DNA)
* if sip != NULL then it also insists upon finding a bioseq of the
* specified moltype where the SeqIds match
*
*****************************************************************************/
NLM_EXTERN Boolean LIBCALL SeqEntryContainsSeqIdOfMolType(SeqEntryPtr sep, SeqIdPtr sip, Boolean isProtein);
/*****************************************************************************
*
* Tests to see if this SeqEntry contains a bioseq of the specified uid
* returns moltype of the bioseq where the SeqIds match
* 0 id not found in this SeqEntry
* 1 Amino Acid sequence
* 2 Nucleotide sequence
*
*****************************************************************************/
NLM_EXTERN Int2 LIBCALL MolTypeForGI(SeqEntryPtr sep, Int4 uid);
/* moved from jzmisc.h */
NLM_EXTERN Boolean seqid_name(SeqIdPtr, CharPtr, Boolean, Boolean);
NLM_EXTERN Boolean MuskSeqIdWrite PROTO((SeqIdPtr sip, CharPtr buf, Int2 buflen, Uint1 format, Boolean do_find, Boolean do_entrez_find));
NLM_EXTERN SeqIdPtr local_id_make(CharPtr);
NLM_EXTERN SeqLocPtr update_seq_loc(Int4, Int4, Uint1, SeqLocPtr );
NLM_EXTERN SeqIdPtr LIBCALL TxGetSubjectIdFromSeqAlign PROTO((SeqAlignPtr seqalign));
NLM_EXTERN SeqIdPtr LIBCALL TxGetQueryIdFromSeqAlign PROTO((SeqAlignPtr seqalign));
NLM_EXTERN Boolean LIBCALL GetScoreAndEvalue PROTO((
SeqAlignPtr seqalign, Int4 *score,
Nlm_FloatHi *bit_score,
Nlm_FloatHi *evalue, Int4 *number
));
/***********************************************************************
*
* Adjust the Offset in the SeqAlign to correspond to the beginning
* of the sequence and not where BLAST (or some other tool) started.
*
**********************************************************************/
NLM_EXTERN void LIBCALL AdjustOffSetsInSeqAlign PROTO((SeqAlignPtr salp, SeqLocPtr slp1, SeqLocPtr slp2));
#ifdef __cplusplus
}
#endif
#undef NLM_EXTERN
#ifdef NLM_EXPORT
#define NLM_EXTERN NLM_EXPORT
#else
#define NLM_EXTERN
#endif
#endif
|