Commits

Casey Greene committed 876018c

allow Data2DB to work with qdabs

Comments (0)

Files changed (6)

 namespace Sleipnir {
 
 const char	CDatabaseImpl::c_acDAB[]		= ".dab";
+const char	CDatabaseImpl::c_acQDAB[]		= ".qdab";
 const char	CDatabaseImpl::c_acExtension[]	= ".db";
 
 ///////////////////////////////////////////////////////////////////////////////
 	Clear( );
 	pBayesNet->GetNodes( vecstrNodes );
 	for( i = 1; i < vecstrNodes.size( ); ++i )
-		vecstrNodes[ i - 1 ] = strInputDirectory + '/' + vecstrNodes[ i ] + c_acDAB;
+		vecstrNodes[ i - 1 ] = strInputDirectory + '/' + vecstrNodes[ i ];
 	if( vecstrNodes.size( ) )
 		vecstrNodes.resize( vecstrNodes.size( ) - 1 );
 	m_vecpDBs.resize( iFiles );
 			for( iInOffset = 0; iInOffset < vecData.size( ); ++iInOffset ) {
 				CDataPair	Dat;
 
-				if( !Dat.Open( vecstrFiles[ iInBase + iInOffset ].c_str( ), false, m_fMemmap ) ) {
+				if( !Dat.Open( (vecstrFiles[ iInBase + iInOffset ] + c_acDAB).c_str( ), false, m_fMemmap ) ) {
 					g_CatSleipnir( ).error( "CDatabaseImpl::Open( ) could not open %s",
-						vecstrFiles[ iInBase + iInOffset ].c_str( ) );
-					return false; }
+						(vecstrFiles[ iInBase + iInOffset ] + c_acDAB).c_str( ) );
+				    if( !Dat.Open( (vecstrFiles[ iInBase + iInOffset ] + c_acQDAB).c_str( ), false, m_fMemmap ) ) {
+					g_CatSleipnir( ).error( "CDatabaseImpl::Open( ) could not open %s",
+						(vecstrFiles[ iInBase + iInOffset ] + c_acQDAB).c_str( ) );
+					return false;
+				    }
+				}
 				for( i = 0; i < veciMyGenes.size( ); ++i )
 					veciMyGenes[ i ] = Dat.GetGene( vecstrMyGenes[ i ] );
 				for( i = 0; i < veciGenes.size( ); ++i )
 class CDatabaseImpl {
 protected:
 	static const char	c_acDAB[];
+	static const char	c_acQDAB[];
 	static const char	c_acExtension[];
 
 	CDatabaseImpl( ) : m_fMemmap(false), m_iBlockIn(-1), m_iBlockOut(-1), m_fBuffer(false) { }

tools/Distancer/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.4
   generated with the following command:
-  /home/chuttenh/hg/sleipnir/trunk/../extlib/gengetopt-2.22/bin/gengetopt -iDistancer.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iDistancer.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
   "\nMain:",
   "  -i, --input=filename    Input PCL file",
   "  -o, --output=filename   Output DAT/DAB file",
-  "  -d, --distance=STRING   Similarity measure  (possible values=\"pearson\", \n                            \"euclidean\", \"kendalls\", \"kolm-smir\", \n                            \"spearman\", \"pearnorm\", \"hypergeom\", \n                            \"innerprod\", \"bininnerprod\", \"quickpear\", \n                            \"mutinfo\", \"relauc\", \"pearsig\", \"dice\" \n                            default=`pearnorm')",
+  "  -d, --distance=STRING   Similarity measure  (possible values=\"pearson\", \n                            \"euclidean\", \"kendalls\", \"kolm-smir\", \n                            \"spearman\", \"pearnorm\", \"hypergeom\", \n                            \"innerprod\", \"bininnerprod\", \"quickpear\", \n                            \"mutinfo\", \"relauc\", \"pearsig\", \"dice\", \n                            \"dcor\", \"sdcor\" default=`pearnorm')",
   "\nMiscellaneous:",
   "  -w, --weights=filename  Input weights file",
   "  -a, --autocorrelate     Autocorrelate distances  (default=off)",
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 
-char *cmdline_parser_distance_values[] = {"pearson", "euclidean", "kendalls", "kolm-smir", "spearman", "pearnorm", "hypergeom", "innerprod", "bininnerprod", "quickpear", "mutinfo", "relauc", "pearsig", "dice", 0} ;	/* Possible values for distance.  */
+const char *cmdline_parser_distance_values[] = {"pearson", "euclidean", "kendalls", "kolm-smir", "spearman", "pearnorm", "hypergeom", "innerprod", "bininnerprod", "quickpear", "mutinfo", "relauc", "pearsig", "dice", "dcor", "sdcor", 0}; /*< Possible values for distance. */
 
 static char *
 gengetopt_strdup (const char *s);
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  FIX_UNUSED (args_info);
   args_info->input_arg = NULL;
   args_info->input_orig = NULL;
   args_info->output_arg = NULL;
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n",
+     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+     CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n", gengetopt_args_info_description);
+    printf("%s\n\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = NULL;
+  args_info->inputs = 0;
   args_info->inputs_num = 0;
 }
 
  * -2 if more than one value has matched
  */
 static int
-check_possible_values(const char *val, char *values[])
+check_possible_values(const char *val, const char *values[])
 {
   int i, found, last;
   size_t len;
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
 {
   int found = -1;
   if (arg) {
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = NULL;
+  char *result = 0;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 {
   int result;
   struct cmdline_parser_params params;
   params.check_ambiguity = 0;
   params.print_errors = 1;
 
-  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
 
   return result;
 }
 int
 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
 {
+  FIX_UNUSED (args_info);
+  FIX_UNUSED (prog_name);
   return EXIT_SUCCESS;
 }
 
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, char *possible_values[], const char *default_value,
+               char *value, const char *possible_values[],
+               const char *default_value,
                cmdline_parser_arg_type arg_type,
                int check_ambiguity, int override,
                int no_free, int multiple_option,
   const char *val = value;
   int found;
   char **string_field;
+  FIX_UNUSED (field);
 
   stop_char = 0;
   found = 0;
 
 
 int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (
+  int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "skip",	1, NULL, 's' },
         { "limit",	1, NULL, 'l' },
         { "verbosity",	1, NULL, 'v' },
-        { NULL,	0, NULL, 0 }
+        { 0,  0, 0, 0 }
       };
 
       c = getopt_long (argc, argv, "hVi:o:d:w:aqnzfg:e:A:s:l:v:", long_options, &option_index);

tools/Distancer/cmdline.h

 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22
+ *  generated by GNU Gengetopt version 2.22.4
  *  http://www.gnu.org/software/gengetopt.
  *  DO NOT modify this file, since it can be overwritten
  *  @author GNU Gengetopt by Lorenzo Bettini */
 #endif /* __cplusplus */
 
 #ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
+/** @brief the program name (used for printing errors) */
 #define CMDLINE_PARSER_PACKAGE "Distancer"
 #endif
 
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "Distancer"
+#endif
+
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
  * @param args_info the structure where option information will be stored
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser (int argc, char * const *argv,
+int cmdline_parser (int argc, char **argv,
   struct gengetopt_args_info *args_info);
 
 /**
  * @return 0 if everything went fine, NON 0 if an error took place
  * @deprecated use cmdline_parser_ext() instead
  */
-int cmdline_parser2 (int argc, char * const *argv,
+int cmdline_parser2 (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   int override, int initialize, int check_required);
 
  * @param params additional parameters for the parser
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser_ext (int argc, char * const *argv,
+int cmdline_parser_ext (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);
 
 int cmdline_parser_required (struct gengetopt_args_info *args_info,
   const char *prog_name);
 
-extern char *cmdline_parser_distance_values[] ;	/**< @brief Possible values for distance.  */
+extern const char *cmdline_parser_distance_values[];  /**< @brief Possible values for distance. */
 
 
 #ifdef __cplusplus

tools/SVMperfer/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.4
   generated with the following command:
-  /r03/cypark/sleipnir/../sleipnir-extlib/gengetopt-2.22/src/gengetopt -iSVMperfer.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iSVMperfer.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
   "  -v, --verbosity=INT         Sets the svm_struct verbosity  (default=`0')",
   "  -s, --skip=INT              Number of columns to skip in input pcls  \n                                (default=`2')",
   "  -n, --normalize             Normalize PCLS to 0 mean 1 variance  \n                                (default=off)",
-  "  -c, --cross_validation=INT  Number of cross-validation sets  (default=`5')",
+  "  -c, --cross_validation=INT  Number of cross-validation sets ( arg of 1 will \n                                turn off cross-validation )  (default=`5')",
   "  -e, --error_function=INT    Sets the loss function for SVM learning: Choice \n                                of:\n\n                                0\tZero/one loss: 1 if vector of predictions \n                                contains error, 0 otherwise.\n\n                                1\tF1: 100 minus the F1-score in percent.\n\n                                2\tErrorrate: Percentage of errors in \n                                prediction vector.\n\n                                3\tPrec/Rec Breakeven: 100 minus PRBEP in \n                                percent.\n\n                                4\tPrec@k: 100 minus precision at k in percent.\n\n                                5\tRec@k: 100 minus recall at k in percent.\n\n                                10\tROCArea: Percentage of swapped pos/neg \n                                pairs (i.e. 100 - ROCArea).\n                                  (default=`10')",
   "  -k, --k_value=FLOAT         Value of k parameter used for Prec@k and Rec@k in \n                                (0,1)  (default=`0.5')",
   "  -t, --tradeoff=FLOAT        SVM tradeoff constant C  (default=`1')",
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 static int
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  FIX_UNUSED (args_info);
   args_info->labels_arg = NULL;
   args_info->labels_orig = NULL;
   args_info->output_arg = NULL;
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n",
+     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+     CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n", gengetopt_args_info_description);
+    printf("%s\n\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = NULL;
+  args_info->inputs = 0;
   args_info->inputs_num = 0;
 }
 
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
 {
+  FIX_UNUSED (values);
   if (arg) {
     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
   } else {
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = NULL;
+  char *result = 0;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 {
   int result;
   struct cmdline_parser_params params;
   params.check_ambiguity = 0;
   params.print_errors = 1;
 
-  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
 
   return result;
 }
 {
   int result = EXIT_SUCCESS;
 
-  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
+  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
     result = EXIT_FAILURE;
 
   return result;
 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
 {
   int error = 0;
+  FIX_UNUSED (additional_error);
 
   /* checks for required options */
   if (! args_info->input_given)
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, char *possible_values[], const char *default_value,
+               char *value, const char *possible_values[],
+               const char *default_value,
                cmdline_parser_arg_type arg_type,
                int check_ambiguity, int override,
                int no_free, int multiple_option,
   const char *val = value;
   int found;
   char **string_field;
+  FIX_UNUSED (field);
 
   stop_char = 0;
   found = 0;
       return 1; /* failure */
     }
 
+  FIX_UNUSED (default_value);
     
   if (field_given && *field_given && ! override)
     return 0;
 
 
 int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (
+  int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "tradeoff",	1, NULL, 't' },
         { "params",	1, NULL, 'p' },
         { "mmap",	0, NULL, 'M' },
-        { NULL,	0, NULL, 0 }
+        { 0,  0, 0, 0 }
       };
 
       c = getopt_long (argc, argv, "hVl:o:i:m:aSv:s:nc:e:k:t:p:M", long_options, &option_index);
             goto failure;
         
           break;
-        case 'c':	/* Number of cross-validation sets.  */
+        case 'c':	/* Number of cross-validation sets ( arg of 1 will turn off cross-validation ).  */
         
         
           if (update_arg( (void *)&(args_info->cross_validation_arg), 

tools/SVMperfer/cmdline.h

 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22
+ *  generated by GNU Gengetopt version 2.22.4
  *  http://www.gnu.org/software/gengetopt.
  *  DO NOT modify this file, since it can be overwritten
  *  @author GNU Gengetopt by Lorenzo Bettini */
 #endif /* __cplusplus */
 
 #ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
+/** @brief the program name (used for printing errors) */
 #define CMDLINE_PARSER_PACKAGE "SVMperfer"
 #endif
 
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "SVMperfer"
+#endif
+
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
   const char *skip_help; /**< @brief Number of columns to skip in input pcls help description.  */
   int normalize_flag;	/**< @brief Normalize PCLS to 0 mean 1 variance (default=off).  */
   const char *normalize_help; /**< @brief Normalize PCLS to 0 mean 1 variance help description.  */
-  int cross_validation_arg;	/**< @brief Number of cross-validation sets (default='5').  */
-  char * cross_validation_orig;	/**< @brief Number of cross-validation sets original value given at command line.  */
-  const char *cross_validation_help; /**< @brief Number of cross-validation sets help description.  */
+  int cross_validation_arg;	/**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) (default='5').  */
+  char * cross_validation_orig;	/**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) original value given at command line.  */
+  const char *cross_validation_help; /**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) help description.  */
   int error_function_arg;	/**< @brief Sets the loss function for SVM learning: Choice of:
   0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
   1\tF1: 100 minus the F1-score in percent.
  * @param args_info the structure where option information will be stored
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser (int argc, char * const *argv,
+int cmdline_parser (int argc, char **argv,
   struct gengetopt_args_info *args_info);
 
 /**
  * @return 0 if everything went fine, NON 0 if an error took place
  * @deprecated use cmdline_parser_ext() instead
  */
-int cmdline_parser2 (int argc, char * const *argv,
+int cmdline_parser2 (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   int override, int initialize, int check_required);
 
  * @param params additional parameters for the parser
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser_ext (int argc, char * const *argv,
+int cmdline_parser_ext (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);