Exemple #1
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;
}
Exemple #2
0
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;
}