File: gff3validator.c

package info (click to toggle)
genometools 1.6.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 50,504 kB
  • sloc: ansic: 271,868; ruby: 30,327; python: 4,942; sh: 3,230; makefile: 1,214; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (47 lines) | stat: -rw-r--r-- 1,335 bytes parent folder | download | duplicates (17)
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
#include "genometools.h"

/* A simple GFF3 validator which validates all given GFF3 files (without
   checking types). */

int main(int argc, const char *argv[])
{
  GtNodeStream *gff3_in_stream;
  GtGenomeNode *gn;
  GtError *err;
  int had_err;

  if (gt_version_check(GT_MAJOR_VERSION, GT_MINOR_VERSION, GT_MICRO_VERSION)) {
    fprintf(stderr, "error: %s\n", gt_version_check(GT_MAJOR_VERSION,
                                                    GT_MINOR_VERSION,
                                                    GT_MICRO_VERSION));
    return EXIT_FAILURE;
  }

  /* initialize */
  gt_lib_init();

  /* create error object */
  err = gt_error_new();

  /* create GFF3 input stream (with ID attribute checking) */
  gff3_in_stream = gt_gff3_in_stream_new_unsorted(argc-1, argv+1);
  gt_gff3_in_stream_check_id_attributes((GtGFF3InStream*) gff3_in_stream);

  /* pull the features through the stream and free them afterwards */
  while (!(had_err = gt_node_stream_next(gff3_in_stream, &gn, err)) && gn)
    gt_genome_node_delete(gn);

  /* handle error */
  if (had_err)
    fprintf(stderr, "%s: error: %s\n", argv[0], gt_error_get(err));
  else
    printf("input is valid GFF3\n");

  /* free */
  gt_node_stream_delete(gff3_in_stream);
  gt_error_delete(err);

  if (had_err)
    return EXIT_FAILURE;
  return EXIT_SUCCESS;
}