Skip to content

Commit

Permalink
Handle upper-case [ATOMS] line in Molden files from Cfour
Browse files Browse the repository at this point in the history
  • Loading branch information
ghutchis committed Nov 15, 2024
1 parent 9dfc2c3 commit 7eb4a75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions avogadro/core/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ inline std::vector<std::string> split(const std::string& string, char delimiter,
* @param search String that will be searched for.
* @return True if the string contains search, false otherwise.
*/
inline bool contains(const std::string& input, const std::string& search)
inline bool contains(const std::string& input, const std::string& search,
bool caseSensitive = true)
{
size_t found = input.find(search);
return found != std::string::npos;
if (caseSensitive) {
return input.find(search) != std::string::npos;
} else {
std::string inputLower = input;
std::string searchLower = search;
std::transform(inputLower.begin(), inputLower.end(), inputLower.begin(),
::tolower);
std::transform(searchLower.begin(), searchLower.end(), searchLower.begin(),
::tolower);
return inputLower.find(searchLower) != std::string::npos;
}
}

/**
Expand Down Expand Up @@ -98,7 +108,7 @@ T lexicalCast(const std::string& inputString, bool& ok)
return value;
}

} // end Core namespace
} // end Avogadro namespace
} // namespace Core
} // namespace Avogadro

#endif // AVOGADRO_CORE_UTILITIES_H
2 changes: 1 addition & 1 deletion avogadro/quantumio/molden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void MoldenFile::processLine(std::istream& in)
// Molden file format uses sections, each starts with a header line of the
// form [Atoms], and the beginning of a new section denotes the end of the
// last.
if (Core::contains(line, "[Atoms]")) {
if (Core::contains(line, "[Atoms]") || Core::contains(line, "[ATOMS]")) {
if (list.size() > 1 && Core::contains(list[1], "AU"))
m_coordFactor = BOHR_TO_ANGSTROM_D;
m_mode = Atoms;
Expand Down

0 comments on commit 7eb4a75

Please sign in to comment.