int main_polysomy(int argc, char *argv[]) { args_t *args = (args_t*) calloc(1,sizeof(args_t)); args->argc = argc; args->argv = argv; args->nbins = 150; args->fit_th = 3.3; args->cn_penalty = 0.7; args->peak_symmetry = 0.5; args->min_peak_size = 0.1; args->ra_rr_scaling = 1; args->min_fraction = 0.1; args->smooth = -3; static struct option loptions[] = { {"ra-rr-scaling",0,0,1}, // hidden option {"force-cn",1,0,2}, // hidden option {"smooth",1,0,'S'}, // hidden option {"nbins",1,0,'n'}, // hidden option {"include-aa",0,0,'i'}, {"peak-size",1,0,'b'}, {"min-fraction",1,0,'m'}, {"verbose",0,0,'v'}, {"fit-th",1,0,'f'}, {"cn-penalty",1,0,'c'}, {"peak-symmetry",1,0,'p'}, {"output-dir",1,0,'o'}, {"sample",1,0,'s'}, {"targets",1,0,'t'}, {"targets-file",1,0,'T'}, {"regions",1,0,'r'}, {"regions-file",1,0,'R'}, {0,0,0,0} }; char *tmp; int c; while ((c = getopt_long(argc, argv, "h?o:vt:T:r:R:s:f:p:c:im:b:n:S:",loptions,NULL)) >= 0) { switch (c) { case 1 : args->ra_rr_scaling = 0; break; case 2 : args->force_cn = atoi(optarg); break; case 'n': args->nbins = atoi(optarg); break; case 'S': args->smooth = atoi(optarg); break; case 'i': args->include_aa = 1; break; case 'b': args->min_peak_size = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -b %s\n", optarg); if ( args->min_peak_size<0 || args->min_peak_size>1 ) error("Range error: -b %s\n", optarg); break; case 'm': args->min_fraction = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -n %s\n", optarg); if ( args->min_fraction<0 || args->min_fraction>1 ) error("Range error: -n %s\n", optarg); break; case 'f': args->fit_th = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -f %s\n", optarg); break; case 'p': args->peak_symmetry = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -p %s\n", optarg); break; case 'c': args->cn_penalty = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -c %s\n", optarg); break; case 's': args->sample = optarg; break; case 't': args->targets_list = optarg; break; case 'T': args->targets_list = optarg; args->targets_is_file = 1; break; case 'r': args->regions_list = optarg; break; case 'R': args->regions_list = optarg; args->regions_is_file = 1; break; case 'o': args->output_dir = optarg; break; case 'v': args->verbose++; break; default: usage(args); break; } } if ( optind>=argc ) { if ( !isatty(fileno((FILE *)stdin)) ) args->fname = "-"; } else args->fname = argv[optind]; if ( !args->fname ) usage(args); if ( !args->output_dir ) error("Missing the -o option\n"); init_data(args); fit_curves(args); destroy_data(args); free(args); return 0; }
int main_polysomy(int argc, char *argv[]) { args_t *args = (args_t*) calloc(1,sizeof(args_t)); args->argc = argc; args->argv = argv; args->nbins = 150; args->fit_th = 3.0; args->cn_penalty = 0.7; args->peak_symmetry = 0.7; static struct option loptions[] = { {"verbose",0,0,'v'}, {"fit-th",1,0,'f'}, {"cn-penalty",1,0,'c'}, {"peak-symmetry",1,0,'p'}, {"output-dir",1,0,'o'}, {"sample",1,0,'s'}, {"targets",1,0,'t'}, {"targets-file",1,0,'T'}, {"regions",1,0,'r'}, {"regions-file",1,0,'R'}, {0,0,0,0} }; char c, *tmp; while ((c = getopt_long(argc, argv, "h?o:vt:T:r:R:s:f:p:c:",loptions,NULL)) >= 0) { switch (c) { case 'f': args->fit_th = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -f %s\n", optarg); break; case 'p': args->peak_symmetry = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -p %s\n", optarg); break; case 'c': args->cn_penalty = strtod(optarg,&tmp); if ( *tmp ) error("Could not parse: -c %s\n", optarg); break; case 's': args->sample = optarg; break; case 't': args->targets_list = optarg; break; case 'T': args->targets_list = optarg; args->targets_is_file = 1; break; case 'r': args->regions_list = optarg; break; case 'R': args->regions_list = optarg; args->regions_is_file = 1; break; case 'o': args->output_dir = optarg; break; case 'v': args->verbose = 1; break; default: usage(args); break; } } if ( optind>=argc ) { if ( !isatty(fileno((FILE *)stdin)) ) args->fname = "-"; } else args->fname = argv[optind]; if ( !args->fname ) usage(args); if ( !args->output_dir ) error("Missing the -o option\n"); init_data(args); fit_curves(args); destroy_data(args); free(args); return 0; }