Loading...
Searching...
No Matches
msrunid.cpp
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#include "msrunid.h"
#include <QFileInfo>
#include <QDir>
int msRunIdMetaTypeId = qRegisterMetaType<pappso::MsRunId>("pappso::MsRunId");
int msRunIdCstSPtrMetaTypeId =
qRegisterMetaType<pappso::MsRunIdCstSPtr>("pappso::MsRunIdCstSPtr");
namespace pappso
{
MsRunId::MsRunId()
{
}
MsRunId::MsRunId(const QString &file_name) : m_fileName(file_name)
{
// by default, the sample name is given by the file name
QFileInfo fileinfo(m_fileName);
if(fileinfo.fileName() == "analysis.tdf")
{
m_fileName = fileinfo.absoluteDir().absolutePath();
}
m_sampleName = QFileInfo(m_fileName).baseName();
}
MsRunId::MsRunId(const QString &file_name, const QString &run_id)
: MsRunId(file_name)
{
m_runId = run_id;
}
MsRunId::MsRunId(const MsRunId &other)
: m_fileName(other.m_fileName),
m_runId(other.m_runId),
m_xmlId(other.m_xmlId),
m_sampleName(other.m_sampleName),
m_mzFormat(other.m_mzFormat)
{
}
MsRunId::~MsRunId()
{
}
void
MsRunId::setSampleName(const QString &name)
{
m_sampleName = name;
}
const QString &
MsRunId::getSampleName() const
{
return m_sampleName;
}
void
MsRunId::setFileName(const QString &file_name)
{
m_fileName = file_name;
QFileInfo file_info(file_name);
QString extension = file_info.suffix();
if(m_sampleName.isEmpty())
{
// set sample name by default :
m_sampleName = file_info.baseName();
}
m_mzFormat = MzFormat::unknown;
if(extension.toLower() == "mzxml")
{
m_mzFormat = MzFormat::mzXML;
}
else if(extension.toLower() == "mgf")
{
m_mzFormat = MzFormat::MGF;
}
else if(extension.toLower() == "mzml")
{
m_mzFormat = MzFormat::mzML;
}
}
void
MsRunId::setRunId(const QString &run_id)
{
m_runId = run_id;
}
const QString &
MsRunId::getRunId() const
{
return m_runId;
}
void
MsRunId::setXmlId(const QString &xml_id)
{
m_xmlId = xml_id;
}
const QString &
MsRunId::getXmlId() const
{
return m_xmlId;
}
const QString &
MsRunId::getFileName() const
{
return m_fileName;
}
void
MsRunId::setMzFormat(MzFormat format)
{
m_mzFormat = format;
}
MzFormat
MsRunId::getMzFormat() const
{
return m_mzFormat;
}
bool
MsRunId::operator==(const MsRunId &other) const
{
if(m_xmlId == other.m_xmlId)
return true;
return false;
}
MsRunId &
MsRunId::operator=(const MsRunId &other)
{
m_xmlId = other.m_xmlId;
m_fileName = other.m_fileName;
m_sampleName = other.m_sampleName;
m_mzFormat = other.m_mzFormat;
return *this;
}
QString
MsRunId::toString() const
{
QString text = QString(
"file name: '%1'\n"
"run id: '%2'\n"
"xml id: '%3'\n"
"sample name: '%4'\n")
.arg(m_fileName)
.arg(m_runId)
.arg(m_xmlId)
.arg(m_sampleName);
return text;
}
bool
MsRunId::isValid() const
{
return !m_fileName.isEmpty() && !m_runId.isEmpty() && !m_xmlId.isEmpty() &&
m_mzFormat != MzFormat::unknown;
}
} // namespace pappso
pappso::MsRunId
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
pappso::MsRunId::m_runId
QString m_runId
Definition msrunid.h:91
pappso::MsRunId::m_mzFormat
MzFormat m_mzFormat
Definition msrunid.h:94
pappso::MsRunId::getMzFormat
MzFormat getMzFormat() const
Definition msrunid.cpp:165
pappso::MsRunId::m_xmlId
QString m_xmlId
Definition msrunid.h:92
pappso::MsRunId::MsRunId
MsRunId()
Definition msrunid.cpp:39
pappso::MsRunId::getFileName
const QString & getFileName() const
Definition msrunid.cpp:151
pappso::MsRunId::toString
QString toString() const
Definition msrunid.cpp:193
pappso::MsRunId::getXmlId
const QString & getXmlId() const
Definition msrunid.cpp:144
pappso::MsRunId::~MsRunId
virtual ~MsRunId()
Definition msrunid.cpp:73
pappso::MsRunId::m_sampleName
QString m_sampleName
Definition msrunid.h:93
pappso::MsRunId::setFileName
void setFileName(const QString &file_name)
Definition msrunid.cpp:93
pappso::MsRunId::operator=
MsRunId & operator=(const MsRunId &other)
Definition msrunid.cpp:181
pappso::MsRunId::getRunId
const QString & getRunId() const
Definition msrunid.cpp:130
pappso::MsRunId::getSampleName
const QString & getSampleName() const
Definition msrunid.cpp:86
pappso::MsRunId::setRunId
void setRunId(const QString &run_id)
Definition msrunid.cpp:123
pappso::MsRunId::setMzFormat
void setMzFormat(MzFormat format)
Definition msrunid.cpp:158
pappso::MsRunId::setXmlId
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:137
pappso::MsRunId::m_fileName
QString m_fileName
Definition msrunid.h:90
pappso::MsRunId::isValid
bool isValid() const
Definition msrunid.cpp:210
pappso::MsRunId::setSampleName
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:79
pappso::MsRunId::operator==
bool operator==(const MsRunId &other) const
Definition msrunid.cpp:172
msRunIdCstSPtrMetaTypeId
int msRunIdCstSPtrMetaTypeId
Definition msrunid.cpp:32
msRunIdMetaTypeId
int msRunIdMetaTypeId
Definition msrunid.cpp:29
msrunid.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::MzFormat
MzFormat
Definition types.h:120
pappso::MzFormat::mzXML
@ mzXML
mzXML
pappso::MzFormat::mzML
@ mzML
mzML
pappso::MzFormat::unknown
@ unknown
unknown format
pappso::MzFormat::MGF
@ MGF
Mascot format.