//{{{struct vid_file *new_vid_file(char *file_name, struct vid_file *new_vid_file(char *file_name, char *full_cmd, uint32_t num_variants, uint32_t num_samples) { struct vid_file *v = (struct vid_file *) malloc(sizeof(struct vid_file)); v->file_name = strdup(file_name); v->type = VID_LOCAL; v->file.local = fopen(file_name,"wb"); if (!v->file.local) err(EX_CANTCREAT, "Cannot create VID file \"%s\"", file_name); v->gqt_header = new_gqt_file_header('v', full_cmd, num_variants, num_samples); v->vids = NULL; if (fwrite(v->gqt_header, sizeof(struct gqt_file_header), 1, v->file.local) != 1) err(EX_IOERR, "Error writing header to VID file \"%s\"", file_name); return v; }
struct off_file *new_off_file(char *file_name, char *full_cmd, uint32_t num_variants, uint32_t num_samples) { struct off_file *o = (struct off_file *) malloc(sizeof(struct off_file)); if (!o) err(EX_OSERR, "malloc error"); o->gqt_header = new_gqt_file_header('o', full_cmd, num_variants, num_samples); o->file_name = strdup(file_name); o->file = fopen(file_name,"wb"); if (!o->file) err(EX_CANTCREAT, "Cannot create OFF file '%s'", file_name); if (fwrite(o->gqt_header, sizeof(struct gqt_file_header), 1, o->file) != 1) err(EX_IOERR, "Error writing header to OFF file '%s'", file_name); return o; }
struct bim_file *new_bim_file(char *file_name, char *full_cmd, uint32_t num_variants, uint32_t num_samples, uint64_t u_size, uint64_t c_size, uint64_t h_size, uint64_t *md_line_lens) { struct bim_file *b = (struct bim_file *) malloc(sizeof(struct bim_file)); b->gqt_header = new_gqt_file_header('b', full_cmd, num_variants, num_samples); b->bim_header = new_bim_file_header(u_size, c_size, h_size, md_line_lens); b->file_name = strdup(file_name); b->file = fopen(file_name,"wb"); if (!b->file) err(EX_CANTCREAT, "Cannot create BIM file \"%s\"", file_name); if (fwrite(b->gqt_header, sizeof(struct gqt_file_header), 1, b->file) != 1) err(EX_IOERR, "Error writing header to BIM file \"%s\"", file_name); if (fwrite(&u_size, sizeof(uint64_t), 1, b->file) != 1) err(EX_IOERR, "Error writing header to BIM file \"%s\"", file_name); if (fwrite(&c_size, sizeof(uint64_t), 1, b->file) != 1) err(EX_IOERR, "Error writing header to BIM file \"%s\"", file_name); if (fwrite(&h_size, sizeof(uint64_t), 1, b->file) != 1) err(EX_IOERR, "Error writing header to BIM file \"%s\"", file_name); if (fwrite(md_line_lens, sizeof(uint64_t), num_variants, b->file) != num_variants) err(EX_IOERR, "Error writing header to BIM file \"%s\"", file_name); b->data_start = ftell(b->file); return b; }