int main(int argc, char *argv[]) { try { if (argc == 1) usage(); Initial_Time(); std::cerr << "Start at: " << Curr_Time() << std::endl; int noptions = mGetOptions(argc, argv); #if defined (_OPENMP) if (param.ncpu) omp_set_num_threads(param.ncpu); #endif finDB.open(refseqFile.c_str()); if (!finDB) { std::cerr << "fatal error: failed to open ref file\n"; exit(1); } ref.Run_ConvertBinseq(finDB); std::cerr << "Load in " << ref.total_num << " reference seqs, total size " << ref.sum_length << " bp. " << Cal_AllTime() << " secs passed" << std::endl; ref.CreateIndex(); std::cerr << "Create refseq k-mer index table. " << Cal_AllTime() << " secs passed" << std::endl; RunProcess(); } catch (const std::exception & e) { std::cerr << e.what() << std::endl; return 1; } return 0; }
int HomoAndMicrosateDis(int argc, char *argv[]) { if (argc == 1) DisUsage(); for (int i=0; i<argc; i++) { std::cout <<argv[i]<<' '; } Initial_Time(); std::cout <<"Start at: "<<Curr_Time()<< std::endl; int noptions = dGetOptions(argc, argv); // process user defined region if (!one_region.empty()) { if (!polyscan.ParseOneRegion(one_region)) { std::cerr<<"fatal error: Please give correct defined region format (-r) \n"; exit(1); } polyscan.ifUserDefinedRegion = true; } else { polyscan.ifUserDefinedRegion = false; } // reading bed file if is exist finB.open(bedFile.c_str()); if (finB) { std::cout << "loading bed regions ..." << std::endl; polyscan.LoadBeds(finB); polyscan.BedFilterorNot(); } // check bam list file finM.open(bamListFile.c_str()); if (!finM) { std::cerr<<"fatal error: failed to open bam list file\n"; exit(1); } std::cout << "loading bam list ..." << std::endl; polyscan.LoadBams(finM); // check h**o/microsate file finH.open(homoFile.c_str()); if (!finH) { std::cerr<<"fatal error: failed to open homopolymer and microsatellites file\n"; exit(1); } std::cout << "loading homopolymer and microsatellite sites ..." << std::endl; polyscan.LoadHomosAndMicrosates(finH); finH.close(); //polyscan.TestHomos(); polyscan.SplitWindows(); //polyscan.TestWindows(); std::cout << "\nTotal loading windows: " << polyscan.totalWindowsNum << " \n\n"; std::cout << "\nTotal loading homopolymer and microsatellites: " << polyscan.totalHomosites << " \n\n"; // pour out distribution foutD.open( disFile.c_str() ); if (!foutD) { std::cerr <<"failed to open file: "<<disFile<< std::endl; exit(1); } polyscan.GetHomoDistribution(foutD); foutD.close(); std::cout << "\nTotal time consumed: " << Cal_AllTime() << " secs\n\n"; return 0; }
// Scan homosites and windows void RefSeq::ScanHomoAndMicrosate(std::ifstream &fin) { _seq.resize(param.max_dbseq_size); total_num = sum_length = 0; unsigned int index = 0; _count = 0; while (LoadNextSeq(fin)) { // filtering little reference sequences if (_length < 20 ) continue; RefTitle r; r._name =_name; r._size = _length; title.push_back(r); // scan window and homopolymer site DoScan(_length, _name, index); std::cout << "scanning chomosome " << _name << " done. " << Cal_AllTime() << " secs passed" << std::endl; index++; total_num++; sum_length += _length; } _seq.clear(); }
int HomoAndMicrosateDisMsi(int argc, char *argv[]) { if (argc == 1) DisUsage(); for (int i=0; i<argc; i++) { std::cout <<argv[i]<<' '; } Initial_Time(); std::cout <<"Start at: "<<Curr_Time() << std::endl; int noptions = dGetOptions(argc, argv); // process user defined region if (!one_region.empty()) { if (!polyscan.ParseOneRegion(one_region)) { std::cerr<<"fatal error: Please give correct defined region format (-r) \n"; exit(1); } polyscan.ifUserDefinedRegion = true; } else { polyscan.ifUserDefinedRegion = false; } // reading bed file if is exist finB.open(bedFile.c_str()); if (finB) { std::cout << "loading bed regions ..." << std::endl; polyscan.LoadBeds(finB); polyscan.BedFilterorNot(); } // load bam files //polyscan.LoadBams( normalBam, tumorBam ); if (!normalBam.empty() && !tumorBam.empty()) { polyscan.LoadBams( normalBam, tumorBam ); } // just for tumor only data if (normalBam.empty() && !tumorBam.empty()) { polyscan.LoadBam(tumorBam); } // check h**o/microsate file finH.open(homoFile.c_str()); if (!finH) { std::cerr<<"fatal error: failed to open homopolymer and microsatellites file\n"; exit(1); } std::cout << "loading homopolymer and microsatellite sites ..." << std::endl; polyscan.LoadHomosAndMicrosates(finH); finH.close(); //polyscan.TestHomos(); polyscan.SplitWindows(); //polyscan.TestWindows(); std::cout << "\nTotal loading windows: " << polyscan.totalWindowsNum << " \n\n"; std::cout << "\nTotal loading homopolymer and microsatellites: " << polyscan.totalHomosites << " \n\n"; // change code to one sample //polyscan.GetHomoDistribution(sample, disFile); // control distribution for tumor only input if (!normalBam.empty() && !tumorBam.empty()) { polyscan.GetHomoDistribution(sample, disFile); } if (normalBam.empty() && !tumorBam.empty()) { polyscan.GetHomoTumorDistribution(sample, disFile); } std::cout << "\nTotal time consumed: " << Cal_AllTime() << " secs\n\n"; return 0; }