CNIRRatio::CNIRRatio( std::shared_ptr< const CSeries > const& t_SolarRadiation, double const lowLambda, double const highLambda ) { auto integratedSolar = t_SolarRadiation->integrate( IntegrationType::Trapezoidal ); auto aSolarRange = CWavelengthRange( WavelengthRange::Solar ); auto totSolar = integratedSolar->sum( aSolarRange.minLambda(), aSolarRange.maxLambda() ); auto totVisible = integratedSolar->sum( lowLambda, highLambda ); m_Ratio = totVisible / totSolar; }
/** * Run multiple test. * * @param transaction_file The file includes associations between TFs and genes. * Each line indicates a gene. * If gene is targeted by the TF, then value is 1, otherwise 0. * @param flag_file Each line indicates a gene. The column1 is gene name. * If gene has the feature, the column2 is 1. The other case 0. * @param threshold The statistical significance threshold. * @param set_method The procedure name for calibration p-value (fisher/u_test/chi). * @param max_comb the maximal size which the largest combination size in tests set. * @param log_file File name for logging. * @param alternative hypothesis, 1 -> greater, 0 -> two sided, -1 -> less */ void LampCore::run(std::string& transaction_file, std::string& flag_file, double threshold, std::string& set_method, int max_comb, std::string& log_file, int alternative) { clean(); // read 2 files and get transaction list std::cerr << "Read input files ..."<< std::endl; try { readFile.readFiles(transaction_file, flag_file, ','); // If the alternative hypothesis is 'less', // the positive and negative of observe values are reversed, // and conduct the identical procedure to 'greater'. if (alternative < 0) reverseValue( readFile.getTransaction_list(), set_method ); if ((int)readFile.getColumnid2name().size() <= max_comb) max_comb = -1; } catch (std::string &msg) { throw msg; } catch (...) { throw std::string("Error: An unexpected error occurred while trying to read input files."); } // run multiple test std::string transaction4lcm53 = transaction_file + ".4lcm53"; // run try { FILE* fp_log = fopen(log_file.c_str(), "w"); if (fp_log == NULL) throw std::string("Can't open file : " + log_file); boost::iostreams::stream<boost::iostreams::file_descriptor_sink> outlog; #if (BOOST_VERSION >= 104900) outlog.open(fileno(fp_log), boost::iostreams::close_handle); #else outlog.open(fileno(fp_log), true); #endif starttime = std::chrono::high_resolution_clock::now(); std::cerr << "Compute the optimal correction factor ..."; double max_lambda = maxLambda(readFile.getTransaction_list()); fre_pattern = new LCM(max_lambda, fileno(fp_log)); lam_star = runMultTest(readFile.getTransaction_list(), transaction4lcm53, threshold, set_method, max_comb, outlog, alternative, max_lambda); correction_term_time = std::chrono::high_resolution_clock::now(); k = fre_pattern->getTotal( lam_star ); std::cerr << " " << k << std::endl; std::cerr << "Compute P-values of testable combinations ..." << std::endl; fwerControll(max_lambda, threshold, outlog); finish_test_time = std::chrono::high_resolution_clock::now(); outlog.close(); std::cerr << "Output results ..." << std::endl; // If the positives and negatives are reversed, the number of positives is calculated. if (( alternative < 0 ) && (std::find(BINARY_METHODS.begin(), BINARY_METHODS.end(), set_method) != BINARY_METHODS.end())) { for (enrich_t* l : enrich_lst) { l->stat_score = l->len - l->stat_score; } } } catch (std::string &msg) { throw msg; } catch (...) { throw std::string("Error: An unexpected error occurred while trying to test."); } }