chunk.c
void tbk_print1(tbk_data_t *d, int i, view_conf_t *conf, kstring_t *ks) {

  switch(DATA_TYPE(d->dtype)) {
  case DT_INT1: {
    ksprintf(ks, "\t%d", ((uint8_t*)(d->data))[i]);
    break;
  }
  case DT_INT2: {
    ksprintf(ks, "\t%d", ((uint8_t*)(d->data))[i]);
    break;
  }
  case DT_INT32: {
    int data = ((int32_t*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%d", data);
    break;
  }
  case DT_FLOAT: {
    float data = ((float*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%f", data);
    break;
  }
  case DT_DOUBLE: {
    double data = ((double*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%f", data);
    break;
  }
  case DT_STRINGF: {
    char *data = ((char*) (d->data)) + i*STRING_MAX(d->dtype);
    kputc('\t', ks); kputs(data, ks);
    break;
  }
  case DT_STRINGD: {
    char *data = ((char**) (d->data))[i];
    kputc('\t', ks); kputs(data, ks);
    free(data);
    break;
  }
  case DT_ONES: {
    float data = ((float*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%.*f", conf->precision, data);
    break;
  }
  case DT_FLOAT_INT: {
    float data = ((float*) (d->data))[i*2];
    int data2 = ((int32_t*) (d->data))[i*2+1];
    if (conf->na_for_negative && data < 0) {
      kputc('\t', ks); kputs(conf->na_token, ks);
    } else {
      if (conf->min_coverage >= 0 && data2 < conf->min_coverage) {
        kputc('\t', ks); kputs(conf->na_token, ks);
      } else {
        ksprintf(ks, "\t%f", data);
      }
    }
    if (conf->print_all_units) ksprintf(ks, "\t%d", data2);
    break;
  }
  case DT_FLOAT_FLOAT: {
    float data = ((float*) (d->data))[i*2];
    float data2 = ((float*) (d->data))[i*2+1];
    if (conf->na_for_negative && data < 0) {
      kputc('\t', ks); kputs(conf->na_token, ks);
    } else {
      if (conf->max_pval >= 0 && data2 > conf->max_pval) {
        kputc('\t', ks); kputs(conf->na_token, ks);
      } else {
        ksprintf(ks, "\t%f", data);
      }
    }
    if (conf->print_all_units) ksprintf(ks, "\t%f", data2);
    break;
  }
  default: wzfatal("Unrecognized data type: %d.\n", DATA_TYPE(d->dtype));
  }
}
/* output the i-th data entry */
output the i-th data entry
output the i - th data entry
void tbk_print1(tbk_data_t *d, int i, view_conf_t *conf, kstring_t *ks) {
  switch(DATA_TYPE(d->dtype)) {
  case DT_INT1: {
    ksprintf(ks, "\t%d", ((uint8_t*)(d->data))[i]);
    break;
  }
  case DT_INT2: {
    ksprintf(ks, "\t%d", ((uint8_t*)(d->data))[i]);
    break;
  }
  case DT_INT32: {
    int data = ((int32_t*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%d", data);
    break;
  }
  case DT_FLOAT: {
    float data = ((float*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%f", data);
    break;
  }
  case DT_DOUBLE: {
    double data = ((double*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%f", data);
    break;
  }
  case DT_STRINGF: {
    char *data = ((char*) (d->data)) + i*STRING_MAX(d->dtype);
    kputc('\t', ks); kputs(data, ks);
    break;
  }
  case DT_STRINGD: {
    char *data = ((char**) (d->data))[i];
    kputc('\t', ks); kputs(data, ks);
    free(data);
    break;
  }
  case DT_ONES: {
    float data = ((float*) (d->data))[i];
    if (conf->na_for_negative && data < 0) { kputc('\t', ks); kputs(conf->na_token, ks); }
    else ksprintf(ks, "\t%.*f", conf->precision, data);
    break;
  }
  case DT_FLOAT_INT: {
    float data = ((float*) (d->data))[i*2];
    int data2 = ((int32_t*) (d->data))[i*2+1];
    if (conf->na_for_negative && data < 0) {
      kputc('\t', ks); kputs(conf->na_token, ks);
    } else {
      if (conf->min_coverage >= 0 && data2 < conf->min_coverage) {
        kputc('\t', ks); kputs(conf->na_token, ks);
      } else {
        ksprintf(ks, "\t%f", data);
      }
    }
    if (conf->print_all_units) ksprintf(ks, "\t%d", data2);
    break;
  }
  case DT_FLOAT_FLOAT: {
    float data = ((float*) (d->data))[i*2];
    float data2 = ((float*) (d->data))[i*2+1];
    if (conf->na_for_negative && data < 0) {
      kputc('\t', ks); kputs(conf->na_token, ks);
    } else {
      if (conf->max_pval >= 0 && data2 > conf->max_pval) {
        kputc('\t', ks); kputs(conf->na_token, ks);
      } else {
        ksprintf(ks, "\t%f", data);
      }
    }
    if (conf->print_all_units) ksprintf(ks, "\t%f", data2);
    break;
  }
  default: wzfatal("Unrecognized data type: %d.\n", DATA_TYPE(d->dtype));
  }
}
void tbk_print1 ( tbk_data_t * d , int i , view_conf_t * conf , kstring_t * ks ) { switch ( DATA_TYPE ( d -> dtype ) ) { case DT_INT1 : { ksprintf ( ks , " \t " , ( ( uint8_t * ) ( d -> data ) ) [ i ] ) ; break ; } case DT_INT2 : { ksprintf ( ks , " \t " , ( ( uint8_t * ) ( d -> data ) ) [ i ] ) ; break ; } case DT_INT32 : { int data = ( ( int32_t * ) ( d -> data ) ) [ i ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else ksprintf ( ks , " \t " , data ) ; break ; } case DT_FLOAT : { float data = ( ( float * ) ( d -> data ) ) [ i ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else ksprintf ( ks , " \t " , data ) ; break ; } case DT_DOUBLE : { double data = ( ( double * ) ( d -> data ) ) [ i ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else ksprintf ( ks , " \t " , data ) ; break ; } case DT_STRINGF : { char * data = ( ( char * ) ( d -> data ) ) + i * STRING_MAX ( d -> dtype ) ; kputc ( ' \t ' , ks ) ; kputs ( data , ks ) ; break ; } case DT_STRINGD : { char * data = ( ( char * * ) ( d -> data ) ) [ i ] ; kputc ( ' \t ' , ks ) ; kputs ( data , ks ) ; free ( data ) ; break ; } case DT_ONES : { float data = ( ( float * ) ( d -> data ) ) [ i ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else ksprintf ( ks , " \t " , conf -> precision , data ) ; break ; } case DT_FLOAT_INT : { float data = ( ( float * ) ( d -> data ) ) [ i * 2 ] ; int data2 = ( ( int32_t * ) ( d -> data ) ) [ i * 2 + 1 ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else { if ( conf -> min_coverage >= 0 && data2 < conf -> min_coverage ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else { ksprintf ( ks , " \t " , data ) ; } } if ( conf -> print_all_units ) ksprintf ( ks , " \t " , data2 ) ; break ; } case DT_FLOAT_FLOAT : { float data = ( ( float * ) ( d -> data ) ) [ i * 2 ] ; float data2 = ( ( float * ) ( d -> data ) ) [ i * 2 + 1 ] ; if ( conf -> na_for_negative && data < 0 ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else { if ( conf -> max_pval >= 0 && data2 > conf -> max_pval ) { kputc ( ' \t ' , ks ) ; kputs ( conf -> na_token , ks ) ; } else { ksprintf ( ks , " \t " , data ) ; } } if ( conf -> print_all_units ) ksprintf ( ks , " \t " , data2 ) ; break ; } default : wzfatal ( " \n " , DATA_TYPE ( d -> dtype ) ) ; } }
output the i-th data entry
output the i - th data entry