From c48bf6039a3e3d22a7e28b04b3da056e56a4bf81 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 1 Jun 2017 13:33:05 +0200 Subject: [PATCH] direct output for tsv spectral count --- src/gui/main.ui | 23 +++++++++++++ src/gui/mainwindow.cpp | 54 +++++++++++++++++++++++++++--- src/gui/mainwindow.h | 1 + src/output/ods/comparbasesheet.cpp | 8 +++-- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/gui/main.ui b/src/gui/main.ui index 088de361..b21bdc63 100644 --- a/src/gui/main.ui +++ b/src/gui/main.ui @@ -41,6 +41,7 @@ <addaction name="actionMassChroQ"/> <addaction name="actionSpreadsheet"/> <addaction name="actionProticDb"/> + <addaction name="action_spectral_counting_mcq"/> </widget> <addaction name="actionLoad_results"/> <addaction name="actionLoad"/> @@ -108,6 +109,11 @@ <string>PROTICdb</string> </property> </action> + <action name="action_spectral_counting_mcq"> + <property name="text"> + <string>Spectral Counting mcq</string> + </property> + </action> </widget> <resources> <include location="../xtpcpp.qrc"/> @@ -257,6 +263,22 @@ </hint> </hints> </connection> + <connection> + <sender>action_spectral_counting_mcq</sender> + <signal>triggered()</signal> + <receiver>Main</receiver> + <slot>doActionSpectralCountingMcq()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>231</x> + <y>191</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>selectXpipFile()</slot> @@ -268,5 +290,6 @@ <slot>doActionModifications()</slot> <slot>doActionLabelingMethods()</slot> <slot>doActionFasta()</slot> + <slot>doActionSpectralCountingMcq()</slot> </slots> </ui> diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c2568e55..76b615e8 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -31,9 +31,21 @@ #include "ui_main.h" #include <pappsomspp/pappsoexception.h> #include <pappsomspp/fasta/fastaoutputstream.h> +#include <odsstream/tsvoutputstream.h> #include "../utils/utils.h" #include "workerthread.h" +#include "output/ods/comparspectrasheet.h" +class TsvNoSheetOutput: public TsvOutputStream { +public : + TsvNoSheetOutput(QTextStream & otxtstream):TsvOutputStream(otxtstream) { + } + ~TsvNoSheetOutput() { + } + + virtual void writeSheet(const QString & sheetName) override { + } +}; MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), @@ -60,11 +72,11 @@ MainWindow::MainWindow(QWidget *parent): //QDockWidget *dock = new QDockWidget(tr("Protein List"), this); //dock->setWidget(_protein_list_window); //addDockWidget(Qt::RightDockWidgetArea, dock); - + qRegisterMetaType<ProjectSp>("ProjectSp"); qRegisterMetaType<AutomaticFilterParameters>("AutomaticFilterParameters"); qRegisterMetaType<GroupingType>("GroupingType"); - + #if QT_VERSION >= 0x050000 // Qt5 code /* @@ -263,6 +275,40 @@ void MainWindow::doActionSpreadsheet() { qDebug() << "MainWindow::doActionSpreadsheet end"; } +void MainWindow::doActionSpectralCountingMcq() +{ + qDebug() << "MainWindow::doActionSpectralCountingMcq begin"; + + QSettings settings; + QString default_location = settings.value("path/scmcqfile", "").toString(); + + QString filename = QFileDialog::getSaveFileName(this, tr("Save spectral count TSV text file"), + QString("%1/untitled.tsv").arg(default_location), + tr("TSV (*.tsv)")); + + if (filename.isEmpty()) { + return; + } + + settings.setValue("path/scmcqfile", QFileInfo(filename).absolutePath()); + + + + QFile outFile; + outFile.setFileName(filename); + outFile.open(QIODevice::WriteOnly); + QTextStream * p_outputStream = new QTextStream(&outFile); + TsvNoSheetOutput* p_writer = new TsvNoSheetOutput(*p_outputStream); + ComparSpectraSheet spectra_sheet(nullptr, p_writer, _project_sp.get()); + spectra_sheet.writeSheet(); + + p_writer->close(); + delete p_writer; + delete p_outputStream; + outFile.close(); + qDebug() << "MainWindow::doActionSpectralCountingMcq end"; +} + void MainWindow::doActionFasta() { try { @@ -324,7 +370,7 @@ void MainWindow::doActionMassChroQ() { } settings.setValue("path/mcqfile", QFileInfo(filename).absolutePath()); - + showWaitingMessage(tr("Writing %1 XPIP file").arg(QFileInfo(filename).fileName())); emit operateWritingMassChroqFile(filename, _project_sp); //emit operateXpipFile(filename); @@ -352,7 +398,7 @@ void MainWindow::doActionProticDb() { } settings.setValue("path/proticfile", QFileInfo(filename).absolutePath()); - + showWaitingMessage(tr("Writing %1 PROTICdbML file").arg(QFileInfo(filename).fileName())); emit operateWritingProticFile(filename, _project_sp); //emit operateXpipFile(filename); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 956d8cf3..362df421 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -71,6 +71,7 @@ public slots: void doOperationFailed(QString); void doOperationFinished(); void doGroupingFinished(); + void doActionSpectralCountingMcq(); //void peptideEdited(QString peptideStr); // void setColor(const QColor &color); // void setShape(Shape shape); diff --git a/src/output/ods/comparbasesheet.cpp b/src/output/ods/comparbasesheet.cpp index acf60e13..338a6967 100644 --- a/src/output/ods/comparbasesheet.cpp +++ b/src/output/ods/comparbasesheet.cpp @@ -70,7 +70,7 @@ void ComparBaseSheet::writeHeaders(IdentificationGroup * p_ident) { }); - _p_writer->writeLine(); + //_p_writer->writeLine(); _p_writer->writeCell("Group ID"); _p_writer->writeCell("Subgroup ID"); //_p_writer->setCellAnnotation("MS sample name (MS run)"); @@ -95,9 +95,13 @@ void ComparBaseSheet::writeProteinMatch(const ProteinMatch * p_protein_match) { unsigned int subgroup_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); unsigned int rank_number = p_protein_match->getGrpProteinSp().get()->getRank(); - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + if (_p_ods_export != nullptr) { + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + } _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); + if (_p_ods_export != nullptr) { _p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer); + } _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(subgroup_number)); _p_writer->clearTableCellStyleRef(); _p_writer->writeCell(p_protein_match->getGrpProteinSp().get()->getGroupingId()); -- GitLab