-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension of bruker precursor information (2nd attempt) #3191
base: master
Are you sure you want to change the base?
Changes from 14 commits
ba475f1
c9f071e
5c7e77a
e8e5c5e
112bf17
0b8ffc4
ee17fef
8aeecd0
0f3b1a3
8104588
3ab4cff
912c3c6
56949cf
e7bf0d5
3e7fd96
5f5a974
ef4e5d4
e2e6ea2
bb1a8ee
853d207
701ac75
a80d333
f4213a0
e487769
73aca39
c18d414
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,13 +52,13 @@ class Serializer_MGF::Impl | |
void read(shared_ptr<istream> is, MSData& msd) const; | ||
}; | ||
|
||
template <typename T> | ||
struct nosci10_policy : boost::spirit::karma::real_policies<T> | ||
{ | ||
// we want to generate up to 10 fractional digits | ||
static unsigned int precision(T) { return 10; } | ||
// we want the numbers always to be in fixed format | ||
static int floatfield(T) { return boost::spirit::karma::real_policies<T>::fmtflags::fixed; } | ||
template <typename T> | ||
struct nosci10_policy : boost::spirit::karma::real_policies<T> | ||
{ | ||
// we want to generate up to 10 fractional digits | ||
static unsigned int precision(T) { return 10; } | ||
// we want the numbers always to be in fixed format | ||
static int floatfield(T) { return boost::spirit::karma::real_policies<T>::fmtflags::fixed; } | ||
}; | ||
|
||
|
||
|
@@ -78,25 +78,25 @@ void Serializer_MGF::Impl::write(ostream& os, const MSData& msd, | |
SpectrumList& sl = *msd.run.spectrumListPtr; | ||
SpectrumWorkerThreads spectrumWorkers(sl, useWorkerThreads, continueOnError); | ||
for (size_t i=0, end=sl.size(); i < end; ++i) | ||
{ | ||
SpectrumPtr s; | ||
try | ||
{ | ||
// s = sl->spectrum(i, true); | ||
s = spectrumWorkers.processBatch(i); | ||
} | ||
catch (std::exception& e) | ||
{ | ||
if (continueOnError) | ||
{ | ||
{ | ||
SpectrumPtr s; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert whitespace only change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still seeing whitespace changes here. You know how to review the diff in GitHub? You can also review it locally if you set your diff engine to show whitespace changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, sorry, but unfortunately it's not finished yet. Yes, It's easy to see whitespace changes, but undoing them without removing other important things is a bit difficult for me. But I´m on it. Thank you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespaces should now be removed. |
||
try | ||
{ | ||
// s = sl->spectrum(i, true); | ||
s = spectrumWorkers.processBatch(i); | ||
} | ||
catch (std::exception& e) | ||
{ | ||
if (continueOnError) | ||
{ | ||
cerr << "Skipping spectrum " << i << " \"" << (s ? s->id : sl.spectrumIdentity(i).id) << "\": " << e.what() << endl; | ||
continue; | ||
} | ||
else | ||
throw; | ||
} | ||
else | ||
throw; | ||
} | ||
|
||
Scan* scan = !s->scanList.empty() ? &s->scanList.scans[0] : 0; | ||
const Scan& scan = !s->scanList.empty() ? s->scanList.scans[0] : Scan(); | ||
|
||
if (s->cvParam(MS_ms_level).valueAs<int>() > 1 && | ||
!s->precursors.empty() && | ||
|
@@ -105,16 +105,16 @@ void Serializer_MGF::Impl::write(ostream& os, const MSData& msd, | |
os << "BEGIN IONS\n"; | ||
|
||
const SelectedIon& si = s->precursors[0].selectedIons[0]; | ||
CVParam scanTimeParam = scan ? scan->cvParam(MS_scan_start_time) : CVParam(); | ||
CVParam scanTimeParam = scan.cvParam(MS_scan_start_time); | ||
CVParam chargeParam = si.cvParam(MS_charge_state); | ||
|
||
CVParam spectrumTitle = s->cvParam(MS_spectrum_title); | ||
if (!spectrumTitle.empty()) | ||
os << "TITLE=" << spectrumTitle.value << '\n'; | ||
else if (titleIsThermoDTA) | ||
{ | ||
string scan = id::value(s->id, "scan"); | ||
os << "TITLE=" << thermoBasename << '.' << scan << '.' << scan << '.' << chargeParam.value << '\n'; | ||
string scan_string = id::value(s->id, "scan"); | ||
os << "TITLE=" << thermoBasename << '.' << scan_string << '.' << scan_string << '.' << chargeParam.value << '\n'; | ||
} | ||
else | ||
os << "TITLE=" << s->id << '\n'; | ||
|
@@ -132,6 +132,16 @@ void Serializer_MGF::Impl::write(ostream& os, const MSData& msd, | |
os << " " << intensityParam.valueFixedNotation(); | ||
os << '\n'; | ||
|
||
CVParam inverseReduceIonMobility = scan.cvParam(MS_inverse_reduced_ion_mobility); | ||
if (!inverseReduceIonMobility.empty()) | ||
os << "INVREION=" << inverseReduceIonMobility.valueFixedNotation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you check whether some official product already writes it this way? Because according to the official MGF spec this is not a valid parameter. https://www.matrixscience.com/help/data_file_help.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, I´ll check this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope it´s done now. :-) |
||
os << '\n'; | ||
|
||
CVParam collisionalCrossSectionalArea = scan.cvParam(MS_collisional_cross_sectional_area); | ||
if (!collisionalCrossSectionalArea.empty()) | ||
os << "COLLCROSSSA=" << collisionalCrossSectionalArea.valueFixedNotation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no official MGF parameter for this. I would be more comfortable with this in the TITLE string, unless a Bruker product is already writing MGFs this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, Is there an example of adding some parameters to the title string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a titleMaker filter that allows for easy customization of the MGF title string with a user-defined format. Although it doesn't support CCS currently, only instrument-level ion mobility metrics. If you don't want to use that, you can add "ccs=" to the title string above this, before the line: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, that sounds good, I'll implement it that way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be finished. |
||
os << '\n'; | ||
|
||
if (chargeParam.empty()) | ||
{ | ||
vector<string> charges; | ||
|
@@ -148,9 +158,9 @@ void Serializer_MGF::Impl::write(ostream& os, const MSData& msd, | |
|
||
const BinaryDataArray& mzArray = *s->getMZArray(); | ||
const BinaryDataArray& intensityArray = *s->getIntensityArray(); | ||
using namespace boost::spirit::karma; | ||
typedef real_generator<double, nosci10_policy<double> > nosci10_type; | ||
static const nosci10_type nosci10 = nosci10_type(); | ||
using namespace boost::spirit::karma; | ||
typedef real_generator<double, nosci10_policy<double> > nosci10_type; | ||
static const nosci10_type nosci10 = nosci10_type(); | ||
char buffer[256]; | ||
for (size_t p=0; p < s->defaultArrayLength; ++p) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,6 +441,7 @@ struct PrecursorInfo | |
string collisionEnergy; | ||
string activation; | ||
double windowWideness; | ||
|
||
|
||
bool empty() const | ||
{ | ||
|
@@ -514,7 +515,6 @@ vector<PrecursorInfo> getPrecursorInfo(const Spectrum& spectrum, | |
return result; | ||
} | ||
|
||
|
||
void write_precursors(XMLWriter& xmlWriter, const vector<PrecursorInfo>& precursorInfo) | ||
{ | ||
xmlWriter.pushStyle(XMLWriter::StyleFlag_InlineInner); | ||
|
@@ -535,7 +535,7 @@ void write_precursors(XMLWriter& xmlWriter, const vector<PrecursorInfo>& precurs | |
attributes.add("activationMethod", it->activation); | ||
if (it->windowWideness != 0) | ||
attributes.add("windowWideness", it->windowWideness); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert whitespace only changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
xmlWriter.startElement("precursorMz", attributes); | ||
xmlWriter.characters(it->mz, false); | ||
xmlWriter.endElement(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,6 +235,16 @@ class SpectrumList_MGFImpl : public SpectrumList_MGF | |
else | ||
selectedIon.set(MS_selected_ion_m_z, value, MS_m_z); | ||
} | ||
else if (name == "INVREION") | ||
{ | ||
bal::trim(value); | ||
scan.cvParams.push_back(CVParam(MS_inverse_reduced_ion_mobility, value, MS_volt_second_per_square_centimeter)); | ||
} | ||
else if (name == "COLLCROSSSA") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When moving CCS to the title, it can be parsed back in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
{ | ||
bal::trim(value); | ||
scan.cvParams.push_back(CVParam(MS_collisional_cross_sectional_area, value, UO_square_angstrom)); | ||
} | ||
else if (name == "CHARGE") | ||
{ | ||
bal::trim_if(value, bal::is_any_of(" \t\r")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert whitespace only change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I´ll fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed.