Skip to content

Commit 2c35ff6

Browse files
committed
Patch potentually fit peaks getting out of sync/re-ordered when concatanated batch peak fit file has cleanup_after_load.
I didnt see this happening on example scenerious I ran, probably because all sample numbers are unique, so it shouldnt happen - but made these changes JIC.
1 parent 0247c8c commit 2c35ff6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/BatchPeak.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,13 @@ void fit_peaks_in_files( const std::string &exemplar_filename,
710710
concatenated_spec->setPeaks( peaks_copy, sample_nums );
711711
}
712712
}
713-
713+
714+
// TODO: Sort sample numbers according to start time, and call:
715+
//concatenated_spec->change_sample_numbers(<#const std::vector<std::pair<int, int>> &from_to_sample_nums#>);
716+
714717
// Clean up the SpecMeas after adding all measurements
715-
concatenated_spec->cleanup_after_load();
716-
718+
concatenated_spec->cleanup_after_load( SpecUtils::SpecFile::DontChangeOrReorderSamples );
719+
717720
// Save the concatenated file
718721
const string concatenated_file = SpecUtils::append_path( options.output_dir, "concatenated.n42" );
719722

src/SpecMeas.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,18 @@ const map<set<int>,long long int> &SpecMeas::dbUserStateIndexes() const
25862586

25872587
void SpecMeas::cleanup_after_load( const unsigned int flags )
25882588
{
2589-
if( m_fileWasFromInterSpec )
2589+
bool has_any_peaks = false;
2590+
if( m_peaks )
2591+
{
2592+
for( const auto &samples_peaks : *m_peaks )
2593+
{
2594+
has_any_peaks = (samples_peaks.second && !samples_peaks.second->empty());
2595+
if( has_any_peaks )
2596+
break;
2597+
}
2598+
}//if( m_peaks )
2599+
2600+
if( m_fileWasFromInterSpec || has_any_peaks )
25902601
{
25912602
SpecFile::cleanup_after_load( (flags | SpecFile::DontChangeOrReorderSamples) );
25922603
}else

0 commit comments

Comments
 (0)