void do_sequential_read() { int fd; char *addr; size_t wsize; char mypath[PATH_LEN]; if (myrank == 0) { gio_dbg("Reade: scale: %s, size: %lu", scale, data_size); } get_rank_path(mypath); addr = (char*)gio_malloc(data_size); fd = gio_open(mypath, O_WRONLY | O_CREAT, 0); if (fd < 0) { gio_err("File open failed (%s:%s:%d)", __FILE__, __func__, __LINE__); } wsize = gio_write(mypath, fd, addr, data_size); if (wsize != data_size) { gio_err("Inputu wirte size is %f, but only %f bytes are written (%s:%s:%d)", data_size, wsize,__FILE__, __func__, __LINE__); } gio_close(mypath, fd); return; }
int main(int argc, char **argv) { GapIO *io; int xpos = 0; int opt; int lp_mode = 0; int mode = DISPLAY_QUAL | DISPLAY_CUTOFFS; extern char *optarg; contig_t *c; int cnum = 0; int read_only = 1; while ((opt = getopt(argc, argv, "hl:dcCx:e")) != -1) { switch (opt) { case '?': case 'h': usage(); return 0; case 'd': mode |= DISPLAY_DIFFS; break; case 'c': mode |= DISPLAY_CUTOFFS; break; case 'C': mode &= ~DISPLAY_CUTOFFS; break; case 'l': lp_mode = atoi(optarg); break; case 'x': cnum = atoi(optarg)-1; break; case 'e': read_only = 0; break; default: if (opt == ':') fprintf(stderr, "Missing parameter\n"); else fprintf(stderr, "Unknown option '%c'\n", opt); usage(); return 1; } } if (optind == argc) { usage(); return 1; } if (NULL == (io = gio_open(argv[optind], read_only, 0))) { fprintf(stderr, "Unable to open db: %s\n", argv[1]); return 1; } optind++; if (optind != argc) { xpos = atoi(argv[optind]); } io->contig_num = cnum; gio_read_contig(io, cnum, &c); cache_incr(io, c); #ifdef TEST_MODE //test_mode(io, &c, xpos); test_mode2(io, &c, xpos); //benchmark(io, &c); //test_mode3(io, arr(GCardinal, io->contig_order, cnum), xpos); #endif if (lp_mode) { print_output(io, &c, xpos, lp_mode, mode); gio_close(io); } else { init_curses(); curses_loop(io, &c, xpos, mode); endwin(); if (io->cache && io->debug_level > 0) { fputs("\n=== cache ===", stderr); HacheTableStats(io->cache, stderr); } gio_close(io); } if (!lp_mode) { printf("\n\n\tg_view:\tShort Read Alignment Viewer, version 1.2.11"SVN_VERS"\n"); printf("\n\tAuthor:\tJames Bonfield ([email protected])\n"); printf("\t\t2007-2011, Wellcome Trust Sanger Institute\n\n"); } return 0; }