pio_status_t pio_transpose(const char *plink_file_prefix, const char *transposed_file_prefix) { struct pio_file_t plink_file; if( pio_open( &plink_file, plink_file_prefix ) != PIO_OK ) { return PIO_ERROR; } char *bed_path = concatenate( plink_file_prefix, ".bed" ); char *transposed_bed_path = concatenate( transposed_file_prefix, ".bed" ); pio_status_t status = bed_transpose( bed_path, transposed_bed_path, pio_num_loci( &plink_file ), pio_num_samples( &plink_file ) ); if( status == PIO_OK ) { char *fam_path = concatenate( plink_file_prefix, ".fam" ); char *transposed_fam_path = concatenate( transposed_file_prefix, ".fam" ); file_copy( fam_path, transposed_fam_path ); free( fam_path ); free( transposed_fam_path ); char *bim_path = concatenate( plink_file_prefix, ".bim" ); char *transposed_bim_path = concatenate( transposed_file_prefix, ".bim" ); file_copy( bim_path, transposed_bim_path ); free( bim_path ); free( transposed_bim_path ); } pio_close( &plink_file ); free( bed_path ); free( transposed_bed_path ); return status; }
Data::Data(std::string datapath,int nthreads) { nSites = 0; nIndiv = 0; this->datapath = datapath; this->nthreads = nthreads; if( pio_open( &plink_file, datapath.c_str() ) != PIO_OK ) { std::cerr << "[Data::getsize] Error opening plink files " << datapath << ".[bed/bim/fam] " << std::endl << std::endl << "This error means that libplinkio (https://github.com/mfranberg/libplinkio) " << "cannot read the dataset correctly." << std::endl << std::endl << "Make sure that plink can process the dataset without non-standard input " << "options such as `--allow-extra-chr` which indicates that the data " << "contains unrecognized chromosome codes." << std::endl << std::endl << "For example, check that `plink --bfile datapath --freq` runs without errors." << std::endl << std::endl; exit(1); } if( !pio_one_locus_per_row( &plink_file ) ) { std::cerr << "[Data::getsize] bed2diffs requires plink files [bed/bim/fam] in SNP-major mode" << std::endl; exit(1); } }
Data::Data(std::string datapath,int nthreads) { nSites = 0; nIndiv = 0; this->datapath = datapath; this->nthreads = nthreads; if( pio_open( &plink_file, datapath.c_str() ) != PIO_OK ) { std::cerr << "[Data::getsize] Error opening plink files " << datapath << ".[bed/bim/fam]" << std::endl; exit(1); } if( !pio_one_locus_per_row( &plink_file ) ) { std::cerr << "[Data::getsize] This program requires plink files [bed/bim/fam] in SNP-major mode" << std::endl; exit(1); } }
void key_drv_thread(KEY2_DRIVER_INFO* drv_info) { unsigned int i, mask; unsigned char button_ticks[KEY_COUNT]; unsigned int new_keys; CHandle keyrd_hnd; pio_open(&keyrd_hnd, &drv_info->pins); for(i=0; i<KEY_COUNT; i++) button_ticks[i] = 0; btns_pressed = 0; for(;;) { // scan keyboard every 5ms while some key is pressed do { tsk_sleep(KEY_POLLING_TIME-4); keyrd_hnd.tsk_read(&new_keys, 4); mask = 1; for(i=0; i<KEY_COUNT; i++) { if (new_keys & drv_info->key_codes[i]) { button_ticks[i] = 0; if (mask & btns_pressed) { btns_pressed ^= mask; key_post(KEY_UP_CODE+i); } } else {//button pressed button_ticks[i]++; if(mask & btns_pressed) { //button hold? if (button_ticks[i] > (KEY_REPEAT_TIME/KEY_POLLING_TIME)) { button_ticks[i] = 0; key_post(KEY_REPEAT_CODE+i); } } else if (button_ticks[i] > (KEY_DEBOUNCE_TIME/KEY_POLLING_TIME)) { button_ticks[i] = 0; btns_pressed |= mask; key_post(KEY_DOWN_CODE+i); } } mask <<=1; } } while(new_keys ^ drv_info->pins.mask); //wait for any key... keyrd_hnd.tsk_read_locked(&new_keys, 4); } }