int index_main(SgrepData *sgrep,int argc, char *argv[]) { int end_options; IndexOptions options; FileList *file_list=NULL; set_default_index_options(sgrep,&options); /* * Get the command line options */ end_options=parse_index_options(&options,argv); if (end_options==SGREP_ERROR) { /* There was error. Display usage information */ index_usage(sgrep); goto error; } switch(options.index_mode) { case IM_CREATE: { if (argc==end_options && options.file_list_files==NULL) { sgrep_error(sgrep,"Can't read input from stdin when indexing.\n"); sgrep_error(sgrep," Use filename '-' to force indexing from stdin.\n"); goto error; } if (argc>end_options) { file_list=check_files(sgrep,argc-end_options,argv+end_options, 0,NULL); } options.file_list=file_list; if (create_index(&options)==SGREP_ERROR) { goto error; } break; } case IM_TERMS: { if (index_query(&options,argc-end_options,argv+end_options) ==SGREP_ERROR) { return 2; } else { return 0; } } case IM_DONE: return 0; case IM_NONE: default: sgrep_error(sgrep,"sgindex: You have to give one of -c, -C -h\n"); index_usage(sgrep); goto error; } if (file_list) delete_flist(file_list); if (options.file_list_files) delete_flist(options.file_list_files); return 0; error: if (file_list) delete_flist(file_list); if (options.file_list_files) delete_flist(options.file_list_files); return 2; }
int bam_index(int argc, char *argv[]) { int csi = 0; int min_shift = BAM_LIDX_SHIFT; int c; while ((c = getopt(argc, argv, "bcm:")) >= 0) switch (c) { case 'b': csi = 0; break; case 'c': csi = 1; break; case 'm': csi = 1; min_shift = atoi(optarg); break; default: index_usage(pysamerr); return 1; } if (optind == argc) { index_usage(stdout); return 1; } if (argc - optind > 1) bam_index_build2(argv[optind], argv[optind+1]); else bam_index_build(argv[optind], csi? min_shift : 0); return 0; }
int bam_index(int argc, char *argv[]) { int csi = 0; int min_shift = BAM_LIDX_SHIFT; int c, ret; while ((c = getopt(argc, argv, "bcm:")) >= 0) switch (c) { case 'b': csi = 0; break; case 'c': csi = 1; break; case 'm': csi = 1; min_shift = atoi(optarg); break; default: index_usage(stderr); return 1; } if (optind == argc) { index_usage(stdout); return 1; } ret = sam_index_build2(argv[optind], argv[optind+1], csi? min_shift : 0); if (ret != 0) { fprintf(stderr, "[%s] corrupted or unsorted input file\n", __func__); return EXIT_FAILURE; } return 0; }