Пример #1
0
int main(void) {
    draw_screen();

    // Main "game" loop
    while (1) {
        switch (joypad()) {
            case J_LEFT:
                 _input1--;
                 redraw_in1();
                 break;
            case J_RIGHT:
                 _input1++;
                 redraw_in1();
                 break;
            case J_UP:
                 _input2++;
                 redraw_in2();
                 break;
            case J_DOWN:
                 _input2--;
                 redraw_in2();
                 break;
            case J_START:
                 calc_ans();
                 break;
            case J_SELECT:
                 select_op();
                 break;
        }
    }

    return 0;
}
Пример #2
0
void unary_op(){
	if (lookahead == LOW_BIN_OP && lexval.ival == '-')	
		match(LOW_BIN_OP);
	else if (lexval.ival == PROJECT)
		project_op();
	else if (lexval.ival == SELECT)
		select_op();
	else if (lexval.ival == EXISTS)
		exists_op();
	else if (lexval.ival == ALL)
		all_op();
	else if (lexval.ival == EXTEND)
		extend_op();	
	else if (lexval.ival == UPDATE)
		update_op();
	else if (lexval.ival == NOT)
		match(UNARY_OP);
	else //(lexval.ival == RENAME)
		rename_op();
}
Пример #3
0
int main(int argc, char *argv[]) 
{
	int i = 0;
	int *key;
	record *value;
	filedata_t *fd;
	final_data_t op_results;
	final_data_t op_results0;
	final_data_t op_results2;
	final_data_t op_results3;
	final_data_t op_results4;
	final_data_t op_results5;
	final_data_t op_results6;
	final_data_t op_results7;

	struct timeval starttime,endtime;
	char * fname, * op_num_str;
	int op_num;

	struct timeval begin_total, end_total;


	// Make sure a filename is specified
	if (argv[1] == NULL)
	{
		printf("USAGE: %s <filename> [ # of operator to use (1:sel 2:prj 3:srt 4:prt 5:agg) ]\n", argv[0]);
		exit(1);
	}

	fname = argv[1];
	op_num_str = argv[2];

	// Get the number of operator to run
	CHECK_ERROR((op_num = (op_num_str == NULL) ? 10 : atoi(op_num_str)) < 0);



	fd=load_op (fname, sizeof(record));	
		//printLoads(fd);
	
	if ((op_num  != 6) && (op_num != 0)){
		prepare_op(fd, &op_results, 0);
		dprintf("\nop_results length  %d:\n", op_results.length);
	}
	get_time (&begin_total);

	switch(op_num){
		case 0:
			prepare_op(fd, &op_results0, 1);

			break;
		case 1:
			select_op(&op_results, cmp12, &op_results2, 1);
				print_sel(op_results2);
			break;
		case 2:
			project_op(&op_results, prj5, &op_results3, 1);
				print_prj(op_results3);
			break;
		case 3:
			sort_op(&op_results, stringcmp, key_ptr, keysize, &op_results4, 1);
				print_srt(op_results4);
			break;
		case 4:
			partition_op(&op_results, hsh_prt, &op_results5, 1);
				print_prt(op_results5);

			//	partition_2op(&op_results, prt, &op_results5, 0);
			break;
		case 5:
			aggregate_op(&op_results, aggr, key_ptr, keysize, &op_results6, 1);
				printAggr(op_results6);
			break;
		case 6:
			select_op_old(fd,cmp12, &op_results7, 1);
				print_sel(op_results7);
			break;
		default:
			printf("No operator selected\n");
			break;
	}

	get_time (&end_total);
	unload_op(fd);


#ifdef TIMING
	fprintf (stderr, "\n\nOverall time: %u\n\n\n", time_diff (&end_total, &begin_total));
#endif
	return 1;
}
Пример #4
0
//--------------------------------------------------------------
//Return a cigar string for dna. For Rna it's invalid
//--------------------------------------------------------------
char* generate_cigar_str(char *str_seq_p, char *str_ref_p, unsigned int start_seq, unsigned int seq_orig_len, unsigned int length, size_t *number_op_tot){
  char *cigar_p;

  unsigned int cigar_max_len = length * 2;
  char operation_number[cigar_max_len];

  unsigned char status;
  unsigned char transition;
  short int cigar_soft;
  short int value = 0;
  unsigned int number_op = 0;
  char operation;
  unsigned int perfect = 0;  
  unsigned int deletions_tot = 0;
  
  *number_op_tot = 0;
  cigar_p = (char *)malloc(sizeof(char)*cigar_max_len);
  cigar_p[0] = '\0';
  
  //printf("seq(%d) start::%d : %s\n", length, start_seq, str_seq_p );
  //printf("ref(%d): %s\n", length, str_ref_p);
  
  //hard clipping start
  if(start_seq > 0){
    sprintf(operation_number, "%iH", start_seq);
    cigar_p = strcat(cigar_p, operation_number);
    *number_op_tot += 1;
  }
  
  //First Status
  if(str_seq_p[0] != '-' && str_ref_p[0] != '-'){
    status = CIGAR_MATCH_MISMATCH;
    //Soft clipping
    cigar_soft = 0;
    while((str_ref_p[cigar_soft] != '-') && (str_seq_p[cigar_soft] != '-') && 
	  (str_ref_p[cigar_soft] != str_seq_p[cigar_soft])){
      cigar_soft++;
      value++;
    }
    if(value > 0){
      sprintf(operation_number, "%iS", value);
      cigar_p = strcat(cigar_p, operation_number);
      *number_op_tot += 1;
    } 
  }else if(str_seq_p[0] == '-'){
    if(str_ref_p[0] == '-'){
      status = CIGAR_PADDING;
    }else{
      status = CIGAR_DELETION;
    }
  }else if(str_ref_p[0] == '-'){
    status = CIGAR_INSERTION;
  }
  
  for(int i = value; i < length; i++){
    //Transition
    if(str_seq_p[i] != '-' && str_ref_p[i] != '-'){
      transition = CIGAR_MATCH_MISMATCH;
      if(str_seq_p[i] == str_ref_p[i] ){
        perfect++;
      }
    }else if(str_seq_p[i] == '-'){
      if(str_ref_p[i] == '-'){
        transition = CIGAR_PADDING;
      }else{
        transition = CIGAR_DELETION;
        deletions_tot++;
      }
    }else if(str_ref_p[i] == '-'){
      transition = CIGAR_INSERTION;
    }
    
    if(transition != status){
      //Insert operation in cigar string
      operation = select_op(status);
      sprintf(operation_number, "%d%c", number_op, operation);
      cigar_p = strcat(cigar_p, operation_number);
      number_op = 1;
      *number_op_tot += 1;
      status = transition;
    }else{
      number_op++;
    }
  }
  
  if((length == perfect) && (perfect == seq_orig_len)){
    status = CIGAR_PERFECT_MATCH;
  }

  *number_op_tot += 1;
  operation = select_op(status);
  
  
  //Hard and Soft clipped end
  if(status == CIGAR_MATCH_MISMATCH){
    cigar_soft = length - 1;
    value = 0;
    while((str_ref_p[cigar_soft] != '-') && (str_seq_p[cigar_soft] != '-') && 
	  (str_seq_p[cigar_soft] != str_ref_p[cigar_soft])){
      cigar_soft--;
      value++;
      //printf("(Soft %c!=%c)", output_p->mapped_ref_p[i][cigar_soft], output_p->mapped_seq_p[i][cigar_soft]);
    }
    
    sprintf(operation_number, "%d%c", number_op - value, operation);
    cigar_p = strcat(cigar_p, operation_number);
    
    if(value > 0){
      number_op -= value;
      sprintf(operation_number, "%iS", value);
      cigar_p = strcat(cigar_p, operation_number);
      *number_op_tot += 1;
    }
  }else{
    sprintf(operation_number, "%d%c", number_op, operation);
    cigar_p = strcat(cigar_p, operation_number);
  }
  //printf("%d+%d < %d\n", length - deletions_tot, start_seq, seq_orig_len);
  if( ((length - deletions_tot) + start_seq) < seq_orig_len ){
    sprintf(operation_number, "%iH", seq_orig_len - ((length - deletions_tot) + start_seq));
    cigar_p = strcat(cigar_p, operation_number);
    *number_op_tot += 1;
  }
    
  //printf("%d-%d\n", length, *number_op_tot);
 
  return cigar_p;
}