2
Copyright (c) 2006-2011 Gordon Gremme <gremme@zbh.uni-hamburg.de>
3
Copyright (c) 2006-2008 Center for Bioinformatics, University of Hamburg
5
Permission to use, copy, modify, and distribute this software for any
6
purpose with or without fee is hereby granted, provided that the above
7
copyright notice and this permission notice appear in all copies.
9
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
#ifndef GFF3_PARSER_API_H
19
#define GFF3_PARSER_API_H
21
#include "core/cstr_table_api.h"
22
#include "core/file_api.h"
23
#include "core/queue_api.h"
24
#include "core/range_api.h"
25
#include "core/strand_api.h"
26
#include "extended/type_checker_api.h"
28
/* A <GtGFF3Parser> can be used to parse GFF3 files and convert them into
29
<GtGenomeNode> objects. If the GFF3 files do not contain the encouraged
30
sequence-region meta directives, the GFF3 parser introduces the corresponding
31
region nodes automatically. This is a low-level class and it is usually not
32
used directly. Normally, a <GtGFF3InStream> is used to parse GFF3 files. */
33
typedef struct GtGFF3Parser GtGFF3Parser;
35
/* Return a new <GtGFF3Parser> object with optional <type_checker>. If a
36
<type_checker> was given, the <GtGFF3Parser> stores a new reference to it
37
internally and uses the <type_checker> to check types during parsing. */
38
GtGFF3Parser* gt_gff3_parser_new(GtTypeChecker *type_checker);
39
/* Enable ID attribute checking in <gff3_parser>. Thereby, the memory
40
consumption of the <gff3_parser> becomes proportional to the input file
42
void gt_gff3_parser_check_id_attributes(GtGFF3Parser *gff3_parser);
43
/* Enable sequence region boundary checking in <gff3_parser>. That is,
44
encountering features outside the sequence region boundaries will result in
46
void gt_gff3_parser_check_region_boundaries(GtGFF3Parser *gff3_parser);
47
/* Disable sequence region boundary checking in <gff3_parser>. That is,
48
features outside the sequence region boundaries will be permitted. */
49
void gt_gff3_parser_do_not_check_region_boundaries(GtGFF3Parser
51
/* Transform all features parsed by <gff3_parser> by the given <offset>. */
52
void gt_gff3_parser_set_offset(GtGFF3Parser *gff3_parser, long offset);
53
/* Set <type_checker> used by <gff3_parser>. */
54
void gt_gff3_parser_set_type_checker(GtGFF3Parser *gff3_parser,
55
GtTypeChecker *type_checker);
56
/* Enable the tidy mode in <gff3_parser>. In tidy mode the <gff3_parser> parser
57
tries to tidy up features which would normally lead to a parse error. */
58
void gt_gff3_parser_enable_tidy_mode(GtGFF3Parser *gff3_parser);
59
/* Use <gff3_parser> to parse genome nodes from file pointer <fpin>.
60
<status_code> is set to 0 if at least one genome node was created (and stored
61
in <genome_nodes>) and to <EOF> if no further genome nodes could be parsed
62
from <fpin>. Every encountered (genome feature) type is recorded in the
63
C string table <used_types>. The parser uses the given <filenamestr> to
64
store the file name of <fpin> in the created genome nodes or to give the
65
correct filename in error messages, if necessary.
66
<line_number> is increased accordingly during parsing and has to be set to 0
67
before parsing a new <fpin>.
68
If an error occurs during parsing this method returns -1 and sets <err>
70
int gt_gff3_parser_parse_genome_nodes(GtGFF3Parser *gff3_parser,
72
GtQueue *genome_nodes,
73
GtCstrTable *used_types,
75
unsigned long long *line_number,
78
/* Reset the <gff3_parser> (necessary if the input file is switched). */
79
void gt_gff3_parser_reset(GtGFF3Parser *gff3_parser);
80
/* Delete the <gff3_parser>. */
81
void gt_gff3_parser_delete(GtGFF3Parser *gff3_parser);