feat: take into account [ atomtype ] section when including itp files #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! It's me again :)
First of all some I wanted to include several ligands into the same .top file calling append_ligand() iteratively. However when doing so, the BioBB simply added the corresponding include directives in the main topology and I ended up in a situation like the following:
The issue with this situation is that each ligand itp file might contain an [ atomtype ] directive as well as the corresponding [ moleculetype ]. In that case we would be alternating [ atomtype ] with [ moleculetype ] directives in the .top file. This leads to an error as explained here.. The solution is given by Justin Lemkul in the same thread:
"If your ligand topologies both introduce new atom types (or any other force field parameters), you have to collect them and declare those directives before any [moleculetype] can be introduced. The entire force field has to be complete before any molecules can be defined. See the Error FAQ page for more information."
So what I've done is to cut the [ atomtype ] directive from the input itp we want to include (if there is any) and merge it with the [ atomtype ] directive in the input .top file (if there is any).
And alternative approach to this one would be to always write [ atomtype ] directives in a separate file. This would require more work and I'm not sure the final solution would be much better.
Of course the piece of code that takes care of this could be separated into a method of the AppendLigand BioBB or a common.py file.
I left some comments regarding additional situations that should be taken into account and would require more work:
I hope this is useful, as always feel free to modify or discard as you think is best.