Skip to content

Commit

Permalink
Code Arrangement Changes #8 (#5476)
Browse files Browse the repository at this point in the history
Co-authored-by: Arraxx <kumaramanjha2901@gmail.com>
  • Loading branch information
Arraxx and Arraxx committed Aug 7, 2021
1 parent 962916f commit e4434b2
Show file tree
Hide file tree
Showing 50 changed files with 926 additions and 525 deletions.
2 changes: 2 additions & 0 deletions src/openms/source/FORMAT/ConsensusXMLFile.cpp
Expand Up @@ -258,7 +258,9 @@ namespace OpenMS
String file_version = "";
optionalAttributeAsString_(file_version, attributes, "version");
if (file_version == "")
{
file_version = "1.0"; //default version is 1.0
}
if (file_version.toDouble() > version_.toDouble())
{
warning(LOAD, "The XML file (" + file_version + ") is newer than the parser (" + version_ + "). This might lead to undefined program behavior.");
Expand Down
10 changes: 8 additions & 2 deletions src/openms/source/FORMAT/ControlledVocabulary.cpp
Expand Up @@ -209,8 +209,9 @@ namespace OpenMS

//do nothing for empty lines
if (line == "")
{
continue;

}
//********************************************************************************
//stanza line
if (line_wo_spaces[0] == '[')
Expand Down Expand Up @@ -292,7 +293,9 @@ namespace OpenMS
//check if the parent term name is correct
String parent_name = line.suffix('!').trim();
if (!checkName_(parent_id, parent_name))
{
cerr << "Warning: while loading term '" << term.id << "' of CV '" << name_ << "': part_of relationship term name '" << parent_name << "' and id '" << parent_id << "' differ." << "\n";
}
}
else
{
Expand All @@ -309,7 +312,9 @@ namespace OpenMS
//check if the parent term name is correct
String unit_name = line.suffix('!').trim();
if (!checkName_(unit_id, unit_name))
{
cerr << "Warning: while loading term '" << term.id << "' of CV '" << name_ << "': has_units relationship term name '" << unit_name << "' and id '" << unit_id << "' differ." << "\n";
}
}
else
{
Expand Down Expand Up @@ -572,8 +577,9 @@ namespace OpenMS
bool ControlledVocabulary::checkName_(const String& id, const String& name, bool ignore_case)
{
if (!exists(id))
{
return true; //what?!

}
String parent_name = name;
String real_parent_name = getTerm(id).name;

Expand Down
22 changes: 16 additions & 6 deletions src/openms/source/FORMAT/DATAACCESS/MSDataSqlConsumer.cpp
Expand Up @@ -84,18 +84,28 @@ namespace OpenMS
{
spectra_.push_back(s);
s.clear(false);
if (full_meta_) peak_meta_.addSpectrum(s);

if (spectra_.size() >= flush_after_) {flush();}
if (full_meta_)
{
peak_meta_.addSpectrum(s);
}
if (spectra_.size() >= flush_after_)
{
flush();
}
}

void MSDataSqlConsumer::consumeChromatogram(ChromatogramType & c)
{
chromatograms_.push_back(c);
c.clear(false);
if (full_meta_) peak_meta_.addChromatogram(c);

if (chromatograms_.size() >= flush_after_) {flush();}
if (full_meta_)
{
peak_meta_.addChromatogram(c);
}
if (chromatograms_.size() >= flush_after_)
{
flush();
}
}

void MSDataSqlConsumer::setExpectedSize(Size /* expectedSpectra */, Size /* expectedChromatograms */) {;}
Expand Down
Expand Up @@ -85,6 +85,9 @@ namespace OpenMS
void MSDataTransformingConsumer::setExperimentalSettings(const OpenMS::ExperimentalSettings& es)
{
// apply the given function to it (unless nullptr)
if (lambda_exp_settings_) lambda_exp_settings_(es);
if (lambda_exp_settings_)
{
lambda_exp_settings_(es);
}
}
} // namespace OpenMS
Expand Up @@ -187,8 +187,9 @@ namespace OpenMS

// Only write the footer if we actually did start writing ...
if (started_writing_)
{
Internal::MzMLHandlerHelper::writeFooter_(ofs_, options_, spectra_offsets_, chromatograms_offsets_);

}
delete validator_;
ofs_.close();
}
Expand Down
Expand Up @@ -133,13 +133,13 @@ namespace OpenMS
{
if (line.hasPrefix(n_id_prefix))
{
String n_id = line.erase(line.find(n_id_prefix), n_id_prefix.size());
ext_n_ids.emplace_back(n_id);
String n_id = line.erase(line.find(n_id_prefix), n_id_prefix.size());
ext_n_ids.emplace_back(n_id);
}
else if (spectrum_ms_file.eof())
{
OPENMS_LOG_WARN << "No native id was found - please check your input mzML. " << std::endl;
break;
OPENMS_LOG_WARN << "No native id was found - please check your input mzML. " << std::endl;
break;
}
}
spectrum_ms_file.close();
Expand Down
17 changes: 12 additions & 5 deletions src/openms/source/FORMAT/FeatureXMLFile.cpp
Expand Up @@ -400,7 +400,9 @@ namespace OpenMS
else if (tag == "featureList")
{
if (options_.getMetadataOnly())
{
throw EndParsingSoftly(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
}
Size count = attributeAsInt_(attributes, "count");
if (size_only_) // true if loadSize() was used instead of load()
{
Expand Down Expand Up @@ -812,8 +814,9 @@ namespace OpenMS
}

if (disable_parsing_)
{
return;

}
// do the actual parsing:
open_tags_.pop_back();

Expand All @@ -823,8 +826,9 @@ namespace OpenMS
in_description_ = false;
}
if (in_description_)
{
return;

}
if (tag == "feature")
{
if ((!options_.hasRTRange() || options_.getRTRange().encloses(current_feature_->getRT()))
Expand Down Expand Up @@ -933,18 +937,21 @@ namespace OpenMS
{
// handle skipping of whole sections
if (disable_parsing_)
{
return;

}
// do the actual parsing:

//for downward compatibility, all tags in the old description must be ignored
if (in_description_)
{
return;

}
// we are before first tag or beyond last tag
if (open_tags_.size() == 0)
{
return;

}
String& current_tag = open_tags_.back();
if (current_tag == "intensity")
{
Expand Down
4 changes: 4 additions & 0 deletions src/openms/source/FORMAT/FileHandler.cpp
Expand Up @@ -456,7 +456,9 @@ namespace OpenMS
conversion_error = true;
}
if (!conversion_error)
{
return FileTypes::DTA;
}
}

//DTA2D
Expand All @@ -475,7 +477,9 @@ namespace OpenMS
conversion_error = true;
}
if (!conversion_error)
{
return FileTypes::DTA2D;
}
}

// MGF (Mascot Generic Format)
Expand Down
21 changes: 16 additions & 5 deletions src/openms/source/FORMAT/FileTypes.cpp
Expand Up @@ -131,7 +131,10 @@ namespace OpenMS
{
for (const auto& t : type_list_)
{
if (t == type) return true;
if (t == type)
{
return true;
}
}
return false;
}
Expand Down Expand Up @@ -161,8 +164,10 @@ namespace OpenMS
}
out += ListUtils::concatenate(items, "");
}
if (add_all_filter) out += "all files (*);;";

if (add_all_filter)
{
out += "all files (*);;";
}
// remove the last ";;", since this will be interpreted as ' (*)' by Qt
out = out.chop(2);

Expand All @@ -174,7 +179,10 @@ namespace OpenMS
{
for (const auto& t_info : type_with_annotation__)
{
if (t_info.type == type) return t_info.name;
if (t_info.type == type)
{
return t_info.name;
}
}
throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Type has no name!", String(type));
}
Expand All @@ -195,7 +203,10 @@ namespace OpenMS

for (const auto& t_info : type_with_annotation__)
{
if (String(t_info.name).toUpper() == name_upper) return t_info.type;
if (String(t_info.name).toUpper() == name_upper)
{
return t_info.type;
}
}

return FileTypes::UNKNOWN;
Expand Down

0 comments on commit e4434b2

Please sign in to comment.