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();
373 if(decimal_places < 0)
376 double multiplier = std::pow(10.0, decimal_places);
381 return std::ceil(value * multiplier) / multiplier;
386 return std::round(value * multiplier + 1e-9) / multiplier;
393 return std::nextafter(value, value + 1);
399 std::chrono::system_clock::time_point chrono_time)
404 tt = std::chrono::system_clock::to_time_t(chrono_time);
406 QString debug_text = QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
414 std::chrono::system_clock::time_point chrono_start,
415 std::chrono::system_clock::time_point chrono_finish)
419 "%1 %2 min = %3 s = %4 ms = %5 "
422 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish - chrono_start).count())
423 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish - chrono_start).count())
425 std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish - chrono_start).count())
426 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish - chrono_start)
437 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
441 std::vector<double> double_vector;
443 for(
int iter = 0; iter < string_list.size(); ++iter)
445 QString current_string = string_list.at(iter);
449 double current_double = current_string.toDouble(&ok);
451 if(!current_double && !ok)
457 double_vector.push_back(current_double);
460 return double_vector;
464std::vector<std::size_t>
469 QStringList string_list = text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
474 std::vector<std::size_t> sizet_vector;
476 for(
int iter = 0; iter < string_list.size(); ++iter)
478 QString current_string = string_list.at(iter);
482 std::size_t current_sizet = current_string.toUInt(&ok);
484 if(!current_sizet && !ok)
490 sizet_vector.push_back(current_sizet);
522 return "abSciexWiff";
526 return "agilentMassHunter";
540 return "brukerBafAscii";
557 return "tims_frames";
631 throw PappsoException(QString(
"Enums::PeptideIon name not implemented"));
693 return iodoacetamide;
705 return phosphorylated;
728 return dimethylated_medium;
734 return dimethylated_heavy;
739 return DimethylpyrroleAdduct;
746 QObject::tr(
"Utils::guessAaModificationPbyMonoisotopicMassDelta => "
747 "modification not found for mass %1")
755 if(unimod_accession ==
"UNIMOD:1")
760 if(unimod_accession ==
"UNIMOD:4")
765 if(unimod_accession ==
"UNIMOD:7")
770 if(unimod_accession ==
"UNIMOD:27")
776 if(unimod_accession ==
"UNIMOD:28")
782 if(unimod_accession ==
"UNIMOD:35")
787 qInfo() <<
"unimod_accession:" << unimod_accession <<
" not found";
796 for(
auto i = myVec.begin(); i != myVec.end(); i++)
798 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 double roundValueToDecimalPlaces(double value, int decimal_places, bool round_up=true)
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