// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright 2009 Illumina, Inc. // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). // // /// \file /// \author Chris Saunders /// #include #include #include #include #include #include static void open_ofstream(const prog_info& pinfo, const std::string& filename, const char* label, const bool is_clobber, std::ofstream& fos) { std::ifstream tis(filename.c_str()); if(tis and not is_clobber) { std::ostringstream oss; oss << label << " file already exists: " << filename; pinfo.usage(oss.str().c_str()); } fos.open(filename.c_str()); if(!fos) { std::ostringstream oss; oss << label << " file can't be opened: " << filename; pinfo.usage(oss.str().c_str()); } } static void write_audit(const blt_options& opt, const prog_info& pinfo, const char* const cmdline, std::ostream& os, const char* const prefix = 0){ if(opt.is_write_variable_metadata){ if(prefix) os << prefix; os << "CMDLINE " << cmdline << "\n"; } if(prefix) os << prefix; os << "PROGRAM_VERSION " << pinfo.version() << "\n"; if(opt.is_write_variable_metadata){ if(prefix) os << prefix; const time_t result(time(0)); os << "START_TIME " << asctime(localtime(&result)); } } static void write_file_audit(const blt_options& opt, const prog_info& pinfo, const char* const cmdline, std::ostream& os) { write_audit(opt,pinfo,cmdline,os,"#$ "); os << "#\n"; } static void setup_bsnp_file(const blt_options& client_opt, const prog_info& pinfo, const char* const cmdline, std::auto_ptr& apo, const std::string& filename, const char* label, const bool is_include_seq_name) { std::ofstream* fosptr(new std::ofstream); apo.reset(fosptr); std::ofstream& fos(*fosptr); open_ofstream(pinfo,filename,label,client_opt.is_clobber,fos); fos << "# ** " << pinfo.name() << " " << label << " file **\n"; write_file_audit(client_opt,pinfo,cmdline,fos); fos << "#$ SNP_THETA " << client_opt.bsnp_diploid_theta << "\n"; fos << "#\n"; fos << "#$ COLUMNS "; if(is_include_seq_name) { fos << "seq_name "; } fos << "pos bcalls_used bcalls_filt ref Q(snp) max_gt Q(max_gt) max_gt|poly_site Q(max_gt|poly_site)"; if(client_opt.is_print_used_allele_counts) { for(unsigned b(0);b