peleffy.forcefield.parameters.BaseParameterWrapper

class peleffy.forcefield.parameters.BaseParameterWrapper(parameters_dict={}, forcefield_name=None)[source]

It defines the base class of a parameter wrapper that inherits from dict.

__init__(parameters_dict={}, forcefield_name=None)[source]

It initializes a parameter wrapper object.

Parameters
  • parameters_dict (dict) – A dictionary keyed by parameter type that contains the parameters to store. Default is an empty dict

  • forcefield_name (str) – The name of the force field the parameters belong to

add_parameters(label, parameters)[source]

It adds a list of parameters of the same type to the collection.

Parameters
  • label (str) – The label to describe the parameter type

  • parameters (list) – The list of parameters to include to the collection

clear() → None. Remove all items from D.
copy() → a shallow copy of D
static from_impact_template(molecule, impact_template_path)[source]

It returns a parameter wrapper out of an impact template.

Parameters
  • molecule (a peleffy.topology.Molecule) – The peleffy’s Molecule object

  • impact_template_path (str) – The path to the impact template from where the parameters will be fetched

Returns

params – The resulting parameters wrapper

Return type

a BaseParameterWrapper object

Examples

Obtain a parameter wrapper from an Impact template.

>>> from peleffy.topology import Molecule
>>> molecule = Molecule('molecule.pdb')
>>> impact_template_path = 'molz'
>>> from peleffy.forcefield.parameters import                 OpenForceFieldParametersWrapper
>>> wrapper_off = OpenForceFieldParametersWrapper()
>>> parameters = wrapper_off.from_impact_template(
        molecule, impact_template_path)
static from_json(input_path)[source]

It loads a json file containing the parameters into the parameter wrapper.

Parameters

input_path (str) – The path to the json file to load the parameters from

Returns

parameters – The resulting parameters wrapper

Return type

a BaseParameterWrapper object

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

is_empty()[source]

If the are no parameters stored in this wrapper, it returns True.

Returns

answer – Whether this parameter wrapper is empty or not

Return type

bool

items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

to_json(output_path)[source]

It saves this parameter wrapper as a json file.

Parameters

output_path (str) – The path to save the output json file

to_string()[source]

It returns a string representation of the parameters stored in the wrapper.

Returns

string_repr – The string representation

Return type

str

update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D’s values

Attributes

atom_iterator

It returns an iterator that goes through all atom parameters.

forcefield_name

name

It returns the name of the current parameter wrapper.