Skip to content
Snippets Groups Projects
Commit 99832e3e authored by Langella Olivier's avatar Langella Olivier
Browse files

violent bug reported by Céline Henry on Fasta file export fixed

parent d3cf1445
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
******************************************************************************/
#include "exportfastafile.h"
#include <pappsomspp/pappsoexception.h>
ExportFastaFile::ExportFastaFile(QString filename, ExportFastaType type)
{
......@@ -33,10 +34,21 @@ ExportFastaFile::ExportFastaFile(QString filename, ExportFastaType type)
m_exportType = type;
}
ExportFastaFile::~ExportFastaFile()
{
close();
}
void
ExportFastaFile::write(ProjectSp project_sp)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
if(mp_outputFastaFile == nullptr)
{
throw pappso::PappsoException(
QObject::tr("error : mp_outputFastaFile is null\n"));
}
mp_outputFastaFile->open(QIODevice::WriteOnly);
QTextStream *p_outputStream = new QTextStream(mp_outputFastaFile);
......@@ -48,17 +60,23 @@ ExportFastaFile::write(ProjectSp project_sp)
{
writeIdentificationGroup(fasta_output, identification);
}
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
mp_outputFastaFile->flush();
delete mp_outputFastaFile;
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
mp_outputFastaFile->close();
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
close();
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
void
ExportFastaFile::close()
{
delete mp_outputFastaFile;
mp_outputFastaFile = nullptr;
if(mp_outputFastaFile != nullptr)
{
delete mp_outputFastaFile;
mp_outputFastaFile = nullptr;
}
}
......@@ -66,7 +84,7 @@ void
ExportFastaFile::writeIdentificationGroup(
pappso::FastaOutputStream &fasta_output, IdentificationGroup *p_ident)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
for(const std::pair<unsigned int, GroupingGroupSp> &group_pair :
p_ident->getGroupStore().getGroupMap())
{
......@@ -79,7 +97,8 @@ ExportFastaFile::writeIdentificationGroup(
std::vector<const ProteinMatch *> protein_match_list =
group_pair.second.get()->getProteinMatchList();
std::sort(protein_match_list.begin(), protein_match_list.end(),
std::sort(protein_match_list.begin(),
protein_match_list.end(),
[](const ProteinMatch *a, const ProteinMatch *b) {
return a->getGrpProteinSp().get()->getGroupingId() <
b->getGrpProteinSp().get()->getGroupingId();
......@@ -115,4 +134,5 @@ ExportFastaFile::writeIdentificationGroup(
fasta_output.writeProtein(protein);
}
}
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
......@@ -44,6 +44,7 @@ class ExportFastaFile
public:
ExportFastaFile(QString filename, ExportFastaType type);
virtual ~ExportFastaFile();
void write(ProjectSp project_sp);
void close();
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment