int bcf_sr_set_targets(bcf_srs_t *readers, const char *targets, int is_file, int alleles) { assert( !readers->targets ); readers->targets = bcf_sr_regions_init(targets,is_file,0,1,-2); if ( !readers->targets ) return -1; readers->targets_als = alleles; return 0; }
int bcf_sr_set_regions(bcf_srs_t *readers, const char *regions, int is_file) { assert( !readers->regions ); if ( readers->nreaders ) { fprintf(stderr,"[%s:%d %s] Error: bcf_sr_set_regions() must be called before bcf_sr_add_reader()\n", __FILE__,__LINE__,__FUNCTION__); return -1; } readers->regions = bcf_sr_regions_init(regions,is_file,0,1,-2); if ( !readers->regions ) return -1; readers->explicit_regs = 1; readers->require_index = 1; return 0; }
int init(int argc, char **argv, bcf_hdr_t *in, bcf_hdr_t *out) { int c; char *fname = NULL; static struct option loptions[] = { {"exons",1,0,'e'}, {0,0,0,0} }; while ((c = getopt_long(argc, argv, "e:?h",loptions,NULL)) >= 0) { switch (c) { case 'e': fname = optarg; break; case 'h': case '?': default: fprintf(stderr,"%s", usage()); exit(1); break; } } if ( !fname ) { fprintf(stderr,"Missing the -e option.\n"); return -1; } in_hdr = in; out_hdr = out; int ret = bcf_hdr_append(out_hdr,"##INFO=<ID=OOF,Number=A,Type=Integer,Description=\"Frameshift Indels: out-of-frame (1), in-frame (0), not-applicable (-1 or missing)\">"); if ( ret!=0 ) { fprintf(stderr,"Error updating the header\n"); return -1; } exons = bcf_sr_regions_init(fname,1,0,1,2); if ( !exons ) { fprintf(stderr,"Error occurred while reading (was the file compressed with bgzip?): %s\n", fname); return -1; } return 0; }
int init(const char *opts, bcf_hdr_t *in, bcf_hdr_t *out) { in_hdr = in; out_hdr = out; int ret = bcf_hdr_append(out_hdr,"##INFO=<ID=OOF,Number=A,Type=Integer,Description=\"Frameshift Indels: out-of-frame (1), in-frame (0), not-applicable (-1 or missing)\">"); if ( ret!=0 ) { fprintf(stderr,"Error updating the header\n"); return -1; } char *fname = config_get_string(opts,"exons"); if ( !fname ) { fprintf(stderr,"No exons given, please run as \"bcftools annotate -p frameshifts:exons=path/to/file.tab.gz\".\n"); return -1; } wordexp_t wexp; wordexp(fname, &wexp, 0); if ( !wexp.we_wordc ) { fprintf(stderr,"No such file: %s\n", fname); return -1; } free(fname); fname = wexp.we_wordv[0]; exons = bcf_sr_regions_init(fname,1,0,1,2); if ( !exons ) { fprintf(stderr,"Error occurred while reading (was the file compressed with bgzip?): %s\n", fname); return -1; } wordfree(&wexp); return 0; }