本文整理汇总了C++中FileManager::get_spectra_counts方法的典型用法代码示例。如果您正苦于以下问题:C++ FileManager::get_spectra_counts方法的具体用法?C++ FileManager::get_spectra_counts怎么用?C++ FileManager::get_spectra_counts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::get_spectra_counts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: train_pmc_rank_models
/******************************************************************************
Train PMC models from positive example files
*******************************************************************************/
void PMCSQS_Scorer::train_pmc_rank_models(Config *config, const FileManager& fm,
int sel_charge, bool overwrite)
{
const bool sample_diagnostic = false;
const vector<int>& spectra_counts = fm.get_spectra_counts();
max_model_charge=0;
int charge;
for (charge=1; charge<spectra_counts.size(); charge++)
{
if (spectra_counts[charge]>=MIN_SPECTRA_FOR_PMCSQS_MODEL)
max_model_charge=charge;
}
const int max_to_read_per_file = 40000;
vector<string> real_names;
init_PMC_feature_names(real_names);
// try and read existing pmc model, otherwise init a new one
string pmc_path = config->get_resource_dir() + "/" + config->get_model_name() + "_PMCR.txt";
ifstream model_stream(pmc_path.c_str());
if (model_stream.is_open() && model_stream.good())
{
model_stream.close();
string pmcr_name = config->get_model_name() + "_PMCR.txt";
const char *path = pmc_path.c_str();
this->read_pmc_rank_models(config,(char *)pmcr_name.c_str());
}
else
{
set_pmc_mass_thresholds();
this->set_frag_pair_sum_offset(MASS_PROTON); // b+y - PM+19
this->set_bin_increment(0.1);
pmc_rank_models.resize(pmc_rank_mass_thresholds.size());
pmc_charge_mz_biases.resize(pmc_rank_mass_thresholds.size());
}
const double prop_train = 0.5;
// It is assumed that the mass thresholds were set according to the training data
// (this is done manually with values encoded in the set_mass_threhsolds function)
for (charge=1; charge<=max_model_charge; charge++)
{
if (sel_charge>0 && charge != sel_charge)
continue;
const int num_sizes = pmc_rank_mass_thresholds[charge].size();
pmc_rank_models[charge].resize(num_sizes+1,NULL);
pmc_charge_mz_biases[charge].resize(num_sizes+1,0);
int size_idx;
for (size_idx=0; size_idx<=num_sizes; size_idx++)
{
if (pmc_rank_models[charge][size_idx] && ! overwrite)
continue;
vector<SingleSpectrumFile *> test_ssfs;
BasicSpecReader bsr;
static QCPeak peaks[5000];
RankBoostDataset train_ds, test_ds, pos_ds, neg_ds;
mass_t min_mass =0;
mass_t max_mass = POS_INF;
if (size_idx>0)
min_mass = pmc_rank_mass_thresholds[charge][size_idx-1];
if (size_idx<num_sizes)
max_mass = pmc_rank_mass_thresholds[charge][size_idx];
// these ranges are given according to pm_with_19
// so files should be selected through select_files and not
// select_file_in_mz_range
FileSet fs;
fs.select_files(fm,min_mass,max_mass,-1,-1,charge);
if (fs.get_total_spectra()<500)
continue;
int num_groups_in_train=0;
int num_groups_in_test=0;
cout << "TRAINING charge " << charge << " size " << size_idx << " (" <<
min_mass << "-" << max_mass << ")" << endl;
fs.randomly_reduce_ssfs(max_to_read_per_file);
const vector<SingleSpectrumFile *>& all_ssf = fs.get_ssf_pointers();
const int num_samples = all_ssf.size();
// first find the bias in number of bins between the true m/z bin and
//.........这里部分代码省略.........
示例2: train_sqs_models
void PMCSQS_Scorer::train_sqs_models(Config *config,
const FileManager& fm_pos,
const char *neg_list,
int specificCharge,
vector<vector<float> > *inputWeights)
{
vector< vector< vector<ME_Regression_Sample> > > samples; // neg, p1, p2, p3 / sizeIndex
FileManager fm_neg;
const vector<int>& spectra_counts = fm_pos.get_spectra_counts();
maximalChargeWithModels_ = (inputWeights ? inputWeights->size()-1 : 3);
int charge;
set_frag_pair_sum_offset(MASS_PROTON); // b+y - PM+19
set_bin_increment(0.1);
this->set_sqs_mass_thresholds();
if (this->pmcMassThresholds_.size() == 0)
{
pmcMassThresholds_=config->get_size_thresholds();
}
vector<vector<float> > classWeights;
if (inputWeights)
{
classWeights = *inputWeights;
}
else
{
classWeights.resize(maximalChargeWithModels_+1);
int i;
for (i=0; i<classWeights.size(); i++)
classWeights[i].resize(maximalChargeWithModels_+1,1.0);
}
const int numSizes = this->sqsMassThresholds_.size();
cout << "NUM SIZE MODELS: " << numSizes+1 << endl;
samples.resize(maximalChargeWithModels_+1);
fm_neg.init_from_list_file(config, neg_list);
const int max_to_read_per_file = 8000;
for (charge=0; charge<=maximalChargeWithModels_; charge++)
{
if (charge>0 && specificCharge>0 && charge != specificCharge)
continue;
int sizeIndex;
for (sizeIndex=0; sizeIndex<=numSizes; sizeIndex++)
{
const mass_t minMass = (sizeIndex == 0 ? 0 : sqsMassThresholds_[sizeIndex-1]);
const mass_t maxMass = (sizeIndex == numSizes ? POS_INF : sqsMassThresholds_[sizeIndex]);
samples[charge].resize(numSizes+1);
BasicSpecReader bsr;
QCPeak peaks[5000];
FileSet fs;
if (charge == 0)
{
fs.select_files_in_mz_range(fm_neg,minMass, maxMass,0);
}
else
{
fs.select_files_in_mz_range(fm_pos, minMass, maxMass, charge);
}
cout << "Found " << fs.get_total_spectra() << " for charge " << charge << " ranges:" <<
minMass << " - " << maxMass << endl;
fs.randomly_reduce_ssfs(max_to_read_per_file);
const vector<SingleSpectrumFile *>& all_ssf = fs.get_ssf_pointers();
const int label = (charge == 0 ? 1 : 0);
const int num_samples = all_ssf.size();
samples[charge][sizeIndex].resize(num_samples);
int i;
for (i=0; i<num_samples; i++)
{
SingleSpectrumFile* ssf = all_ssf[i];
BasicSpectrum bs;
bs.peaks = peaks;
bs.ssf = ssf;
if (charge==0)
{
bs.num_peaks = bsr.read_basic_spec(config,fm_neg,ssf,peaks);
bs.ssf->charge=0;
}
else
bs.num_peaks = bsr.read_basic_spec(config,fm_pos,ssf,peaks);
init_for_current_spec(config,bs);
calculate_curr_spec_pmc_values(bs, bin_increment);
//.........这里部分代码省略.........