49 QRegularExpression(
"\\d*\\.?\\d+");
58 QRegularExpression(
"-?\\d*\\.?\\d*[e-]?\\d*");
63 QRegularExpression(QString(
"^(%1)(%2)(%3)")
74 int size = log10(num);
76 QLatin1Char latin1_char(size);
77 QString base(latin1_char);
78 base.append(QString().setNum(num));
86 *p_out << (char)(log10(num) + 97) << num;
106 int intPart =
static_cast<int>(value);
110 double decimalPart = value - intPart;
116 while(decimalPart > 0)
142 if(decimal_places < 0)
145 return ceil((value * pow(10, decimal_places)) - 0.49) / pow(10, decimal_places);
153 if(
sizeof(
int *) == 4)
155 test_decimal = 100000000;
157 return (floor(input * test_decimal));
168 std::string env_backup;
173 env_backup = std::setlocale(LC_ALL,
nullptr);
174 std::setlocale(LC_ALL,
"C");
176 std::locale::global(std::locale(
"C"));
179 catch(std::exception &error)
182 QObject::tr(
"Error trying to set local to C : %1").arg(error.what()));
185 QByteArray byte_array = text.toUtf8();
186 std::string stdText =
"";
188 for(
char c : byte_array)
197 std::setlocale(LC_ALL, env_backup.c_str());
199 std::locale::global(std::locale(
""));
202 catch(std::exception &error)
206 QObject::tr(
"Error trying to set local to original system one %1 : %2")
207 .arg(env_backup.c_str())
219 QFile file(file_name);
221 if(file.open(QFile::WriteOnly | QFile::Truncate))
224 QTextStream out(&file);
241 QFile file(file_name);
243 if(file.open(QFile::WriteOnly | QFile::Append))
245 file.open(QIODevice::WriteOnly);
247 QTextStream fileStream(&file);
249 for(
auto &&value : data)
250 fileStream << QString(
"%1\n").arg(value, 0,
'f', decimals);
265 QFile file(file_name);
267 if(file.open(QFile::WriteOnly | QFile::Append))
270 QTextStream out(&file);
287 qDebug() <<
" " << spectrum_native_id;
288 QStringList native_id_list = spectrum_native_id.split(
"=");
289 if(native_id_list.size() < 2)
292 QObject::tr(
"scan number not found in mzML native id %1").arg(spectrum_native_id));
310 return native_id_list.back().toULong();
319 return QString(
"%1").arg((quintptr)pointer, QT_POINTER_SIZE * 2, 16, QChar(
'0'));
340 double valueSum = std::abs(value1 + value2);
344 double valueDiff = std::abs(value1 - value2);
348 double epsilon = std::numeric_limits<double>::epsilon();
352 double scaleFactor = epsilon * valueSum * decimalPlaces;
360 bool res = valueDiff < scaleFactor
362 || valueDiff < std::numeric_limits<double>::min();
374 return std::nextafter(value, value + 1);
380 std::chrono::system_clock::time_point chrono_time)
385 tt = std::chrono::system_clock::to_time_t(chrono_time);
387 QString debug_text = QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
395 std::chrono::system_clock::time_point chrono_start,
396 std::chrono::system_clock::time_point chrono_finish)
400 "%1 %2 min = %3 s = %4 ms = %5 "
403 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish - chrono_start).count())
404 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish - chrono_start).count())
406 std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish - chrono_start).count())
407 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish - chrono_start)
418 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
422 std::vector<double> double_vector;
424 for(
int iter = 0; iter < string_list.size(); ++iter)
426 QString current_string = string_list.at(iter);
430 double current_double = current_string.toDouble(&ok);
432 if(!current_double && !ok)
438 double_vector.push_back(current_double);
441 return double_vector;
445std::vector<std::size_t>
450 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
455 std::vector<std::size_t> sizet_vector;
457 for(
int iter = 0; iter < string_list.size(); ++iter)
459 QString current_string = string_list.at(iter);
463 std::size_t current_sizet = current_string.toUInt(&ok);
465 if(!current_sizet && !ok)
471 sizet_vector.push_back(current_sizet);
503 return "abSciexWiff";
507 return "agilentMassHunter";
521 return "brukerBafAscii";
538 return "tims_frames";
612 throw PappsoException(QString(
"Enums::PeptideIon name not implemented"));
674 return iodoacetamide;
686 return phosphorylated;
709 return dimethylated_medium;
715 return dimethylated_heavy;
720 return DimethylpyrroleAdduct;
727 QObject::tr(
"Utils::guessAaModificationPbyMonoisotopicMassDelta => "
728 "modification not found for mass %1")
736 if(unimod_accession ==
"UNIMOD:1")
741 if(unimod_accession ==
"UNIMOD:4")
746 if(unimod_accession ==
"UNIMOD:7")
751 if(unimod_accession ==
"UNIMOD:27")
757 if(unimod_accession ==
"UNIMOD:28")
763 if(unimod_accession ==
"UNIMOD:35")
768 qInfo() <<
"unimod_accession:" << unimod_accession <<
" not found";
777 for(
auto i = myVec.begin(); i != myVec.end(); i++)
779 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