summaryrefslogtreecommitdiffstats
path: root/src/aggregator.c (plain)
blob: 8057bb3b5456431f5ad3672dadd0352a33904dbd
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
/*
 * Aggregate the collected influenza data into a single HDF5
 * container.
 */

#include "error/check_h5_error.h"
#include "load/load_blast_scores.h"
#include "load/load_influenza_aa_dat.h"
#include "load/load_influenza_faa.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BLASTFILE "run20090807.del"
#define H5FILE "influenza.h5"
#define INFLUENZA_AA_DAT "/genomes/INFLUENZA/influenza_aa.dat"
#define INFLUENZA_FAA "/genomes/INFLUENZA/influenza.faa"

int
main ()
{
  char* exp004 = getenv ("EXP004");
  if (exp004 == NULL)
    {
      printf ("EXP004 environment variable not set.  This should be set to the "
	      "directory containing the genomes/INFLUENZA data.");
      exit (0);
    }

  /*
   * Create a new HDF5 file if it does not already exist.  If an
   * existing file is found then open it.
   */
  hid_t file_id = 0;
  FILE *f = fopen (H5FILE, "r+");
  if (f == NULL)
    {
      file_id = H5Fcreate (H5FILE, H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
      if (file_id < 0)
	check_h5_error (__FILE__, __LINE__);
    }
  else
    {
      fclose (f);
      file_id = H5Fopen (H5FILE, H5F_ACC_RDWR, H5P_DEFAULT);
      if (file_id < 0)
	check_h5_error (__FILE__, __LINE__);
    }

  /*
   * Load the supplementary protein data file.
   */
  char* loc1 = malloc (strlen (exp004) + strlen (INFLUENZA_AA_DAT) + 1);
  loc1[0] = '\0';
  strcat (loc1, exp004);
  strcat (loc1, INFLUENZA_AA_DAT);
  printf ("Loading \"influenza_aa.dat\" with contents of %s.\n",
	  loc1);
  load_influenza_aa_dat (file_id, loc1);
  free (loc1);

  /*
   * Load the FASTA protein sequence data file.
   */
  char* loc2 = malloc (strlen (exp004) + strlen (INFLUENZA_FAA) + 1);
  loc2[0] = '\0';
  strcat (loc2, exp004);
  strcat (loc2, INFLUENZA_FAA);
  printf ("Loading \"influenza.faa\" with contents of %s.\n",
	  loc2);
  load_influenza_faa (file_id, loc2);
  free (loc2);

  /*
   * Load the BLAST scores.
   */
  /*
  printf ("Loading \"blast\" with contents of %s.\n",
	  BLASTFILE);
  load_blast_scores (file_id, BLASTFILE);
  */

  /*
   * Close the HDF5 file.
   */
  herr_t status = H5Fclose (file_id);
  if (status < 0)
    check_h5_error (__FILE__, __LINE__);

  return 0;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.