MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / plotFilteredSpectra

Method plotFilteredSpectra

src/topp/MetaProSIP.cpp:468–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466 }
467
468 static void plotFilteredSpectra(const String& output_dir, const String& tmp_path, const String& file_suffix, const String& file_extension, const vector<SIPPeptide>& sip_peptides, Size debug_level = 0, const QString& executable = QString("R"))
469 {
470 String filename = String("spectrum_plot") + file_suffix + "." + file_extension;
471 String script_filename = String("spectrum_plot") + file_suffix + String(".R");
472
473 for (Size i = 0; i != sip_peptides.size(); ++i)
474 {
475 TextFile current_script;
476 StringList mz_list;
477 StringList intensity_list;
478
479 for (Size j = 0; j != sip_peptides[i].accumulated.size(); ++j)
480 {
481 const Peak1D& peak = sip_peptides[i].accumulated[j];
482 mz_list.push_back(String(peak.getMZ()));
483 intensity_list.push_back(String(peak.getIntensity()));
484 }
485
486 String mz_list_string;
487 mz_list_string.concatenate(mz_list.begin(), mz_list.end(), ",");
488
489 String intensity_list_string;
490 intensity_list_string.concatenate(intensity_list.begin(), intensity_list.end(), ",");
491
492 current_script.addLine("mz<-c(" + mz_list_string + ")");
493 current_script.addLine("int<-c(" + intensity_list_string + ")");
494 current_script.addLine("x0=mz; x1=mz; y0=rep(0, length(x0)); y1=int");
495
496 if (file_extension == "png")
497 {
498 current_script.addLine("png('" + tmp_path + "/" + filename + "')");
499 }
500 else if (file_extension == "svg")
501 {
502 current_script.addLine("svg('" + tmp_path + "/" + filename + "', width=8, height=4.5)");
503 }
504 else if (file_extension == "pdf")
505 {
506 current_script.addLine("pdf('" + tmp_path + "/" + filename + "', width=8, height=4.5)");
507 }
508
509 current_script.addLine("plot.new()");
510 current_script.addLine("plot.window(xlim=c(min(mz),max(mz)), ylim=c(0,max(int)))");
511 current_script.addLine("axis(1); axis(2)");
512 current_script.addLine("title(xlab=\"m/z\")");
513 current_script.addLine("title(ylab=\"intensity\")");
514 current_script.addLine("box()");
515 current_script.addLine("segments(x0,y0,x1,y1)");
516 current_script.addLine("tmp<-dev.off()");
517 current_script.store(tmp_path + "/" + script_filename);
518
519 QProcess p;
520 QStringList env = QProcess::systemEnvironment();
521 env << QString("R_LIBS=") + tmp_path.toQString();
522 p.setEnvironment(env);
523
524 QStringList qparam;
525 qparam << "--vanilla" << "--quiet" << "--slave" << "--file=" + QString(tmp_path.toQString() + "/" + script_filename.toQString());

Callers

nothing calls this directly

Calls 14

concatenateMethod · 0.80
QStringClass · 0.50
StringClass · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
getMZMethod · 0.45
getIntensityMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
storeMethod · 0.45
toQStringMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected