1 /* @include ajfeatdata ********************************************************
2 **
3 ** AJAX feature data include file
4 **
5 ** @author Copyright (C) 1999 Richard Bruskiewich
6 ** @version $Revision: 1.35 $
7 ** @modified 2000 Ian Longden.
8 ** @modified 2001 Peter Rice.
9 ** @modified $Date: 2013/06/29 22:31:59 $ by $Author: rice $
10 ** @@
11 **
12 ** This library is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU Lesser General Public
14 ** License as published by the Free Software Foundation; either
15 ** version 2.1 of the License, or (at your option) any later version.
16 **
17 ** This library is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ** Lesser General Public License for more details.
21 **
22 ** You should have received a copy of the GNU Lesser General Public
23 ** License along with this library; if not, write to the Free Software
24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 ** MA  02110-1301,  USA.
26 ******************************************************************************/
27 
28 #ifndef AJFEATDATA_H
29 #define AJFEATDATA_H
30 
31 /* ========================================================================= */
32 /* ============================= include files ============================= */
33 /* ========================================================================= */
34 
35 #include "ajdefine.h"
36 #include "ajstr.h"
37 #include "ajlist.h"
38 #include "ajtextdata.h"
39 
40 AJ_BEGIN_DECLS
41 
42 
43 
44 
45 /* ========================================================================= */
46 /* =============================== constants =============================== */
47 /* ========================================================================= */
48 
49 
50 
51 
52 #define DEFAULT_GFF_VERSION 3
53 
54 /*
55 ** some featflag values are retained for reading in old output files
56 */
57 
58 #define AJFEATFLAG_START_BEFORE_SEQ 0x0001  /* <start */
59 #define AJFEATFLAG_END_AFTER_SEQ    0x0002  /* >end */
60 #define AJFEATFLAG_GENERATED        0x0004  /* generated for GFF3 */
61 #define AJFEATFLAG_BETWEEN_SEQ      0x0008  /* x^y */
62 #define AJFEATFLAG_START_TWO        0x0010  /* x.y.. */
63 #define AJFEATFLAG_END_TWO          0x0020  /* ..x.y */
64 #define AJFEATFLAG_POINT            0x0040  /* x */
65 #define AJFEATFLAG_COMPLEMENT_MAIN  0x0080  /* complement around the join */
66 #define AJFEATFLAG_MULTIPLE         0x0100  /* part of a multiple i.e. join*/
67 #define AJFEATFLAG_GROUP            0x0200  /* group */
68 #define AJFEATFLAG_ORDER            0x0400  /* order */
69 #define AJFEATFLAG_ONEOF            0x0800  /* one_of */
70 #define AJFEATFLAG_REMOTEID         0x1000  /* AB012345.6: */
71 #define AJFEATFLAG_LABEL            0x2000  /* label as location */
72 #define AJFEATFLAG_START_UNSURE     0x4000  /* unsure position: SwissProt '?' */
73 #define AJFEATFLAG_END_UNSURE       0x8000  /* unsure position: SwissProt '?' */
74 
75 
76 
77 
78 /* ========================================================================= */
79 /* ============================== public data ============================== */
80 /* ========================================================================= */
81 
82 
83 
84 
85 /* @data AjPFeattable *********************************************************
86 **
87 ** Ajax data type for collecting AjPFeatures in a 'feature table'.
88 ** The features themselves may be accessed via iteration methods.
89 **
90 ** @alias AjSFeattable
91 ** @alias AjOFeattable
92 **
93 ** @new    ajFeattableNew        Constructor
94 ** @delete ajFeattableDel        Default destructor
95 ** @modify ajFeattableAdd        Adds an AjPFeature to a set
96 ** @new    ajFeatRead            Reads in a feature set in a specified format
97 **
98 ** @attr Seqid [AjPStr] Sequence name
99 ** @attr Type [AjPStr] Sequence type: P or N
100 ** @attr Features [AjPList] List of AjPFeatures...
101 ** @attr Groups [ajuint] Maximum group number
102 ** @attr Start [ajuint] First position used (like sequence begin)
103 ** @attr End [ajuint] Last position used (like sequence end)
104 ** @attr Len [ajuint] Maximum length
105 ** @attr Offset [ajuint] Offset when trimmed
106 ** @attr Rev [AjBool] reversed if true
107 ** @attr Reversed  [AjBool] true: has been reverse-complemented
108 ** @attr Trimmed   [AjBool] true: has been trimmed
109 ** @attr Db [AjPStr] Database name from input
110 ** @attr Setdb [AjPStr] Database name from command line
111 ** @attr Full [AjPStr] Full name
112 ** @attr Qry [AjPStr] UFO query for re-reading
113 ** @attr Formatstr [AjPStr] Input format name
114 ** @attr Filename [AjPStr] Original filename
115 ** @attr TextPtr [AjPStr] Full text
116 ** @attr Fpos [ajlong] File position (fseek) for Query
117 ** @attr Format [AjEnum] Input format enum
118 ** @attr Circular [AjBool] true: circular nucleotide molecule
119 ** @@
120 ******************************************************************************/
121 
122 typedef struct AjSFeattable
123 {
124     AjPStr  Seqid;
125     AjPStr  Type;
126     AjPList Features;
127     ajuint  Groups;
128     ajuint  Start;
129     ajuint  End;
130     ajuint  Len;
131     ajuint  Offset;
132     AjBool  Rev;
133     AjBool  Reversed;
134     AjBool  Trimmed;
135     AjPStr  Db;
136     AjPStr  Setdb;
137     AjPStr  Full;
138     AjPStr  Qry;
139     AjPStr  Formatstr;
140     AjPStr  Filename;
141     AjPStr  TextPtr;
142     ajlong  Fpos;
143     AjEnum  Format;
144     AjBool Circular;
145 }  AjOFeattable;
146 
147 #define AjPFeattable AjOFeattable*
148 
149 
150 
151 
152 /* @data AjPFeattabin *********************************************************
153 **
154 ** Ajax class for feature table input
155 **
156 ** @alias AjSFeattabin
157 ** @alias AjOFeattabin
158 ** @alias AjPFeattabIn
159 **
160 ** @new    ajFeattabinNew Constructor
161 ** @new    ajFeattabinNewSS Constructor with format, name and type
162 ** @new    ajFeattabinNewSSF Constructor with format, name, type and input file
163 ** @delete ajFeattabinDel Destructor
164 **
165 ** @attr Input     [AjPTextin] Text file input object
166 ** @attr Ufo [AjPStr] Original UFO
167 ** @attr Formatstr [AjPStr] Input format name
168 ** @attr Filename [AjPStr] Original filename
169 ** @attr Seqid [AjPStr] Sequence entryname
170 ** @attr Type [AjPStr] Type N or P
171 ** @attr Seqname [AjPStr] name of AjPSeq assoc. with feature table
172 ** @attr Local [AjBool] Opened as a local file if ajTrue
173 ** @attr Rev       [AjBool]    Reverse/complement if true
174 ** @attr Start     [ajint]     Start position
175 ** @attr End       [ajint]     End position
176 ** @attr Circular [AjBool] true: circular nucleotide molecule
177 ** @attr Padding [char[4]] Padding to alignment boundary
178 ** @@
179 ******************************************************************************/
180 
181 typedef struct AjSFeattabin
182 {
183     AjPTextin     Input;
184     AjPStr        Ufo;
185     AjPStr        Formatstr;
186     AjPStr        Filename;
187     AjPStr        Seqid;
188     AjPStr        Type;
189     AjPStr        Seqname;
190     AjBool        Local;
191     AjBool        Rev;
192     ajint         Start;
193     ajint         End;
194     AjBool        Circular;
195     char Padding[4];
196 }  AjOFeattabin;
197 
198 #define AjPFeattabin AjOFeattabin*
199 #define AjPFeattabIn AjOFeattabin*
200 
201 
202 
203 
204 /* @data AjPFeattaball ********************************************************
205 **
206 ** Ajax feature all (stream) object.
207 **
208 ** Inherits an AjPFeattable but allows more data resources to be read from the
209 ** same input by also inheriting the AjPFeattabin input object.
210 **
211 ** @alias AjSFeattaball
212 ** @alias AjOFeattaball
213 **
214 ** @attr Feattable [AjPFeattable] Current feature table
215 ** @attr Feattabin [AjPFeattabin] Feature input for reading next
216 ** @attr Totfeattables [ajulong] Count of feature tables so far
217 ** @attr Count [ajuint] Count of feature tables so far
218 ** @attr Multi [AjBool] True if multiple values are expected
219 ** @attr Returned [AjBool] if true: featuure table object has been returned
220 **                         to a new owner
221 **                         and is not to be deleted by the destructor
222 ** @attr Padding [char[4]] Padding to alignment boundary
223 ** @@
224 ******************************************************************************/
225 
226 typedef struct AjSFeattaball
227 {
228     AjPFeattable Feattable;
229     AjPFeattabin Feattabin;
230     ajulong Totfeattables;
231     ajuint Count;
232     AjBool Multi;
233     AjBool Returned;
234     char Padding[4];
235 } AjOFeattaball;
236 
237 #define AjPFeattaball AjOFeattaball*
238 
239 
240 
241 
242 /* @data AjPFeattabAccess *****************************************************
243 **
244 ** Ajax feature table access database reading object.
245 **
246 ** Holds information needed to read a feature table from a database.
247 ** Access methods are defined for each known database type.
248 **
249 ** Feature tables are read from the database using the defined
250 ** database access function, which is usually a static function
251 ** within ajtextdb.c or ajfeatdb.c
252 **
253 ** This should be a static data object but is needed for the definition
254 ** of AjPFeatin.
255 **
256 ** @alias AjSFeattabAccess
257 ** @alias AjOFeattabAccess
258 **
259 ** @attr Name [const char*] Access method name used in emboss.default
260 ** @attr Access [AjBool function] Access function
261 ** @attr AccessFree [AjBool function] Access cleanup function
262 ** @attr Qlink [const char*] Supported query link operators
263 ** @attr Desc [const char*] Description
264 ** @attr Alias [AjBool] Alias for another name
265 ** @attr Entry [AjBool] Supports retrieval of single entries
266 ** @attr Query [AjBool] Supports retrieval of selected entries
267 ** @attr All [AjBool] Supports retrieval of all entries
268 ** @attr Chunked [AjBool] Supports retrieval of entries in chunks
269 ** @attr Padding [AjBool] Padding to alignment boundary
270 ** @@
271 ******************************************************************************/
272 
273 typedef struct AjSFeattabAccess
274 {
275     const char *Name;
276     AjBool (*Access) (AjPFeattabin ftabin);
277     AjBool (*AccessFree) (void* qry);
278     const char* Qlink;
279     const char* Desc;
280     AjBool Alias;
281     AjBool Entry;
282     AjBool Query;
283     AjBool All;
284     AjBool Chunked;
285     AjBool Padding;
286 } AjOFeattabAccess;
287 
288 #define AjPFeattabAccess AjOFeattabAccess*
289 
290 
291 
292 
293 /* @data AjPFeattabOut ********************************************************
294 **
295 ** Ajax class for feature table output
296 **
297 ** @alias AjSFeattabOut
298 ** @alias AjOFeattabOut
299 **
300 ** @new    ajFeattabOutNew Constructor
301 ** @new    ajFeattabOutNewSSF Constructor with format, name, type and
302 **                            output file
303 ** @delete ajFeattabOutDel Destructor
304 **
305 ** @attr Ufo [AjPStr] Original output UFO
306 ** @attr Formatstr [AjPStr] Output format name
307 ** @attr Filename [AjPStr] Output filename
308 ** @attr Directory [AjPStr] Output directory
309 ** @attr Seqid [AjPStr] Output entryname
310 ** @attr Type [AjPStr] Type N or P
311 ** @attr Handle [AjPFile] Output file
312 ** @attr Seqname [AjPStr] AjPSeq assoc. with feature table
313 ** @attr Basename [AjPStr] Basename for output file
314 ** @attr Format [ajint] Output format index
315 ** @attr Local [AjBool] Opened as a local file if ajTrue
316 ** @attr Count [ajuint] Number of feature tables written
317 ** @attr Padding [char[4]] Padding to alignment boundary
318 ** @attr Cleanup [void function] Function to write remaining lines on closing
319 ** @@
320 ******************************************************************************/
321 
322 typedef struct AjSFeattabOut
323 {
324     AjPStr        Ufo;
325     AjPStr        Formatstr;
326     AjPStr        Filename;
327     AjPStr        Directory;
328     AjPStr        Seqid;
329     AjPStr        Type;
330     AjPFile       Handle;
331     AjPStr        Seqname;
332     AjPStr        Basename;
333     ajint         Format;
334     AjBool        Local;
335     ajuint        Count;
336     char          Padding[4];
337     void (*Cleanup) (AjPFile filethys);
338 }  AjOFeattabOut;
339 
340 #define AjPFeattabOut AjOFeattabOut*
341 
342 
343 
344 
345 /* @data AjPFeature ***********************************************************
346 **
347 ** Ajax Biological Feature object superclass.
348 **
349 ** Holds generic data describing a single genome feature.
350 **
351 ** A feature is a description of a
352 ** sequence location which was determined by some 'source' analysis
353 ** (which may be of 'wet lab' experimental or 'in silico'
354 ** computational nature), has a 'primary' descriptor ('Type'),
355 ** may have some 'score' asserting the level of analysis confidence in
356 ** its identity (e.g. log likelihood relative to a null hypothesis or
357 ** other similar entity), has a 'Location' in the genome, and may have
358 ** any arbitrary number of descriptor Tags and TagValues associated with it.
359 **
360 **
361 ** @alias AjSFeature
362 ** @alias AjOFeature
363 **
364 ** @new    ajFeatNew             Constructor - must specify the associated
365 **                               (non-null) AjPFeattable
366 ** @new    ajFeatNewII           Simple constructor with only start and end
367 **                               positions
368 ** @new    ajFeatNewIIRev        Simple constructor with only start and end
369 **                               positions, sets feature to be
370 **                               on the reverse strand
371 ** @new    ajFeatNewProt         Protein-specific constructor -
372 **                               must specify the associated
373 **                               (non-null) AjPFeattable
374 ** @delete ajFeatDel             Default destructor
375 ** @new    ajFeatCopy            Copy constructor
376 **
377 ** @attr Source [AjPStr] Source program name (or EMBL)
378 ** @attr Type [AjPStr] Feature type (feature key) from internal list
379 **                    for protein or nucleotide
380 ** @attr Subfeatures [AjPList] Subfeatures
381 ** @attr Tags [AjPList] Tag-value list (qualifier list)
382 ** @attr GffTags [AjPList] GFF3 Tag-value list (qualifier list)
383 ** @attr Protein [AjBool] true for a protein feature
384 ** @attr Start [ajuint] Start position
385 ** @attr End [ajuint] End position
386 ** @attr Start2 [ajuint] Second start position - EMBL (a.b)
387 ** @attr End2 [ajuint] Second end position - EMBL ..(a.b)
388 ** @attr Frame [ajint] Frame 1..3, -1..-3 or 0
389 ** @attr Flags [ajuint] Flag bit mask for EMBL location
390 ** @attr Group [ajuint] Group for join/order/one-of
391 ** @attr Remote [AjPStr] Remote ID - EMBL Remote:a.b
392 ** @attr Label [AjPStr] Label name for location - EMBL legacy
393 ** @attr Exon [ajuint] Exon number
394 ** @attr Score [float] Score or 0.0 if none
395 ** @attr Strand [char] Strand +/- or NULL
396 ** @attr Padding [char[7]] Padding to alignment boundary
397 ** @@
398 ******************************************************************************/
399 
400 typedef struct AjSFeature
401 {
402     AjPStr            Source;
403     AjPStr            Type;
404     AjPList           Subfeatures;
405     AjPList           Tags;
406     AjPList           GffTags;
407     AjBool            Protein;
408     ajuint            Start;
409     ajuint            End;
410     ajuint            Start2;
411     ajuint            End2;
412     ajint             Frame;
413     ajuint            Flags;
414     ajuint            Group;
415     AjPStr            Remote;
416     AjPStr            Label;
417     ajuint            Exon;
418     float             Score;
419     char              Strand;
420     char              Padding[7];
421 } AjOFeature;
422 
423 #define AjPFeature AjOFeature*
424 
425 
426 
427 
428 /* @data AjPFeatGfftags *******************************************************
429 **
430 ** Biological feature GFF3 special tags
431 **
432 ** @alias AjSFeatGfftags
433 ** @alias AjOFeatGfftags
434 **
435 ** @attr Id [AjPStr] Identifier attribute. Features with the same id are
436 **                   one feature with multiple locations
437 ** @attr Name [AjPStr] Display name attribute, can be shared
438 ** @attr Alias [AjPStr] Alias attribute (list) e.g. locus name, can be shared
439 ** @attr Parent [AjPStr] Parent attribute (list) for part_of grouping
440 ** @attr Target [AjPStr] Target attribute "target_id start end [strand]"
441 ** @attr Gap [AjPStr] Gap attribute in exonerate CIGAR format
442 ** @attr DerivesFrom [AjPStr] Derives_from attribute for relations
443 ** @attr Note [AjPStr] Note attribute (list)
444 ** @attr Dbxref [AjPStr] Dbxref attribute (list) in format DBTAG:ID
445 ** @attr OntologyTerm [AjPStr] Ontology_term attribute (list) in format DBTAG:ID
446 ** @attr IsCircular [AjPStr] Is_circular attribute
447 ** @@
448 ******************************************************************************/
449 
450 typedef struct AjSFeatGfftags
451 {
452     AjPStr            Id;
453     AjPStr            Name;
454     AjPStr            Alias;
455     AjPStr            Parent;
456     AjPStr            Target;
457     AjPStr            Gap;
458     AjPStr            DerivesFrom;
459     AjPStr            Note;
460     AjPStr            Dbxref;
461     AjPStr            OntologyTerm;
462     AjPStr            IsCircular;
463 } AjOFeatGfftags;
464 
465 #define AjPFeatGfftags AjOFeatGfftags*
466 
467 
468 
469 
470 /* ========================================================================= */
471 /* =========================== public functions ============================ */
472 /* ========================================================================= */
473 
474 
475 
476 
477 /*
478 ** Prototype definitions
479 */
480 
481 /*
482 ** End of prototype definitions
483 */
484 
485 
486 
487 
488 AJ_END_DECLS
489 
490 #endif /* !AJFEATDATA_H */
491