コード例 #1
0
ファイル: gio.c プロジェクト: kento/gio
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;

}
コード例 #2
0
ファイル: tg_view.c プロジェクト: nathanhaigh/staden-trunk
/* Debug functions that don't use curses - handy for valgrind testing */
static void test_mode(GapIO *io, contig_t **c, int xpos) {
    rangec_t *r;
    int nr, i;

    r = contig_seqs_in_range(io, c, xpos, xpos+79, CSIR_SORT_BY_X, &nr);
    for (i = 0; i < nr; i++) {
        seq_t *s = get_seq(io, r[i].rec);
        printf("%.*s: range %d..%d seq %d+%d st=%d en=%d %.*s\n",
               s->name_len, s->name,
               r[i].start, r[i].end,
               s->pos, s->len,
               s->left, s->right,
               ABS(s->len), s->seq);

        s = dup_seq(s);
        complement_seq_t(s);

        printf("%.*s: range %d..%d seq %d+%d st=%d en=%d %.*s\n",
               s->name_len, s->name,
               r[i].start, r[i].end,
               s->pos, s->len,
               s->left, s->right,
               ABS(s->len), s->seq);
    }

    gio_close(io);
    system("ps lx | grep g_iotest | grep -v grep");
    exit(0);
}
コード例 #3
0
ファイル: tg_view.c プロジェクト: nathanhaigh/staden-trunk
static void test_mode2(GapIO *io, contig_t **c, int xpos) {
    rangec_t *r;
    int nr, i, bpv = 256;
    char cons[CONS_LEN+1];
    track_t *t;

    //    r = contig_seqs_in_range(io, c, xpos, xpos+CONS_LEN, &nr);
    //    qsort(r, nr, sizeof(*r), sort_range);
    //    calc_cons(io, r, nr, xpos, CONS_LEN, cons);
    //    printf("Cons=%.*s\n", CONS_LEN, cons);

    t = contig_get_track(io, c, xpos, xpos+CONS_LEN, TRACK_READ_DEPTH, bpv);
    for (i = 0; i < CONS_LEN/bpv; i++) {
        printf("%d\t%d\n", i*bpv, arr(int, t->data, i));
    }

    cache_flush(io);
    gio_close(io);
    exit(0);
}
コード例 #4
0
ファイル: tg_view.c プロジェクト: nathanhaigh/staden-trunk
static void benchmark(GapIO *io, contig_t **c) {
    int i;
    char cons[10000];

    srandom(0);
    fprintf(stderr, "=== Benchmarking ===\n");
    for (i = 0; i < 1000; i++) {
        int xpos = random() % 2000000;
        int size = random() % 1000;
        int nr;
        rangec_t *r;

        r = contig_seqs_in_range(io, c, xpos, xpos+size, 0, &nr);
        calc_cons(io, r, nr, xpos, size, cons);
        printf("%.*s\n", size, cons);
        fputc('.', stderr);
        fflush(stderr);
        free(r);
    }
    gio_close(io);
    exit(0);
}
コード例 #5
0
ファイル: tg_view.c プロジェクト: nathanhaigh/staden-trunk
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;
}