From 1501b0b828fab86848cbfc242925964685da3e83 Mon Sep 17 00:00:00 2001 From: Don Pellegrino Date: Sat, 16 Jan 2010 19:20:46 +0000 Subject: Modified to convert the year field from text to numeric during the load. --- diff --git a/src/load_influenza_aa_dat.c b/src/load_influenza_aa_dat.c index 5af8a72..493c7db 100644 --- a/src/load_influenza_aa_dat.c +++ b/src/load_influenza_aa_dat.c @@ -11,7 +11,7 @@ #include #define NFIELDS (hsize_t) 11 -#define TABLE_NAME "Protein Sequences" +#define TABLE_NAME "influenza_aa.dat" void load_influenza_aa_dat (hid_t file_id) @@ -26,7 +26,7 @@ load_influenza_aa_dat (hid_t file_id) int genome_segment_number; char subtype[7]; char country[25]; - char year[8]; + int year; int sequence_length; char virus_name[196]; char age[17]; @@ -93,9 +93,7 @@ load_influenza_aa_dat (hid_t file_id) H5Tset_size (country_type, 25 ); field_type[4] = country_type; - hid_t year_type = H5Tcopy ( H5T_C_S1 ); - H5Tset_size (year_type, 8); - field_type[5] = year_type; + field_type[5] = H5T_NATIVE_INT; field_type[6] = H5T_NATIVE_INT; @@ -175,8 +173,19 @@ load_influenza_aa_dat (hid_t file_id) strncpy(p_data.country, strsep (&running, "\t"), sizeof(p_data.country)); - strncpy (p_data.year, strsep (&running, "\t"), - sizeof(p_data.year)); + /* + * Convert the year field from text to numeric. Unknown and empty + * values are assigned a numeric value of zero. + */ + token = strsep (&running, "\t"); + if (strcmp (token, "\0") == 0) + p_data.year = 0; + else if (strcmp (token, "unknown") == 0) + p_data.year = 0; + else if (strcmp (token, "NON") == 0) + p_data.year = 0; + else + p_data.year = atoi(token); token = strsep (&running, "\t"); if (strcmp (token, "\0") == 0) @@ -197,7 +206,7 @@ load_influenza_aa_dat (hid_t file_id) sizeof(p_data.full_length_indicator)); if (current_line == 1) - H5TBmake_table ("Protein Sequences", file_id, TABLE_NAME,NFIELDS,1, + H5TBmake_table ("influenza_aa.dat", file_id, TABLE_NAME,NFIELDS,1, dst_size,field_names, dst_offset, field_type, chunk_size, fill_data, compress, &p_data); else @@ -218,7 +227,6 @@ load_influenza_aa_dat (hid_t file_id) H5Tclose (host_type); H5Tclose (subtype_type); H5Tclose (country_type); - H5Tclose (year_type); H5Tclose (virus_name_type); H5Tclose (age_type); H5Tclose (gender_type); -- cgit v0.8.3.1-22-g547a