50 QRegularExpression(
"\\d*\\.?\\d+");
59 QRegularExpression(
"-?\\d*\\.?\\d*[e-]?\\d*");
64 QRegularExpression(QString(
"^(%1)(%2)(%3)")
75 int size = log10(num);
77 QLatin1Char latin1_char(size);
78 QString base(latin1_char);
79 base.append(QString().setNum(num));
87 *p_out << (char)(log10(num) + 97) << num;
107 int intPart =
static_cast<int>(value);
111 double decimalPart = value - intPart;
117 while(decimalPart > 0)
143 if(decimal_places < 0)
146 return ceil((value * pow(10, decimal_places)) - 0.49) / pow(10, decimal_places);
154 if(
sizeof(
int *) == 4)
156 test_decimal = 100000000;
158 return (floor(input * test_decimal));
169 std::string env_backup;
174 env_backup = std::setlocale(LC_ALL,
nullptr);
175 std::setlocale(LC_ALL,
"C");
177 std::locale::global(std::locale(
"C"));
180 catch(std::exception &error)
183 QObject::tr(
"Error trying to set local to C : %1").arg(error.what()));
186 QByteArray byte_array = text.toUtf8();
187 std::string stdText =
"";
189 for(
char c : byte_array)
198 std::setlocale(LC_ALL, env_backup.c_str());
200 std::locale::global(std::locale(
""));
203 catch(std::exception &error)
207 QObject::tr(
"Error trying to set local to original system one %1 : %2")
208 .arg(env_backup.c_str())
220 QFile file(file_name);
222 if(file.open(QFile::WriteOnly | QFile::Truncate))
225 QTextStream out(&file);
242 QFile file(file_name);
244 if(file.open(QFile::WriteOnly | QFile::Append))
246 file.open(QIODevice::WriteOnly);
248 QTextStream fileStream(&file);
250 for(
auto &&value : data)
251 fileStream << QString(
"%1\n").arg(value, 0,
'f', decimals);
266 QFile file(file_name);
268 if(file.open(QFile::WriteOnly | QFile::Append))
271 QTextStream out(&file);
288 qDebug() <<
" " << spectrum_native_id;
289 QStringList native_id_list = spectrum_native_id.split(
"=");
290 if(native_id_list.size() < 2)
293 QObject::tr(
"scan number not found in mzML native id %1").arg(spectrum_native_id));
311 return native_id_list.back().toULong();
320 return QString(
"%1").arg((quintptr)pointer, QT_POINTER_SIZE * 2, 16, QChar(
'0'));
341 double valueSum = std::abs(value1 + value2);
345 double valueDiff = std::abs(value1 - value2);
349 double epsilon = std::numeric_limits<double>::epsilon();
353 double scaleFactor = epsilon * valueSum * decimalPlaces;
361 bool res = valueDiff < scaleFactor
363 || valueDiff < std::numeric_limits<double>::min();
375 return std::nextafter(value, value + 1);
381 std::chrono::system_clock::time_point chrono_time)
386 tt = std::chrono::system_clock::to_time_t(chrono_time);
388 QString debug_text = QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
396 std::chrono::system_clock::time_point chrono_start,
397 std::chrono::system_clock::time_point chrono_finish)
401 "%1 %2 min = %3 s = %4 ms = %5 "
404 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish - chrono_start).count())
405 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish - chrono_start).count())
407 std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish - chrono_start).count())
408 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish - chrono_start)
419 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
423 std::vector<double> double_vector;
425 for(
int iter = 0; iter < string_list.size(); ++iter)
427 QString current_string = string_list.at(iter);
431 double current_double = current_string.toDouble(&ok);
433 if(!current_double && !ok)
439 double_vector.push_back(current_double);
442 return double_vector;
446std::vector<std::size_t>
451 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
456 std::vector<std::size_t> sizet_vector;
458 for(
int iter = 0; iter < string_list.size(); ++iter)
460 QString current_string = string_list.at(iter);
464 std::size_t current_sizet = current_string.toUInt(&ok);
466 if(!current_sizet && !ok)
472 sizet_vector.push_back(current_sizet);
504 return "abSciexWiff";
508 return "agilentMassHunter";
522 return "brukerBafAscii";
539 return "tims_frames";
613 throw PappsoException(QString(
"Enums::PeptideIon name not implemented"));
675 return iodoacetamide;
687 return phosphorylated;
710 return dimethylated_medium;
716 return dimethylated_heavy;
721 return DimethylpyrroleAdduct;
728 QObject::tr(
"Utils::guessAaModificationPbyMonoisotopicMassDelta => "
729 "modification not found for mass %1")
737 if(unimod_accession ==
"UNIMOD:1")
742 if(unimod_accession ==
"UNIMOD:4")
747 if(unimod_accession ==
"UNIMOD:7")
752 if(unimod_accession ==
"UNIMOD:27")
758 if(unimod_accession ==
"UNIMOD:28")
764 if(unimod_accession ==
"UNIMOD:35")
769 qInfo() <<
"unimod_accession:" << unimod_accession <<
" not found";
778 for(
auto i = myVec.begin(); i != myVec.end(); i++)
780 result.push_back((*i));
pappso_double getMass() const
static AaModificationP getInstance(const QString &accession)
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
bool contains(pappso_double) const
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
static QString chronoTimePointDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_time=std::chrono::system_clock::now())
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
static QString pointerToString(const void *const pointer)
static QString msDataFormatAsString(Enums::MsDataFormat mz_format)
Convenience function to return a string describing the MzFormat of a file.
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
static QRegularExpression anythingButDigitDotDash
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
Tell if both double values, are equal within the double representation capabilities of the platform.
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
static std::vector< double > splitMzStringToDoubleVectorWithSpaces(const QString &text, std::size_t &error_count)
static double nearestGreater(double value)
static std::string toUtf8StandardString(const QString &text)
static bool appendToFile(const QString &text, const QString &file_name)
static QString fileReaderTypeAsString(Enums::FileReaderType file_reader_type)
static QString booleanToString(bool value)
convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable ...
static AaModificationP translateAaModificationFromUnimod(const QString &unimod_accession)
static QString chronoIntervalDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_start, std::chrono::system_clock::time_point chrono_finish=std::chrono::system_clock::now())
static long long int roundToDecimal32bitsAsLongLongInt(pappso_double input)
static bool writeToFile(const QString &text, const QString &file_name)
static std::vector< std::size_t > splitSizetStringToSizetVectorWithSpaces(const QString &text, std::size_t &error_count)
static QRegularExpression signedDoubleNumberExponentialRegExp
static QRegularExpression xyMassDataFormatRegExp
Regular expression matching <numerical value><non-numerical*><numericalvalue>.
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
static const QString getLexicalOrderedString(unsigned int num)
static QJsonArray toJson(const std::vector< double > &myVec)
convert vector of double into json array
static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num)
static int zeroDecimalsInValue(pappso_double value)
Determine the number of zero decimals between the decimal point and the first non-zero decimal.
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
static QString getVersion()
#define PAPPSOMSPP_VERSION
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter).
@ astar
Nter aldimine ions + NH3 loss.
@ ystar
Cter amino ions + NH3 loss.
@ yo
Cter amino ions + H2O loss.
@ bstar
Nter acylium ions + NH3 loss.
@ bo
Nter acylium ions + H2O loss.
@ ao
Nter aldimine ions + H2O loss.
@ tims
TimsMsRunReader : each scan is returned as a mass spectrum.
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)
@ reAlign
Re Alignment (1 - RE).
@ align
Alignment (2 - AL).
ExperimentalSpectrumDataPointType
@ both
both, the ion and the complement exists in the original spectrum
@ symmetric
new peak : computed symmetric mass from a corresponding native peak
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
const AaModification * AaModificationP
double pappso_double
A type definition for doubles.
const PrecisionBase * PrecisionPtr
std::map< Enums::PrecisionUnit, QString > precisionUnitMap