static void flanks_sam_open() { if(!futil_path_has_extension(sam_path, ".bam") && !futil_path_has_extension(sam_path, ".sam")) { cmd_print_usage("Mapped flanks is not .sam or .bam file: %s", sam_path); } bool isbam = futil_path_has_extension(sam_path, ".bam"); samfh = sam_open(sam_path, isbam ? "rb" : "rs"); if(samfh == NULL) die("Cannot open SAM/BAM %s", sam_path); // Load BAM header bam_header = sam_hdr_read(samfh); bamentry = bam_init1(); }
// reqtype: v=>vcf, z=>compressed vcf, b=>bcf, bu=>uncompressed bcf int vcf_misc_get_outtype(const char *reqtype, const char *path) { int mode = -1; if(reqtype) { const char *ot = reqtype; if(!strcmp(ot,"vcf") || !strcmp(ot,"uvcf") || !strcmp(ot,"v")) mode = 0; else if(!strcmp(ot,"vcfgz") || !strcmp(ot,"z")) mode = 1; else if(!strcmp(ot,"ubcf") || !strcmp(ot,"u")) mode = 2; else if(!strcmp(ot,"bcf") || !strcmp(ot,"b")) mode = 3; else die("Unkown output type: %s", ot); } else if(path) { if( futil_path_has_extension(path,".vcf")) mode = 0; else if(futil_path_has_extension(path,".vcfgz")) mode = 1; else if(futil_path_has_extension(path,".vcf.gz")) mode = 1; else if(futil_path_has_extension(path,".ubcf")) mode = 2; else if(futil_path_has_extension(path,".bcf")) mode = 3; } // default to uncompressed VCF return mode < 0 ? 0 : mode; }
// returns -1 if we cannot calc int64_t seq_est_seq_bases(seq_file_t **files, size_t nfiles) { size_t i; int64_t est_num_bases = 0; for(i = 0; i < nfiles; i++) { if(strcmp(files[i]->path,"-") != 0) { off_t fsize = futil_get_file_size(files[i]->path); if(fsize < 0) warn("Cannot get file size: %s", files[i]->path); else { if(seq_is_fastq(files[i]) || seq_is_sam(files[i])) fsize /= 2; if(futil_path_has_extension(files[i]->path,".gz")) fsize *= 4; est_num_bases += fsize; } } else return -1; } return est_num_bases; }