本文整理汇总了C++中MzMLFile::setLogType方法的典型用法代码示例。如果您正苦于以下问题:C++ MzMLFile::setLogType方法的具体用法?C++ MzMLFile::setLogType怎么用?C++ MzMLFile::setLogType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MzMLFile
的用法示例。
在下文中一共展示了MzMLFile::setLogType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_
ExitCodes main_(int, const char **)
{
String in = getStringOption_("in");
String out = getStringOption_("out");
String tr_file = getStringOption_("tr");
bool force = getFlag_("force");
boost::shared_ptr<PeakMap > exp ( new PeakMap );
MzMLFile mzmlfile;
mzmlfile.setLogType(log_type_);
mzmlfile.load(in, *exp);
TargetedExpType transition_exp;
TraMLFile().load(tr_file, transition_exp);
FeatureMap output;
OpenSwath::SpectrumAccessPtr input = SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(exp);
run_(input, output, transition_exp, force);
output.ensureUniqueId();
StringList ms_runs;
exp->getPrimaryMSRunPath(ms_runs);
output.setPrimaryMSRunPath(ms_runs);
FeatureXMLFile().store(out, output);
return EXECUTION_OK;
}
示例2: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//varaibles
String db, user, password, host, in;
Int port;
bool init = getFlag_("init");
if (!init)
{
in = getStringOption_("in");
}
db = getStringOption_("db");
user = getStringOption_("user");
password = getStringOption_("password");
host = getStringOption_("host");
port = getIntOption_("port");
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
DBConnection con;
con.connect(db, user, password, host, port);
DBAdapter a(con);
if (init)
{
a.createDB();
}
else
{
//load input file data
MSExperiment<Peak1D> exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//annotate output with data processing info
addDataProcessing_(exp, getProcessingInfo_(DataProcessing::FORMAT_CONVERSION));
//store data
a.storeExperiment(exp);
writeLog_(String(" written file to DB (id: ") + (double)(exp.getPersistenceId()) + ")");
}
return EXECUTION_OK;
}
示例3: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
String in(getStringOption_("in"));
String out(getStringOption_("out"));
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
MSExperiment<> exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//-------------------------------------------------------------
// if meta data arrays are present, remove them and warn
//-------------------------------------------------------------
if (exp.clearMetaDataArrays())
{
writeLog_("Warning: Spectrum meta data arrays cannot be sorted. They are deleted.");
}
//-------------------------------------------------------------
// filter
//-------------------------------------------------------------
Param filter_param = getParam_().copy("algorithm:", true);
writeDebug_("Used filter parameters", filter_param, 3);
BernNorm filter;
filter.setParameters(filter_param);
filter.filterPeakMap(exp);
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
//annotate output with data processing info
addDataProcessing_(exp, getProcessingInfo_(DataProcessing::FILTERING));
f.store(out, exp);
return EXECUTION_OK;
}
示例4: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
String in(getStringOption_("in"));
String out(getStringOption_("out"));
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
MSExperiment<> exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//-------------------------------------------------------------
// filter
//-------------------------------------------------------------
Param filter_param = getParam_().copy("algorithm:", true);
writeDebug_("Used filter parameters", filter_param, 3);
Normalizer filter;
filter.setParameters(filter_param);
filter.filterPeakMap(exp);
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
//annotate output with data processing info
addDataProcessing_(exp, getProcessingInfo_(DataProcessing::FILTERING));
f.store(out, exp);
return EXECUTION_OK;
}
示例5: main_
ExitCodes main_(int, const char **)
{
//----------------------------------------------------------------
// load data
//----------------------------------------------------------------
String in = getStringOption_("in");
String out = getStringOption_("out");
MSExperiment<> exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
DoubleReal sampling_rate = getDoubleOption_("sampling_rate");
LinearResampler lin_resampler;
Param resampler_param;
resampler_param.setValue("spacing", sampling_rate);
lin_resampler.setParameters(resampler_param);
// resample every scan
for (Size i = 0; i < exp.size(); ++i)
{
lin_resampler.raster(exp[i]);
}
//clear meta data because they are no longer meaningful
exp.clearMetaDataArrays();
//annotate output with data processing info
addDataProcessing_(exp,
getProcessingInfo_(DataProcessing::DATA_PROCESSING));
//store output
f.store(out, exp);
return EXECUTION_OK;
}
示例6: main_
ExitCodes main_(int , const char**) override
{
String in = getStringOption_("in");
String out = getStringOption_("out");
MapType exp;
MapType out_exp;
Param picker_param = getParam_().copy("algorithm:", true);
MzMLFile f;
f.setLogType(log_type_);
f.load(in,exp);
PeakPickerIterative pp;
pp.setParameters(picker_param);
pp.setLogType(log_type_);
pp.pickExperiment(exp, out_exp);
addDataProcessing_(out_exp, getProcessingInfo_(DataProcessing::PEAK_PICKING));
f.store(out,out_exp);
return EXECUTION_OK;
}
示例7: main_
ExitCodes main_(int, const char **)
{
// data to be passed through the algorithm
vector<vector<SILACPattern> > data;
MSQuantifications msq;
vector<Clustering *> cluster_data;
//
// Parameter handling
//
map<String, DoubleReal> label_identifiers; // list defining the mass shifts of each label (e.g. "Arg6" => 6.0201290268)
handleParameters_sample();
handleParameters_algorithm();
handleParameters_labels(label_identifiers);
handleParameters();
if (selected_labels.empty() && !out.empty()) // incompatible parameters
{
writeLog_("Error: The 'out' parameter cannot be used without a label (parameter 'sample:labels'). Use 'out_features' instead.");
return ILLEGAL_PARAMETERS;
}
//
// Initializing the SILACAnalzer with our parameters
//
SILACAnalyzer analyzer;
analyzer.setLogType(log_type_);
analyzer.initialize(
// section "sample"
selected_labels,
charge_min,
charge_max,
missed_cleavages,
isotopes_per_peptide_min,
isotopes_per_peptide_max,
// section "algorithm"
rt_threshold,
rt_min,
intensity_cutoff,
intensity_correlation,
model_deviation,
allow_missing_peaks,
// labels
label_identifiers);
//--------------------------------------------------
// loading input from .mzML
//--------------------------------------------------
MzMLFile file;
MSExperiment<Peak1D> exp;
// only read MS1 spectra ...
/*
std::vector<int> levels;
levels.push_back(1);
file.getOptions().setMSLevels(levels);
*/
LOG_DEBUG << "Loading input..." << endl;
file.setLogType(log_type_);
file.load(in, exp);
// set size of input map
exp.updateRanges();
// extract level 1 spectra
exp.getSpectra().erase(remove_if(exp.begin(), exp.end(), InMSLevelRange<MSExperiment<Peak1D>::SpectrumType>(IntList::create("1"), true)), exp.end());
// sort according to RT and MZ
exp.sortSpectra();
if (out_mzq != "")
{
vector<vector<String> > SILAClabels = analyzer.getSILAClabels(); // list of SILAC labels, e.g. selected_labels="[Lys4,Arg6][Lys8,Arg10]" => SILAClabels[0][1]="Arg6"
std::vector<std::vector<std::pair<String, DoubleReal> > > labels;
//add none label
labels.push_back(std::vector<std::pair<String, DoubleReal> >(1, std::make_pair<String, DoubleReal>(String("none"), DoubleReal(0))));
for (Size i = 0; i < SILAClabels.size(); ++i) //SILACLabels MUST be in weight order!!!
{
std::vector<std::pair<String, DoubleReal> > one_label;
for (UInt j = 0; j < SILAClabels[i].size(); ++j)
{
one_label.push_back(*(label_identifiers.find(SILAClabels[i][j]))); // this dereferencing would break if all SILAClabels would not have been checked before!
}
labels.push_back(one_label);
}
msq.registerExperiment(exp, labels); //add assays
msq.assignUIDs();
}
MSQuantifications::QUANT_TYPES quant_type = MSQuantifications::MS1LABEL;
msq.setAnalysisSummaryQuantType(quant_type); //add analysis_summary_
//--------------------------------------------------
// estimate peak width
//--------------------------------------------------
LOG_DEBUG << "Estimating peak width..." << endl;
PeakWidthEstimator::Result peak_width;
//.........这里部分代码省略.........
示例8: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
String in(getStringOption_("in"));
String out(getStringOption_("out"));
Size num_spots_per_row(getIntOption_("num_spots_per_row"));
double RT_distance(getDoubleOption_("RT_distance"));
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
PeakMap exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
ProgressLogger pl;
pl.setLogType(log_type_);
pl.startProgress(0, exp.size(), "Assigning pseudo RTs.");
Size num_ms1(0), num_ms1_base(0), row_counter(0);
bool row_to_reverse(false);
double actual_RT(0);
for (Size i = 0; i != exp.size(); ++i)
{
pl.setProgress(i);
if (row_to_reverse)
{
actual_RT = (double)(num_ms1_base + (num_spots_per_row - row_counter)) * RT_distance;
writeDebug_("RT=" + String(actual_RT) + " (modified, row_counter=" + String(row_counter) + ")", 1);
}
else
{
actual_RT = (double)num_ms1 * RT_distance;
writeDebug_("RT=" + String(actual_RT), 1);
}
exp[i].setRT(actual_RT);
if (exp[i].getMSLevel() == 1)
{
if (++row_counter >= num_spots_per_row)
{
row_counter = 0;
if (row_to_reverse)
{
row_to_reverse = false;
}
else
{
row_to_reverse = true;
}
}
++num_ms1;
if (!row_to_reverse)
{
num_ms1_base = num_ms1;
}
}
}
pl.endProgress();
// sort the spectra according to their new RT
exp.sortSpectra();
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
f.store(out, exp);
return EXECUTION_OK;
}
示例9: main_
//.........这里部分代码省略.........
traml.load(tr_file, targeted_exp);
std::cout << "Loaded TraML file" << std::endl;
// Do parallelization over the different input files
// Only in OpenMP 3.0 are unsigned loop variables allowed
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (SignedSize i = 0; i < boost::numeric_cast<SignedSize>(file_list.size()); ++i)
{
boost::shared_ptr<PeakMap > exp(new PeakMap);
MzMLFile f;
// Logging and output to the console
// IF_MASTERTHREAD f.setLogType(log_type_);
// Find the transitions to extract and extract them
MapType tmp_out;
OpenMS::TargetedExperiment transition_exp_used;
f.load(file_list[i], *exp);
if (exp->empty() ) { continue; } // if empty, go on
OpenSwath::SpectrumAccessPtr expptr = SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(exp);
bool do_continue = true;
if (is_swath)
{
do_continue = OpenSwathHelper::checkSwathMapAndSelectTransitions(*exp, targeted_exp, transition_exp_used, min_upper_edge_dist);
}
else
{
transition_exp_used = targeted_exp;
}
#ifdef _OPENMP
#pragma omp critical (OpenSwathChromatogramExtractor_metadata)
#endif
// after loading the first file, copy the meta data from that experiment
// this may happen *after* chromatograms were already added to the
// output, thus we do NOT fill the experiment here but rather store all
// the chromatograms in the "chromatograms" array and store them in
// out_exp afterwards.
if (i == 0)
{
out_exp = *exp;
out_exp.clear(false);
}
std::cout << "Extracting " << transition_exp_used.getTransitions().size() << " transitions" << std::endl;
std::vector< OpenSwath::ChromatogramPtr > chromatogram_ptrs;
std::vector< ChromatogramExtractor::ExtractionCoordinates > coordinates;
// continue if the map is not empty
if (do_continue)
{
// Prepare the coordinates (with or without rt extraction) and then extract the chromatograms
ChromatogramExtractor extractor;
if (rt_extraction_window < 0)
{
extractor.prepare_coordinates(chromatogram_ptrs, coordinates, transition_exp_used, rt_extraction_window, extract_MS1);
}
else
{
// Use an rt extraction window of 0.0 which will just write the retention time in start / end positions
extractor.prepare_coordinates(chromatogram_ptrs, coordinates, transition_exp_used, 0.0, extract_MS1);
for (std::vector< ChromatogramExtractor::ExtractionCoordinates >::iterator it = coordinates.begin(); it != coordinates.end(); ++it)
{
it->rt_start = trafo_inverse.apply(it->rt_start) - rt_extraction_window / 2.0;
it->rt_end = trafo_inverse.apply(it->rt_end) + rt_extraction_window / 2.0;
}
}
extractor.extractChromatograms(expptr, chromatogram_ptrs, coordinates,
mz_extraction_window, ppm, extraction_function);
#ifdef _OPENMP
#pragma omp critical (OpenSwathChromatogramExtractor_insertMS1)
#endif
{
// Remove potential meta value indicating cached data
SpectrumSettings exp_settings = (*exp)[0];
for (Size j = 0; j < exp_settings.getDataProcessing().size(); j++)
{
if (exp_settings.getDataProcessing()[j]->metaValueExists("cached_data"))
{ exp_settings.getDataProcessing()[j]->removeMetaValue("cached_data"); }
}
extractor.return_chromatogram(chromatogram_ptrs, coordinates, transition_exp_used, exp_settings, chromatograms, extract_MS1);
}
} // end of do_continue
} // end of loop over all files / end of OpenMP
// TODO check that no chromatogram IDs occur multiple times !
// store the output
out_exp.setChromatograms(chromatograms);
MzMLFile mzf;
mzf.setLogType(log_type_);
addDataProcessing_(out_exp, getProcessingInfo_(DataProcessing::SMOOTHING));
mzf.store(out, out_exp);
return EXECUTION_OK;
}
示例10: main_
ExitCodes main_(int, const char**)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
StringList in_spec = getStringList_("in");
StringList out = getStringList_("out");
String in_lib = getStringOption_("lib");
String compare_function = getStringOption_("compare_function");
Int precursor_mass_multiplier = getIntOption_("round_precursor_to_integer");
float precursor_mass_tolerance = getDoubleOption_("precursor_mass_tolerance");
//Int min_precursor_charge = getIntOption_("min_precursor_charge");
//Int max_precursor_charge = getIntOption_("max_precursor_charge");
float remove_peaks_below_threshold = getDoubleOption_("filter:remove_peaks_below_threshold");
UInt min_peaks = getIntOption_("filter:min_peaks");
UInt max_peaks = getIntOption_("filter:max_peaks");
Int cut_peaks_below = getIntOption_("filter:cut_peaks_below");
StringList fixed_modifications = getStringList_("fixed_modifications");
StringList variable_modifications = getStringList_("variable_modifications");
Int top_hits = getIntOption_("top_hits");
if (top_hits < -1)
{
writeLog_("top_hits (should be >= -1 )");
return ILLEGAL_PARAMETERS;
}
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
if (out.size() != in_spec.size())
{
writeLog_("out (should be as many as input files)");
return ILLEGAL_PARAMETERS;
}
time_t prog_time = time(NULL);
MSPFile spectral_library;
RichPeakMap query, library;
//spectrum which will be identified
MzMLFile spectra;
spectra.setLogType(log_type_);
time_t start_build_time = time(NULL);
//-------------------------------------------------------------
//building map for faster search
//-------------------------------------------------------------
//library containing already identified peptide spectra
vector<PeptideIdentification> ids;
spectral_library.load(in_lib, ids, library);
map<Size, vector<PeakSpectrum> > MSLibrary;
{
RichPeakMap::iterator s;
vector<PeptideIdentification>::iterator i;
ModificationsDB* mdb = ModificationsDB::getInstance();
for (s = library.begin(), i = ids.begin(); s < library.end(); ++s, ++i)
{
double precursor_MZ = (*s).getPrecursors()[0].getMZ();
Size MZ_multi = (Size)precursor_MZ * precursor_mass_multiplier;
map<Size, vector<PeakSpectrum> >::iterator found;
found = MSLibrary.find(MZ_multi);
PeakSpectrum librar;
bool variable_modifications_ok = true;
bool fixed_modifications_ok = true;
const AASequence& aaseq = i->getHits()[0].getSequence();
//variable fixed modifications
if (!fixed_modifications.empty())
{
for (Size i = 0; i < aaseq.size(); ++i)
{
const Residue& mod = aaseq.getResidue(i);
for (Size s = 0; s < fixed_modifications.size(); ++s)
{
if (mod.getOneLetterCode() == mdb->getModification(fixed_modifications[s]).getOrigin() && fixed_modifications[s] != mod.getModification())
{
fixed_modifications_ok = false;
break;
}
}
}
}
//variable modifications
if (aaseq.isModified() && (!variable_modifications.empty()))
{
for (Size i = 0; i < aaseq.size(); ++i)
{
if (aaseq.isModified(i))
{
const Residue& mod = aaseq.getResidue(i);
for (Size s = 0; s < variable_modifications.size(); ++s)
{
if (mod.getOneLetterCode() == mdb->getModification(variable_modifications[s]).getOrigin() && variable_modifications[s] != mod.getModification())
{
variable_modifications_ok = false;
break;
}
}
}
//.........这里部分代码省略.........
示例11: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
String in = getStringOption_("in");
String out = getStringOption_("out");
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
MzMLFile mzMLFile;
mzMLFile.setLogType(log_type_);
MSExperiment<Peak1D> input;
mzMLFile.getOptions().addMSLevel(1);
mzMLFile.load(in, input);
if (input.empty())
{
LOG_WARN << "The given file does not contain any conventional peak data, but might"
" contain chromatograms. This tool currently cannot handle them, sorry.";
return INCOMPATIBLE_INPUT_DATA;
}
//check if spectra are sorted
for (Size i = 0; i < input.size(); ++i)
{
if (!input[i].isSorted())
{
writeLog_("Error: Not all spectra are sorted according to peak m/z positions. Use FileFilter to sort the input!");
return INCOMPATIBLE_INPUT_DATA;
}
}
//-------------------------------------------------------------
// pick
//-------------------------------------------------------------
FeatureMap<> output;
FeatureFinder ff;
Param param = getParam_().copy("algorithm:", true);
FFSH ffsh;
ffsh.setParameters(param);
ffsh.setData(input, output, ff);
ffsh.run();
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
//annotate output with data processing info
addDataProcessing_(output, getProcessingInfo_(DataProcessing::PEAK_PICKING));
addDataProcessing_(output, getProcessingInfo_(DataProcessing::QUANTITATION));
output.ensureUniqueId();
for (Size i = 0; i < output.size(); i++)
{
output[i].ensureUniqueId();
}
FeatureXMLFile().store(out, output);
return EXECUTION_OK;
}
示例12: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
String in(getStringOption_("in"));
String out(getStringOption_("out"));
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
RichPeakMap exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
writeDebug_("Data set contains " + String(exp.size()) + " spectra", 1);
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
writeDebug_("Reading model file", 2);
// create model an set the given options
PILISModel * model = new PILISModel();
model->readFromFile(getStringOption_("model_file"));
Param model_param(model->getParameters());
model_param.setValue("upper_mz", getDoubleOption_("model:upper_mz"));
model_param.setValue("lower_mz", getDoubleOption_("model:lower_mz"));
model_param.setValue("charge_directed_threshold", getDoubleOption_("model:charge_directed_threshold"));
model_param.setValue("charge_remote_threshold", getDoubleOption_("model:charge_remote_threshold"));
//model_param.setValue("min_main_ion_intensity", getDoubleOption_("model:min_main_ion_intensity"));
//model_param.setValue("min_loss_ion_intensity", getDoubleOption_("model:min_loss_ion_intensity"));
model_param.setValue("min_y_ion_intensity", getDoubleOption_("model:min_y_ion_intensity"));
model_param.setValue("min_b_ion_intensity", getDoubleOption_("model:min_b_ion_intensity"));
model_param.setValue("min_a_ion_intensity", getDoubleOption_("model:min_a_ion_intensity"));
model_param.setValue("min_y_loss_intensity", getDoubleOption_("model:min_y_loss_intensity"));
model_param.setValue("min_b_loss_intensity", getDoubleOption_("model:min_b_loss_intensity"));
model_param.setValue("charge_loss_factor", getDoubleOption_("model:charge_loss_factor"));
model_param.setValue("visible_model_depth", getIntOption_("model:visible_model_depth"));
model_param.setValue("model_depth", getIntOption_("model:model_depth"));
model_param.setValue("fixed_modifications", getStringOption_("fixed_modifications"));
model->setParameters(model_param);
writeDebug_("Reading sequence db", 2);
// create sequence db
SuffixArrayPeptideFinder * sapf = new SuffixArrayPeptideFinder(getStringOption_("peptide_db_file"), "trypticCompressed");
sapf->setTolerance(getDoubleOption_("precursor_mass_tolerance"));
sapf->setNumberOfModifications(0);
sapf->setUseTags(false);
//exp.resize(50); // TODO
UInt max_charge(3), min_charge(1); // TODO
vector<double> pre_weights;
for (RichPeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
{
double pre_weight(it->getPrecursors()[0].getMZ());
for (Size z = min_charge; z <= max_charge; ++z)
{
pre_weights.push_back((pre_weight * (double)z) - (double)z);
}
}
sort(pre_weights.begin(), pre_weights.end());
cerr << "Getting candidates from SA...";
vector<vector<pair<pair<String, String>, String> > > candidates;
sapf->getCandidates(candidates, pre_weights);
cerr << "done" << endl;
delete sapf;
map<double, vector<pair<pair<String, String>, String> > > sorted_candidates;
UInt count(0);
for (Size count = 0; count != candidates.size(); ++count)
{
sorted_candidates[pre_weights[count]] = candidates[count];
}
candidates.clear();
// create ProteinIdentification and set the options
PILISIdentification PILIS_id;
PILIS_id.setModel(model);
Param id_param(PILIS_id.getParameters());
id_param.setValue("precursor_mass_tolerance", getDoubleOption_("precursor_mass_tolerance"));
id_param.setValue("max_candidates", getIntOption_("max_pre_candidates"));
// disable evalue scoring, this is done separately to allow for a single id per spectrum
id_param.setValue("use_evalue_scoring", 0);
id_param.setValue("fixed_modifications", getStringOption_("fixed_modifications"));
PILIS_id.setParameters(id_param);
vector<PeptideIdentification> ids;
//.........这里部分代码省略.........
示例13: main_
ExitCodes main_(int, const char**)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
String in(getStringOption_("in"));
String id(getStringOption_("id"));
String out(getStringOption_("out"));
double fragment_mass_tolerance(getDoubleOption_("fragment_mass_tolerance"));
bool fragment_mass_unit_ppm = getStringOption_("fragment_mass_unit") == "Da" ? false : true;
Size max_peptide_len = getIntOption_("max_peptide_length");
Size max_num_perm = getIntOption_("max_num_perm");
AScore ascore;
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
vector<PeptideIdentification> pep_ids;
vector<ProteinIdentification> prot_ids;
vector<PeptideIdentification> pep_out;
IdXMLFile().load(id, prot_ids, pep_ids);
MSExperiment<> exp;
MzMLFile f;
f.setLogType(log_type_);
PeakFileOptions options;
options.clearMSLevels();
options.addMSLevel(2);
f.getOptions() = options;
f.load(in, exp);
exp.sortSpectra(true);
SpectrumLookup lookup;
lookup.readSpectra(exp.getSpectra());
for (vector<PeptideIdentification>::iterator pep_id = pep_ids.begin(); pep_id != pep_ids.end(); ++pep_id)
{
Size scan_id = lookup.findByRT(pep_id->getRT());
PeakSpectrum& temp = exp.getSpectrum(scan_id);
vector<PeptideHit> scored_peptides;
for (vector<PeptideHit>::const_iterator hit = pep_id->getHits().begin(); hit < pep_id->getHits().end(); ++hit)
{
PeptideHit scored_hit = *hit;
addScoreToMetaValues_(scored_hit, pep_id->getScoreType()); // backup score value
LOG_DEBUG << "starting to compute AScore RT=" << pep_id->getRT() << " SEQUENCE: " << scored_hit.getSequence().toString() << std::endl;
PeptideHit phospho_sites = ascore.compute(scored_hit, temp, fragment_mass_tolerance, fragment_mass_unit_ppm, max_peptide_len, max_num_perm);
scored_peptides.push_back(phospho_sites);
}
PeptideIdentification new_pep_id(*pep_id);
new_pep_id.setScoreType("PhosphoScore");
new_pep_id.setHigherScoreBetter(true);
new_pep_id.setHits(scored_peptides);
pep_out.push_back(new_pep_id);
}
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
IdXMLFile().store(out, prot_ids, pep_out);
return EXECUTION_OK;
}
示例14: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
StringList in(getStringList_("in"));
StringList id_in(getStringList_("id_in"));
String trained_model_file(getStringOption_("trained_model_file"));
String model_file(getStringOption_("model_file"));
bool score_filtering(getFlag_("score_filtering"));
double score_threshold(getDoubleOption_("score_threshold"));
Int min_charge(getIntOption_("min_charge"));
Int max_charge(getIntOption_("max_charge"));
if (in.empty())
{
writeLog_("For 'training' mode spectra and identifications are needed.");
return INCOMPATIBLE_INPUT_DATA;
}
//bool duplicates_by_tic(getFlag_("duplicates_by_tic"));
//bool base_model_from_file(getFlag_("base_model_from_file"));
// create model, either read from a model file, or initialize with default parameters
PILISModel model;
if (model_file != "")
{
writeDebug_("Reading model from file '" + model_file + "'", 1);
model.readFromFile(model_file);
}
else
{
writeDebug_("Initializing model", 1);
model.setParameters(getParam_().copy("PILIS_parameters:", true));
model.init();
}
Param pilis_param(model.getParameters());
ModificationDefinitionsSet mod_set(pilis_param.getValue("fixed_modifications"), pilis_param.getValue("variable_modifications"));
// read spectra file (if available)
vector<RichPeakMap> exp;
vector<vector<ProteinIdentification> > prot_ids;
vector<vector<PeptideIdentification> > pep_ids;
if (!in.empty())
{
FileTypes::Type in_file_type = FileHandler().getType(in[0]);
writeDebug_("File type of parameter 'in' estimated as '" + FileTypes::typeToName(in_file_type) + "'", 1);
// TODO check all types
if (in_file_type == FileTypes::MSP)
{
writeDebug_("Reading MSP file", 1);
MSPFile f;
exp.resize(in.size());
pep_ids.resize(in.size());
for (Size i = 0; i != in.size(); ++i)
{
f.load(in[i], pep_ids[i], exp[i]);
for (Size j = 0; j != exp[i].size(); ++j)
{
exp[i][j].getPeptideIdentifications().push_back(pep_ids[i][j]);
}
}
}
if (in_file_type == FileTypes::MZML)
{
MzMLFile f;
f.setLogType(log_type_);
exp.resize(in.size());
for (Size i = 0; i != in.size(); ++i)
{
f.load(in[i], exp[i]);
}
}
}
if (!id_in.empty())
{
prot_ids.resize(id_in.size());
pep_ids.resize(id_in.size());
IdXMLFile f;
for (Size i = 0; i != id_in.size(); ++i)
{
f.load(id_in[i], prot_ids[i], pep_ids[i]);
}
}
if (!id_in.empty() && !in.empty())
{
// map the
if (id_in.size() != in.size())
{
writeLog_("If in parameter contains mzML files and id_in contains idXML files, the number should be equal to allow mapping of the identification to the spectra");
return INCOMPATIBLE_INPUT_DATA;
}
//.........这里部分代码省略.........
示例15: main_
//.........这里部分代码省略.........
// warn if custom RT and more than one scan in input file
if (rt_custom && in.size() > 1)
{
writeLog_(String("Warning: More than one scan in file '") + filename + "'! All scans will have the same retention time!");
}
// handle special raw data options:
for (MSExperiment<>::iterator spec_it = in.begin();
spec_it != in.end(); ++spec_it)
{
float rt_final = spec_it->getRT();
if (rt_auto_number)
{
rt_final = ++rt_auto;
}
else if (rt_custom)
{
rt_final = custom_rts[i];
}
else if (rt_filename)
{
static const boost::regex re("rt(\\d+(\\.\\d+)?)");
boost::smatch match;
bool found = boost::regex_search(filename, match, re);
if (found)
{
rt_final = String(match[1]).toFloat();
}
else
{
writeLog_("Warning: could not extract retention time from filename '" + filename + "'");
}
}
// none of the rt methods were successful
if (rt_final < 0)
{
writeLog_(String("Warning: No valid retention time for output scan '") + rt_auto + "' from file '" + filename + "'");
}
spec_it->setRT(rt_final);
spec_it->setNativeID("spectrum=" + String(native_id));
if (ms_level > 0)
{
spec_it->setMSLevel(ms_level);
}
++native_id;
}
// if we have only one spectrum, we can annotate it directly, for more spectra, we just name the source file leaving the spectra unannotated (to avoid a long and redundant list of sourceFiles)
if (in.size() == 1)
{
in[0].setSourceFile(in.getSourceFiles()[0]);
in.getSourceFiles().clear(); // delete source file annotated from source file (it's in the spectrum anyways)
}
if (rt_gap_ > 0.0) // concatenate in RT
{
adjustRetentionTimes_(in, trafo_out[i], i == 0);
}
// add spectra to output
for (MSExperiment<>::const_iterator spec_it = in.begin();
spec_it != in.end(); ++spec_it)
{
out.addSpectrum(*spec_it);
}
// also add the chromatograms
for (vector<MSChromatogram<ChromatogramPeak> >::const_iterator
chrom_it = in.getChromatograms().begin(); chrom_it !=
in.getChromatograms().end(); ++chrom_it)
{
out.addChromatogram(*chrom_it);
}
// copy experimental settings from first file
if (i == 0)
{
out.ExperimentalSettings::operator=(in);
}
else // otherwise append
{
out.getSourceFiles().insert(out.getSourceFiles().end(), in.getSourceFiles().begin(), in.getSourceFiles().end()); // could be emtpty if spectrum was annotated above, but that's ok then
}
}
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
// annotate output with data processing info
addDataProcessing_(out, getProcessingInfo_(DataProcessing::FORMAT_CONVERSION));
MzMLFile f;
f.setLogType(log_type_);
f.store(out_file, out);
}
return EXECUTION_OK;
}