Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel'
Browse files Browse the repository at this point in the history
Merging from 2023.5.0.dev into 2023.5.0 for the release
  • Loading branch information
chryswoods committed Dec 15, 2023
2 parents 5412f1c + 1e9a6b9 commit 16421d9
Show file tree
Hide file tree
Showing 64 changed files with 4,614 additions and 423 deletions.
2 changes: 2 additions & 0 deletions corelib/src/libs/SireIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set ( SIREIO_HEADERS
netcdffile.h
pdb.h
pdb2.h
pdbx.h
perturbationslibrary.h
protoms.h
sdf.h
Expand Down Expand Up @@ -95,6 +96,7 @@ set ( SIREIO_SOURCES
netcdffile.cpp
pdb.cpp
pdb2.cpp
pdbx.cpp
perturbationslibrary.cpp
protoms.cpp
sdf.cpp
Expand Down
3 changes: 3 additions & 0 deletions corelib/src/libs/SireIO/mol2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,9 @@ void Mol2::addToSystem(System &system, const PropertyMap &map) const
// you should loop through each molecule in the system and work out
// which ones are described in the file, and then add data from the file
// to thise molecules.
throw SireError::unsupported(QObject::tr(
"You cannot add data from a mol2 file to an existing system!"),
CODELOC);
}

/** Internal function used to get the molecule structure for molecule 'imol'. */
Expand Down
87 changes: 53 additions & 34 deletions corelib/src/libs/SireIO/moleculeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,19 @@ MoleculeParserPtr MoleculeParser::parse(const System &system, const QString &for
cannot be recognised, or if there is an error in parsing. */
MoleculeParserPtr MoleculeParser::parse(const QString &filename, const PropertyMap &map)
{
MoleculeParserPtr parser = MoleculeParser::_pvt_parse(filename, map);
getFileCache()->clear();
MoleculeParserPtr parser;

try
{
parser = MoleculeParser::_pvt_parse(filename, map);
getFileCache()->clear();
}
catch (...)
{
getFileCache()->clear();
throw;
}

return parser;
}

Expand All @@ -1939,48 +1950,56 @@ QList<MoleculeParserPtr> MoleculeParser::parse(const QStringList &filenames, con
{
QList<MoleculeParserPtr> result;

if (filenames.count() == 1)
{
result.append(MoleculeParser::_pvt_parse(filenames[0], map));
}
else
try
{
QVector<MoleculeParserPtr> parsers(filenames.count());

bool run_parallel = true;

if (map["parallel"].hasValue())
if (filenames.count() == 1)
{
run_parallel = map["parallel"].value().asA<BooleanProperty>().value();
}

if (run_parallel)
{
// parse the files in parallel - we use a grain size of 1
// as each file can be pretty big, and there won't be many of them
tbb::parallel_for(
tbb::blocked_range<int>(0, filenames.count(), 1),
[&](tbb::blocked_range<int> r)
{
for (int i = r.begin(); i < r.end(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
},
tbb::simple_partitioner());
result.append(MoleculeParser::_pvt_parse(filenames[0], map));
}
else
{
for (int i = 0; i < filenames.count(); ++i)
QVector<MoleculeParserPtr> parsers(filenames.count());

bool run_parallel = true;

if (map["parallel"].hasValue())
{
run_parallel = map["parallel"].value().asA<BooleanProperty>().value();
}

if (run_parallel)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
// parse the files in parallel - we use a grain size of 1
// as each file can be pretty big, and there won't be many of them
tbb::parallel_for(
tbb::blocked_range<int>(0, filenames.count(), 1),
[&](tbb::blocked_range<int> r)
{
for (int i = r.begin(); i < r.end(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
},
tbb::simple_partitioner());
}
else
{
for (int i = 0; i < filenames.count(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
}

result = parsers.toList();
}

result = parsers.toList();
getFileCache()->clear();
}
catch (...)
{
getFileCache()->clear();
throw;
}

getFileCache()->clear();

return result;
}
Expand Down
Loading

0 comments on commit 16421d9

Please sign in to comment.