Example #1
0
static VALUE
mol_by_mol(VALUE self, VALUE q_mol, VALUE t_mol)
{
  struct Query  query;
  struct Target target;
  struct State  state;
  VALUE result;

  target.max_length = 0;
  state.max_length = 0;

  query_setup(  q_mol, & query  );
  target_setup( t_mol, & target );

  state_allocate(& state, & query, & target);

  if(rb_block_given_p() == Qtrue){
    state_setup_block(& state);
  }
  else{
    state_setup(& state, & query, & target);
  }

  search_by_ullmann(& state, & query, & target);
  result = state_get_result(& state);

  query_free(& query);
  target_free(& target);
  state_free(& state);

  return result;
}
Example #2
0
static void
db_load(struct CompoundDB * db, struct Query * query){

  int new_n_bits;
  int new_n_bytes;
  int mat_ptr;

  struct Target target;
  struct State state;
  struct Record record;

  int i, j;

  target.n_bits  = 0;
  target.n_bytes = 0;
  target.max_length = 0;
  state.max_length = 0;

  for(;;){
    if(feof(db->idx) || feof(db->mat) || feof(db->mat)){
      printf("Database broken!\n");
      return;
    }

    fread(& record, sizeof(struct Record), 1, db->idx);
    if(record.n_bits == -1){
      return;
    }
    target_setup_db(& target, & record);
    if(record.information != -1){

      fread(target.mat, sizeof(long), target.n_bits * target.n_bytes, db->mat);
      fread(target.typ, sizeof(long), target.n_bits,                  db->typ);

      state_allocate(& state, query, & target);
      state_setup(& state, query, & target);
      //show(state.mat, query->len, target.n_bits);
      search_by_ullmann(& state, query, & target);
    }else{
      fread(target.typ, sizeof(long), target.n_bytes, db->typ);
      printf("atom_number : %d\n", target.typ[0]);
    }
  }
  target_free_db(& target);
  state_free(& state);
}
Example #3
0
int main (int argc, char **argv)
{
    state_t * self = (state_t*) calloc (1, sizeof (state_t));
    self->use_gui = 1;

    char *optstring = "hc:p:";
    int c;
    struct option long_opts[] = { 
        { "help", no_argument, 0, 'h' },
        { "chain", required_argument, 0, 'c' },
        { "plugin-path", required_argument, 0, 'p' },
        { "no-gui", no_argument, 0, 'u' },
        { 0, 0, 0, 0 }
    };

    while ((c = getopt_long (argc, argv, optstring, long_opts, 0)) >= 0)
    {
        switch (c) {
            case 'c':
                self->xml_fname = strdup (optarg);
                break;
            case 'u':
                self->use_gui = 0;
                break;
            case 'p':
                self->extra_plugin_path = strdup (optarg);
                break;
            case 'h':
            default:
                usage ();
                break;
        };
    }

    if (!self->use_gui && !self->xml_fname) usage();

    if (self->use_gui) {
        gtk_init (&argc, &argv);
    } else {
        g_type_init ();
    }

    if (!g_thread_supported()) {
        g_thread_init (NULL);
    }

    if (0 != state_setup (self)) {
        state_cleanup(self);
        return 1;
    }

    if (self->use_gui) {
        camview_gtk_quit_on_interrupt ();
        gtk_main ();
        state_cleanup (self);
    } else {
        // did everything start up correctly?
        CamUnit *faulty = cam_unit_chain_all_units_stream_init(self->chain);
        if (faulty) {
            int faulty_index = 0;
            for(GList *uiter = cam_unit_chain_get_units(self->chain);
                    uiter && uiter->data != faulty; uiter = uiter->next)
                faulty_index ++;

            fprintf(stderr, "Unit %d [%s] is not streaming, aborting...\n",
                    faulty_index, cam_unit_get_name (faulty));
            return -1;
        }

        GMainLoop *mainloop = g_main_loop_new (NULL, FALSE);
        camview_g_quit_on_interrupt (mainloop);
        g_main_loop_run (mainloop);
        g_main_loop_unref (mainloop);
        state_cleanup (self);
    }

    return 0;
}