MolecularSystem should be immutable
A FragmentDict
is available once a MolecularSystem
is initialized, but when fragments are selected for a given region these are removed from the FragmentDict
. As I understand, this is a safeguard, to prevent inclusion of the same fragment into multiple regions (a pointless operation) However, it might be counterintuitive to newcomers, given that the state of the MolecularSystem
changes within a script and depends on the order of operations one has carried out on it.
One could think of the FragmentDict
value as storing a data structure that includes the name of the region where a given fragment has been included:
- Upon grabbing fragments into a region, there could be a check on this field. If it's empty, add to the region and update. If it's set already, either pop and exception or reduce don't add it to the new region (a no-op, quite surprising so I'd got for the exception)
- One bonus. A
get_all_fragments()
function could be implemented and that would give the same results at any point in the script. - One more bonus. This should also make the
-
operation (and not only+
) make sense onFragmentDict
. "Desired" use example:project = pyframe.Project() system = pyframe.MolecularSystem(input_file='chrom_in_water.pdb') water = system.get_fragments_by_name(names=['T3P']) core = system.get_all_fragments() - water
- Possibly a further bonus. Algebraic operations (
+
and-
only, that I can foresee) mixingMolecularSystem
s and regions (defined asFragmentDict
s) could actually start to make sense (some additional coding, since they have different types). "Desired" use example:project = pyframe.Project() system = pyframe.MolecularSystem(input_file='chrom_in_water.pdb') water = system.get_fragments_by_name(names=['T3P']) core = system - water