Skip to content
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

Feature format #126

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
af824e7
Working out how to add support for LJ C4 parameters
chryswoods Nov 11, 2023
2f36fb2
Adding in the stubs so I can play with writing a pdbx/cif parser
chryswoods Nov 11, 2023
c610ac8
Added a PDBx parser which uses gemmi for reading and writing PDBx/mmC…
chryswoods Nov 11, 2023
3480923
Using the gemmi structure object is much easier and will be more main…
chryswoods Nov 11, 2023
d7c4f94
Moved the gemmi integration to sire.convert, as it would be much bett…
chryswoods Nov 12, 2023
7f45ae3
Have loaded the SireGemmi library and registered the reader and write…
chryswoods Nov 12, 2023
9f7b29e
Can now interoperate between (empty) sire.System and gemmi.Structure …
chryswoods Nov 12, 2023
91206d5
Cleaned up the interconversion - still only works for empty objects
chryswoods Nov 12, 2023
7172c95
Making progress - now beginning to add in all of the water molecules.
chryswoods Nov 12, 2023
fe2fe70
Not available for conda gemmi
chryswoods Nov 12, 2023
7f80f24
Making a lot of progress now - can load up waters and non-proteins
chryswoods Nov 12, 2023
47fa4ba
Can now read a PDBx/mmcif file by converting it from a gemmi Structure.
chryswoods Nov 13, 2023
8b98a02
Added in the calls to create a QStringList from a gemmi::Structure. N…
chryswoods Nov 13, 2023
df8331e
Can now convert water molecules over to gemmi (and can save them to a…
chryswoods Nov 13, 2023
04aabad
Can use ensure_entities
chryswoods Nov 13, 2023
741a6cb
Can now write molecules and proteins :-)
chryswoods Nov 13, 2023
cdffcdb
All multi-residue molecules are Polymers
chryswoods Nov 13, 2023
adc5f34
Added proper (working) support for recording bonds when converting to…
chryswoods Nov 14, 2023
b53ef2e
Adding in tests so that I can check the conversions. Need to clean up…
chryswoods Nov 14, 2023
2928b48
Done a better job of handling entities
chryswoods Nov 14, 2023
c085076
Pinned down version as gemmi is semverd, plus added more to the test
chryswoods Nov 14, 2023
209cd0c
Attempting to fix some of the compile / link issues for gemmi on diff…
chryswoods Nov 15, 2023
a8d699e
Added a test if we need the extra files, which definitely fails well
chryswoods Nov 15, 2023
cc959ca
Updating the docs - triggering a CI build :-)
chryswoods Nov 15, 2023
3d8dad6
Documented the gemmi integration, and also preserve the system name w…
chryswoods Nov 15, 2023
71c78b7
Manually adding in the C++ files we need from gemmi, and not linking to
chryswoods Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
54 changes: 42 additions & 12 deletions corelib/src/libs/SireIO/amberprm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void AmberPrm::rebuildLJParameters()

const auto acoeffs = float_data.value("LENNARD_JONES_ACOEF");
const auto bcoeffs = float_data.value("LENNARD_JONES_BCOEF");
const auto ccoeffs = float_data.value("LENNARD_JONES_CCOEF");

const auto hbond_acoeffs = float_data.value("HBOND_ACOEF");
const auto hbond_bcoeffs = float_data.value("HBOND_BCOEF");
Expand All @@ -401,6 +402,17 @@ void AmberPrm::rebuildLJParameters()
CODELOC);
}

if ((not ccoeffs.isEmpty()) and (ccoeffs.count() != acoeffs.count()))
{
throw SireIO::parse_error(QObject::tr("Incorrect number of LJ coefficients for the number of specified "
"atom types! Should be %1 for %2 types, but actually have "
"%3 LJ C-coefficients")
.arg((ntypes * (ntypes + 1)) / 2)
.arg(ntypes)
.arg(ccoeffs.count()),
CODELOC);
}

if (nb_parm_index.count() != ntypes * ntypes)
{
throw SireIO::parse_error(QObject::tr("Incorrect number of non-bonded parameter indicies. There should "
Expand All @@ -424,11 +436,12 @@ void AmberPrm::rebuildLJParameters()

const auto acoeffs_data = acoeffs.constData();
const auto bcoeffs_data = bcoeffs.constData();

const auto hbond_acoeffs_data = hbond_acoeffs.constData();
const auto hbond_bcoeffs_data = hbond_bcoeffs.constData();
const auto nb_parm_index_data = nb_parm_index.constData();

auto build_lj = [&](int i)
for (int i = 0; i < ntypes; ++i)
{
// amber stores the A and B coefficients as the product of all
// possible combinations. We need to find the values from the
Expand Down Expand Up @@ -461,22 +474,39 @@ void AmberPrm::rebuildLJParameters()

lj_data_array[i] = LJParameter(sigma * angstrom, epsilon * kcal_per_mol);
}
};
}

if (usesParallel())
if (not ccoeffs.isEmpty())
{
tbb::parallel_for(tbb::blocked_range<int>(0, ntypes), [&](tbb::blocked_range<int> r)
{
for (int i = r.begin(); i < r.end(); ++i)
// we need to create a matrix mapping the C4 terms for pairs
// of LJ parameters
QHash<LJParameter, QHash<LJParameter, double>> lj_c4_values;

const auto ccoeffs_data = ccoeffs.constData();

// find all of the C4 co-efficients for all of the types
for (int i = 0; i < ntypes; ++i)
{
for (int j = 0; i < ntypes; ++j)
{
build_lj(i);
} });
}
else
{
const int idx = nb_parm_index_data[ntypes * i + j];

const double ccoeff = ccoeffs_data[idx - 1];

if (ccoeff != 0)
{
const auto &lj0 = lj_data_array[i];
const auto &lj1 = lj_data_array[j];

lj_c4_values[lj0][lj1] = ccoeff;
lj_c4_values[lj1][lj0] = ccoeff;
}
}
}

// now give each LJParameter its C4 values for all other types
for (int i = 0; i < ntypes; ++i)
{
build_lj(i);
}
}

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
Loading