mstk.forcefield.FFTermFactory¶
- class mstk.forcefield.FFTermFactory¶
Factory class for force field terms.
Mainly used for loading a FFTerm from xml element stored in ZFP file.
Methods
__init__()create_from_zff(line)Reconstruct a FFTerm using a line read from ZFF text file.
create_from_zfp(name, d)Reconstruct a FFTerm using a dict of attributes read from ZFP xml file.
register(klass[, extra_names])Register a force field term so that it can be read from or write into a ZFP or ZFF file.
- static register(klass, extra_names=None)¶
Register a force field term so that it can be read from or write into a ZFP or ZFF file.
- Parameters:
klass (subclass of FFTerm) –
extra_names (list of str) –
- static create_from_zfp(name, d)¶
Reconstruct a FFTerm using a dict of attributes read from ZFP xml file.
Essentially it finds the class for the term, and calls the constructor of the class. Every class to be reconstructed should have a class attribute _zfp_attrs. This dict records which attributes should be saved into ZFP xml file, and it is also used as the arguments for initializing a FFTerm. It also tell the data type of these attributes.
Some force field terms can not be fully built from the constructor. Then
FFTerm._from_zfp_extra()should be implemented for those terms, and it will be called to do some extra works.- Parameters:
name (str) – Class name of the term to be constructed
d (dict, [str, str]) – Attributes loaded from ZFP xml element
- Returns:
term
- Return type:
subclass of FFTerm
- static create_from_zff(line)¶
Reconstruct a FFTerm using a line read from ZFF text file.
Essentially it finds the class for the term, and calls the constructor of the class. Every class to be reconstructed should have a class attribute _zfp_attrs. This dict records which attributes should be saved into ZFP xml file, and it is also used as the arguments for initializing a FFTerm. It also tell the data type of these attributes.
Some force field terms can not be fully built from the constructor. Then
FFTerm._from_zff_extra()should be implemented for those terms, and it will be called to do some extra works.- Parameters:
line (str) – A line read from ZFF file
- Returns:
term
- Return type:
subclass of FFTerm