예제 #1
0
void PropertyManager::parseBlock(BlockProperties& properties)
{
	parseMethods(properties);

	if (!properties.luaRef["perBlock"].isNil())
		parsePerBlockProperties(properties);
	if (!properties.luaRef["events"].isNil())
		parseEvents(properties);
}
예제 #2
0
QDBusMetaObjectGenerator::QDBusMetaObjectGenerator(const QString &interfaceName,
                                                   const QDBusIntrospection::Interface *parsedData)
    : data(parsedData), interface(interfaceName)
{
    if (data) {
        parseProperties();
        parseSignals();             // call parseSignals first so that slots override signals
        parseMethods();
    }
}
예제 #3
0
 void parseInterface( JSON::Entity const &interfaceObject, Interface &interface )
 {
   JSON::ObjectDecoder interfaceObjectDecoder( interfaceObject );
   JSON::Entity keyString, valueEntity;
   while ( interfaceObjectDecoder.getNext( keyString, valueEntity ) )
   {
     try
     {
       if ( keyString.stringIs( "methods", 7 ) )
       {
         valueEntity.requireArray();
         parseMethods( valueEntity, interface.methods );
       }
     }
     catch ( Exception e )
     {
       interfaceObjectDecoder.rethrow( e );
     }
   }
 }
예제 #4
0
/**
 * The function to call when running the 'similarity' command.
 */
RunSimilarity::RunSimilarity(int argc, char *argv[]) {

  // Initialize some of the program parameters.
  min_obs = 30;

  // Defaults for mutual information B-spline estimate.
  mi_bins = 10;
  mi_degree = 3;

  // Set the default threshold for expression values.
  threshold  = -INFINITY;

  // Initialize the array of method names. We set it to 10 as max. We'll
  // most likely never have this many of similarity methods available.
  method = (char **) malloc(sizeof(char *) * 10);

  // The concatenated method.
  char * cmethod = NULL;

  // loop through the incoming arguments until the
  // getopt_long function returns -1. Then we break out of the loop
  // The value returned by getopt_long.
  int c;
  while(1) {
    int option_index = 0;

    // specify the long options. The values returned are specified to be the
    // short options which are then handled by the case statement below
    static struct option long_options[] = {
      {"help",         no_argument,       0,  'h' },
      {"method",       required_argument, 0,  'm' },
      {"min_obs",      required_argument, 0,  'o' },
      {"th",           required_argument, 0,  's' },
      // Filtering options.
      {"set1",         required_argument, 0,  '1' },
      {"set2",         required_argument, 0,  '2' },
      // Mutual information options.
      {"mi_bins",      required_argument, 0,  'b' },
      {"mi_degree",    required_argument, 0,  'd' },
      // Expression matrix options.
      {"rows",         required_argument, 0,  'r' },
      {"cols",         required_argument, 0,  'c' },
      {"headers",      no_argument,       &headers,  1 },
      {"omit_na",      no_argument,       &omit_na,  1 },
      {"func",         required_argument, 0,  'f' },
      {"na_val",       required_argument, 0,  'n' },
      {"ematrix",      required_argument, 0,  'e' },
      // Last element required to be all zeros.
      {0, 0, 0,  0 }
    };

    // get the next option
    c = getopt_long(argc, argv, "m:o:b:d:j:i:t:a:l:r:c:f:n:e:s:h", long_options, &option_index);

    // if the index is -1 then we have reached the end of the options list
    // and we break out of the while loop
    if (c == -1) {
      break;
    }

    // handle the options
    switch (c) {
      case 0:
        break;
      case 'm':
        cmethod = optarg;
        break;
      case 'o':
        min_obs = atoi(optarg);
        break;
      case 's':
        threshold = atof(optarg);
        break;
      // Mutual information options.
      case 'b':
        mi_bins = atoi(optarg);
        break;
      case 'd':
        mi_degree = atoi(optarg);
        break;
      // Expression matrix options.
      case 'e':
        infilename = optarg;
        break;
      case 'r':
        rows = atoi(optarg);
        break;
      case 'c':
        cols = atoi(optarg);
        break;
      case 'n':
        na_val = optarg;
        break;
      case 'f':
        strcpy(func, optarg);
        break;
      // Help and catch-all options.
      case 'h':
        printUsage();
        exit(-1);
        break;
      case '?':
        exit(-1);
        break;
      case ':':
        printUsage();
        exit(-1);
        break;
      default:
        printUsage();
        exit(-1);
    }
  }

  // Make sure the similarity method is valid.
  if (!cmethod) {
    fprintf(stderr,"Please provide the method (--method option).\n");
    exit(-1);
  }
  parseMethods(cmethod);

  // make sure the required arguments are set and appropriate
  if (!infilename) {
    fprintf(stderr,"Please provide an expression matrix (--ematrix option).\n");
    exit(-1);
  }
  // make sure we have a positive integer for the rows and columns of the matrix
  if (rows < 0 || rows == 0) {
    fprintf(stderr, "Please provide a positive integer value for the number of rows in the \n");
    fprintf(stderr, "expression matrix (--rows option).\n");
    exit(-1);
  }
  if (cols < 0 || cols == 0) {
    fprintf(stderr, "Please provide a positive integer value for the number of columns in\n");
    fprintf(stderr, "the expression matrix (--cols option).\n");
    exit(-1);
  }

  if (omit_na && !na_val) {
    fprintf(stderr, "Error: The missing value string should be provided (--na_val option).\n");
    exit(-1);
  }
  // make sure the input file exists
  if (access(infilename, F_OK) == -1) {
    fprintf(stderr,"The input file does not exists or is not readable.\n");
    exit(-1);
  }

  // Create and initialize the histogram for the distribution of coefficients.
  histogram = (int *) malloc(sizeof(int) * HIST_BINS + 1);
  for (int m = 0; m < HIST_BINS + 1; m++) {
    histogram[m] = 0;
  }

  if (headers == 1) {
    printf("  Reading header line\n");
  }
  printf("  Performing transformation: %s \n", func);
  if (omit_na) {
    printf("  Missing values are: '%s'\n", na_val);
  }
  printf("  Required observations: %d\n", min_obs);
  for(int i = 0; i < this->num_methods; i++) {
    printf("  Using similarity method: '%s'\n", method[i]);
    if (strcmp(method[i], "mi") ==0) {
      printf("  Bins for B-Spline estimate of MI: %d\n", mi_bins);
      printf("  Degree for B-Spline estimate of MI: %d\n", mi_degree);
    }
  }
  printf("  Minimal observed value: %f\n", threshold);

  // Retrieve the data from the EMatrix file.
  printf("  Reading expression matrix...\n");
  ematrix = new EMatrix(infilename, rows, cols, headers, omit_na, na_val, func);

}