1 /*  objloc.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 loclic 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:  objloc.h
27 *
28 * Author:  James Ostell
29 *
30 * Version Creation Date: 4/1/91
31 *
32 * $Revision: 6.8 $
33 *
34 * File Description:  Object manager interface for module NCBI-Seqloc
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date	   Name        Description of modification
39 * -------  ----------  -----------------------------------------------------
40 *
41 *
42 * $Log: objloc.h,v $
43 * Revision 6.8  2015/08/13 22:36:04  kans
44 * NOJIRA Added support for PDB chain_id field
45 *
46 * Revision 6.7  2008/09/23 18:40:13  kans
47 * increased NUM_SEQID
48 *
49 * Revision 6.6  2008/09/15 18:44:37  kans
50 * added support for SEQID_NAMED_ANNOT_TRACK
51 *
52 * Revision 6.5  2005/04/26 21:33:00  kans
53 * added SEQID_GPIPE
54 *
55 * Revision 6.4  2005/03/10 17:18:43  kans
56 * added SeqLocCopy as a convenience function in ncbiobj library
57 *
58 * Revision 6.3  2001/08/06 20:07:26  ostell
59 * added SEQID_TPG, TPE, TPD types
60 *
61 * Revision 6.2  2001/01/31 15:24:20  kans
62 * PatentSeqId.seqid is now an Int4 (JO)
63 *
64 * Revision 6.1  2000/04/05 18:11:41  dondosha
65 * Moved SeqIdSetDup from mblast.h
66 *
67 * Revision 6.0  1997/08/25 18:50:07  madden
68 * Revision changed to 6.0
69 *
70 * Revision 4.1  1997/06/19 18:41:32  vakatov
71 * [WIN32,MSVC++]  Adopted for the "NCBIOBJ.LIB" DLL'ization
72 *
73 * Revision 4.0  1995/07/26 13:48:06  ostell
74 * force revision to 4.0
75 *
76  * Revision 3.3  1995/05/09  18:04:44  ostell
77  * added NUM_SEGID to define how many SeqId classes there are
78  *
79 *
80 *
81 * ==========================================================================
82 */
83 
84 #ifndef _NCBI_Seqloc_
85 #define _NCBI_Seqloc_
86 
87 #ifndef _ASNTOOL_
88 #include <asn.h>
89 #endif
90 #ifndef _NCBI_General_
91 #include <objgen.h>
92 #endif
93 #ifndef _NCBI_Biblio_
94 #include <objbibli.h>
95 #endif
96 
97 typedef ValNode SeqId, FAR *SeqIdPtr;
98 typedef ValNode SeqLoc, FAR *SeqLocPtr;
99 
100 #ifndef _NCBI_Seqfeat_
101 #include <objfeat.h>      /* after Seqloc to avoid cycles */
102 #endif
103 
104 #undef NLM_EXTERN
105 #ifdef NLM_IMPORT
106 #define NLM_EXTERN NLM_IMPORT
107 #else
108 #define NLM_EXTERN extern
109 #endif
110 
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114 
115 /*****************************************************************************
116 *
117 *   Seqloc loader
118 *
119 *****************************************************************************/
120 NLM_EXTERN Boolean	LIBCALL SeqLocAsnLoad PROTO((void));
121 
122 /*****************************************************************************
123 *
124 *   internal structures for NCBI-Seqloc objects
125 *
126 *****************************************************************************/
127 
128 /*****************************************************************************
129 *
130 *   SeqId is a choice using an ValNode, most types in data.ptrvalue
131 *      except integers, in data.intvalue
132 *   choice:
133 *   0 = not set
134     1 = local Object-id ,        -- local use
135     2 = gibbsq INTEGER ,         -- Geninfo backbone seqid
136     3 = gibbmt INTEGER ,         -- Geninfo backbone moltype
137     4 = giim Giimport-id ,       -- Geninfo import id
138     5 = genbank Textseq-id ,
139     6 = embl Textseq-id ,
140     7 = pir Textseq-id ,
141     8 = swissprot Textseq-id ,
142     9 = patent Patent-seq-id ,
143     10 = other Textseq-id ,      -- catch all
144     11 = general Dbtag }         -- for other databases
145     12 = gi  INTEGER             -- GenInfo Integrated Database
146     13 = ddbj Textseq-id         -- ddbj
147 	14 = prf Textseq-id ,        -- PRF SEQDB
148 	15 = pdb PDB-seq-id          -- PDB sequence
149     16 = tpg Textseq-id ,        -- Third Party Annot/Seq Genbank
150     17 = tpe Textseq-id ,        -- Third Party Annot/Seq EMBL
151     18 = tpd Textseq-id ,        -- Third Party Annot/Seq DDBJ
152     19 = gpipe Textseq-id ,      -- Internal NCBI genome pipeline processing ID }
153     20 = named-annot-track Textseq-id -- Internal named annotation tracking ID
154 
155 	WARNING: Some routines in sequtil.c (e.g. SeqIdPrint, SeqIdParse)
156         and tofasta.c  use
157 	arrays of size NUM_SEQID to set certain behaviors. They should be changed
158 	when SeqIds are added or changed.
159 *
160 *****************************************************************************/
161 
162 #define NUM_SEQID 21     /* total number of SeqId types */
163 
164 #define SEQID_NOT_SET ( (Uint1)0)
165 #define SEQID_LOCAL ( (Uint1)1)
166 #define SEQID_GIBBSQ ( (Uint1)2)
167 #define SEQID_GIBBMT ( (Uint1)3)
168 #define SEQID_GIIM ( (Uint1)4)
169 
170 #define SEQID_GENBANK ( (Uint1)5)
171 #define SEQID_EMBL ( (Uint1)6)
172 #define SEQID_PIR ( (Uint1)7)
173 #define SEQID_SWISSPROT ( (Uint1)8)
174 
175 
176 #define SEQID_PATENT ( (Uint1)9)
177 #define SEQID_OTHER ( (Uint1)10)
178 #define SEQID_GENERAL ( (Uint1)11)
179 #define SEQID_GI ( (Uint1)12)
180 #define SEQID_DDBJ ((Uint1)13)
181 #define SEQID_PRF ((Uint1)14)
182 #define SEQID_PDB ((Uint1)15)
183 
184 #define SEQID_TPG ((Uint1)16)
185 #define SEQID_TPE ((Uint1)17)
186 #define SEQID_TPD ((Uint1)18)
187 
188 #define SEQID_GPIPE  ((Uint1)19)
189 #define SEQID_NAMED_ANNOT_TRACK  ((Uint1)20)
190 
191 NLM_EXTERN Boolean	 LIBCALL SeqIdAsnWrite PROTO((SeqIdPtr anp, AsnIoPtr aip, AsnTypePtr atp));
192 NLM_EXTERN SeqIdPtr LIBCALL SeqIdAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
193 NLM_EXTERN SeqIdPtr LIBCALL SeqIdFree PROTO((SeqIdPtr anp));
194 NLM_EXTERN SeqIdPtr LIBCALL SeqIdDup PROTO((SeqIdPtr oldid));
195 NLM_EXTERN SeqIdPtr LIBCALL SeqIdSetDup PROTO((SeqIdPtr seqid));
196 NLM_EXTERN Int2 LIBCALL SeqIdLabel PROTO(( SeqIdPtr sip, CharPtr buffer, Int2 buflen, Uint1 content));
197 
198 /*****************************************************************************
199 *
200 *   These routines process sets or sequences of SeqId's
201 *
202 *****************************************************************************/
203 NLM_EXTERN Boolean  LIBCALL SeqIdSetAsnWrite PROTO((SeqIdPtr anp, AsnIoPtr aip, AsnTypePtr settype, AsnTypePtr elementtype));
204 NLM_EXTERN SeqIdPtr LIBCALL SeqIdSetAsnRead PROTO((AsnIoPtr aip, AsnTypePtr settype, AsnTypePtr elementtype));
205 NLM_EXTERN SeqIdPtr LIBCALL SeqIdSetFree PROTO((SeqIdPtr anp));
206 
207 
208 /*****************************************************************************
209 *
210 *   PatentSeqId
211 *
212 *****************************************************************************/
213 typedef struct patentseqid {
214     Int4 seqid;
215     IdPatPtr cit;
216 } PatentSeqId, PNTR PatentSeqIdPtr;
217 
218 NLM_EXTERN PatentSeqIdPtr LIBCALL PatentSeqIdNew PROTO((void));
219 NLM_EXTERN Boolean        LIBCALL PatentSeqIdAsnWrite PROTO((PatentSeqIdPtr psip, AsnIoPtr aip, AsnTypePtr atp));
220 NLM_EXTERN PatentSeqIdPtr LIBCALL PatentSeqIdAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
221 NLM_EXTERN PatentSeqIdPtr LIBCALL PatentSeqIdFree PROTO((PatentSeqIdPtr psip));
222 
223 /*****************************************************************************
224 *
225 *   TextSeqId
226 *
227 *****************************************************************************/
228 typedef struct textseqid {
229     CharPtr name,
230         accession,
231         release;
232 	Int2 version;             /* INT2_MIN (ncbilcl.h) = not set */
233 } TextSeqId, PNTR TextSeqIdPtr;
234 
235 NLM_EXTERN TextSeqIdPtr LIBCALL TextSeqIdNew PROTO((void));
236 NLM_EXTERN Boolean      LIBCALL TextSeqIdAsnWrite PROTO((TextSeqIdPtr tsip, AsnIoPtr aip, AsnTypePtr atp));
237 NLM_EXTERN TextSeqIdPtr LIBCALL TextSeqIdAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
238 NLM_EXTERN TextSeqIdPtr LIBCALL TextSeqIdFree PROTO((TextSeqIdPtr tsip));
239 
240 /*****************************************************************************
241 *
242 *   Giim
243 *
244 *****************************************************************************/
245 typedef struct giim {
246     Int4 id;
247     CharPtr db,
248         release;
249 } Giim, PNTR GiimPtr;
250 
251 NLM_EXTERN GiimPtr LIBCALL GiimNew PROTO((void));
252 NLM_EXTERN Boolean LIBCALL GiimAsnWrite PROTO((GiimPtr gip, AsnIoPtr aip, AsnTypePtr atp));
253 NLM_EXTERN GiimPtr LIBCALL GiimAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
254 NLM_EXTERN GiimPtr LIBCALL GiimFree PROTO((GiimPtr gip));
255 
256 
257 /*****************************************************************************
258 *
259 *   PDBSeqId
260 *
261 *****************************************************************************/
262 typedef struct pdbseqid {
263     CharPtr mol;
264 	Uint1 chain;        /* 0 = no chain set.  default = 32 */
265 	DatePtr rel;
266 	CharPtr chain_id;
267 } PDBSeqId, PNTR PDBSeqIdPtr;
268 
269 NLM_EXTERN PDBSeqIdPtr LIBCALL PDBSeqIdNew PROTO((void));
270 NLM_EXTERN Boolean     LIBCALL PDBSeqIdAsnWrite PROTO((PDBSeqIdPtr tsip, AsnIoPtr aip, AsnTypePtr atp));
271 NLM_EXTERN PDBSeqIdPtr LIBCALL PDBSeqIdAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
272 NLM_EXTERN PDBSeqIdPtr LIBCALL PDBSeqIdFree PROTO((PDBSeqIdPtr tsip));
273 
274 /*****************************************************************************
275 *
276 *   SeqLoc
277 *   SeqLoc is a choice using an ValNode, most types in data.ptrvalue
278 *      except integers, in data.intvalue
279 *   choice:
280     1 = null NULL ,           -- not placed
281     2 = empty Seq-id ,        -- to NULL one Seq-id in a collection
282     3 = whole Seq-id ,        -- whole sequence
283     4 = int Seq-interval ,    -- from to
284     5 = packed-int Packed-seqint ,
285     6 = pnt Seq-point ,
286     7 = packed-pnt Packed-seqpnt ,
287     8 = mix SEQUENCE OF Seq-loc ,
288     9 = equiv SET OF Seq-loc ,  -- equivalent sets of locations
289     10 = bond Seq-bond
290     11 = feat Feat-id    -- indirect through a feature
291 *
292 *****************************************************************************/
293 #define SEQLOC_NULL ( (Uint1)1)
294 #define SEQLOC_EMPTY ( (Uint1)2)
295 #define SEQLOC_WHOLE ( (Uint1)3)
296 #define SEQLOC_INT ( (Uint1)4)
297 #define SEQLOC_PACKED_INT ( (Uint1)5)
298 #define SEQLOC_PNT ( (Uint1)6)
299 #define SEQLOC_PACKED_PNT ( (Uint1)7)
300 #define SEQLOC_MIX ( (Uint1)8)
301 #define SEQLOC_EQUIV ( (Uint1)9)
302 #define SEQLOC_BOND ( (Uint1)10)
303 #define SEQLOC_FEAT ( (Uint1)11)
304 
305 NLM_EXTERN Boolean   LIBCALL SeqLocAsnWrite PROTO((SeqLocPtr anp, AsnIoPtr aip, AsnTypePtr atp));
306 NLM_EXTERN SeqLocPtr LIBCALL SeqLocAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
307 NLM_EXTERN SeqLocPtr LIBCALL SeqLocFree PROTO((SeqLocPtr anp));
308 NLM_EXTERN SeqLocPtr LIBCALL SeqLocCopy PROTO((SeqLocPtr anp));
309 NLM_EXTERN Int2 LIBCALL SeqLocLabel PROTO((SeqLocPtr slp, CharPtr buffer, Int2 buflen, Uint1 content));
310 
311 /*****************************************************************************
312 *
313 *   these routines work on set/seq of SeqLoc
314 *
315 *****************************************************************************/
316 NLM_EXTERN Boolean   LIBCALL SeqLocSetAsnWrite PROTO((SeqLocPtr anp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element));
317 NLM_EXTERN SeqLocPtr LIBCALL SeqLocSetAsnRead PROTO((AsnIoPtr aip, AsnTypePtr orig, AsnTypePtr element));
318 NLM_EXTERN SeqLocPtr LIBCALL SeqLocSetFree PROTO((SeqLocPtr anp));
319 
320 /*****************************************************************************
321 *
322 *   SeqInt
323 *
324 *****************************************************************************/
325 typedef struct seqint {
326     Int4 from,
327         to;
328     Uint1 strand;
329     SeqIdPtr id;    /* seq-id */
330     IntFuzzPtr if_from,
331                if_to;
332 } SeqInt, PNTR SeqIntPtr;
333 
334 NLM_EXTERN SeqIntPtr LIBCALL SeqIntNew PROTO((void));
335 NLM_EXTERN Boolean   LIBCALL SeqIntAsnWrite PROTO((SeqIntPtr sip, AsnIoPtr aip, AsnTypePtr atp));
336 NLM_EXTERN SeqIntPtr LIBCALL SeqIntAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
337 NLM_EXTERN SeqIntPtr LIBCALL SeqIntFree PROTO((SeqIntPtr sip));
338 
339 /*****************************************************************************
340 *
341 *   Packed-int
342 *
343 *****************************************************************************/
344 
345 NLM_EXTERN Boolean   LIBCALL PackSeqIntAsnWrite PROTO((SeqLocPtr sip, AsnIoPtr aip, AsnTypePtr atp));
346 NLM_EXTERN SeqLocPtr LIBCALL PackSeqIntAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
347 
348 /*****************************************************************************
349 *
350 *   SeqLocMix
351 *
352 *****************************************************************************/
353 
354 NLM_EXTERN Boolean   LIBCALL SeqLocMixAsnWrite PROTO((SeqLocPtr anp, AsnIoPtr aip, AsnTypePtr atp));
355 NLM_EXTERN SeqLocPtr LIBCALL SeqLocMixAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
356 
357 /*****************************************************************************
358 *
359 *   SeqLocEquiv
360 *
361 *****************************************************************************/
362 
363 NLM_EXTERN Boolean   LIBCALL SeqLocEquivAsnWrite PROTO((SeqLocPtr anp, AsnIoPtr aip, AsnTypePtr atp));
364 NLM_EXTERN SeqLocPtr LIBCALL SeqLocEquivAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
365 
366 /*****************************************************************************
367 *
368 *   SeqPnt
369 *
370 *****************************************************************************/
371 typedef struct seqpoint {
372     Int4 point;
373     Uint1 strand;
374     SeqIdPtr id;    /* seq-id */
375     IntFuzzPtr fuzz;
376 } SeqPnt, PNTR SeqPntPtr;
377 
378 NLM_EXTERN SeqPntPtr LIBCALL SeqPntNew PROTO((void));
379 NLM_EXTERN Boolean   LIBCALL SeqPntAsnWrite PROTO((SeqPntPtr spp, AsnIoPtr aip, AsnTypePtr atp));
380 NLM_EXTERN SeqPntPtr LIBCALL SeqPntAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
381 NLM_EXTERN SeqPntPtr LIBCALL SeqPntFree PROTO((SeqPntPtr spp));
382 
383 /*****************************************************************************
384 *
385 *   PackSeqPnt
386 *
387 *****************************************************************************/
388 #define PACK_PNT_NUM 100     /* number of points per block */
389 
390 typedef struct packseqpnt {
391     SeqIdPtr id;    /* seq-id */
392     IntFuzzPtr fuzz;
393     Uint1 strand,
394           used;       /* number of pnts used */
395     Int4 pnts[PACK_PNT_NUM];
396     struct packseqpnt PNTR next;   /* builds up chain of points */
397 } PackSeqPnt, PNTR PackSeqPntPtr;
398 
399 NLM_EXTERN PackSeqPntPtr LIBCALL PackSeqPntNew PROTO((void));
400 NLM_EXTERN Boolean       LIBCALL PackSeqPntAsnWrite PROTO((PackSeqPntPtr pspp, AsnIoPtr aip, AsnTypePtr atp));
401 NLM_EXTERN PackSeqPntPtr LIBCALL PackSeqPntAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
402 NLM_EXTERN PackSeqPntPtr LIBCALL PackSeqPntFree PROTO((PackSeqPntPtr pspp));
403 NLM_EXTERN Int4          LIBCALL PackSeqPntGet PROTO((PackSeqPntPtr pspp, Int4 index));
404 NLM_EXTERN Boolean       LIBCALL PackSeqPntPut PROTO((PackSeqPntPtr pspp, Int4 point));
405 NLM_EXTERN Int4          LIBCALL PackSeqPntNum PROTO((PackSeqPntPtr pspp));
406 
407 /*****************************************************************************
408 *
409 *   SeqBond
410 *
411 *****************************************************************************/
412 typedef struct seqbond {
413     SeqPntPtr a,
414                 b;
415 } SeqBond, PNTR SeqBondPtr;
416 
417 NLM_EXTERN SeqBondPtr LIBCALL SeqBondNew PROTO((void));
418 NLM_EXTERN Boolean    LIBCALL SeqBondAsnWrite PROTO((SeqBondPtr sbp, AsnIoPtr aip, AsnTypePtr atp));
419 NLM_EXTERN SeqBondPtr LIBCALL SeqBondAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp));
420 NLM_EXTERN SeqBondPtr LIBCALL SeqBondFree PROTO((SeqBondPtr sbp));
421 
422 
423 /*****************************************************************************
424 *
425 *   strand types
426 *
427 *****************************************************************************/
428 #define Seq_strand_unknown 0
429 #define Seq_strand_plus 1
430 #define Seq_strand_minus 2
431 #define Seq_strand_both 3
432 #define Seq_strand_both_rev 4
433 #define Seq_strand_other 255
434 
435 #ifdef __cplusplus
436 }
437 #endif
438 
439 #undef NLM_EXTERN
440 #ifdef NLM_EXPORT
441 #define NLM_EXTERN NLM_EXPORT
442 #else
443 #define NLM_EXTERN
444 #endif
445 
446 #endif
447