Source code for kvazar.core.martini

# -*- coding: utf-8 -*-
import numpy

from mm import MM
from params import martini_parm
from lib import libmartini

[docs]class MARTINI(MM): """ This class is the successor of class MM Constructor of class MARTINI: Args: struct(structure): nanostructure ff_params(list): list of names of force field parameters(functions) """ def __init__(self, struct, ff_params): if not ff_params: ff_params = ["u_bond", "u_angle", "u_tors", "u_lj", "u_charge"] self.parm = martini_parm.getMARTINI_parm() super(MARTINI, self).__init__(struct, libmartini, ff_params, self.parm)
[docs] def preprocessing(self, struct): """ It corrects atom type and atom boxnames, group them and find out, if bead is the part of protein, take mass of bead from parameters. """ id_of_type_name = self.parm["bead_ids"] id_of_atom_group = self.parm["bead_group_ids"] isprot = self.parm["is_protein"] bmass = self.parm["mass"] struct.atom_types = numpy.zeros(struct.n_atoms, numpy.int32) struct.atom_groups = numpy.zeros(struct.n_atoms, numpy.int32) isprotein = [] mass = [] if hasattr(struct, "atom_names"): for i, at in enumerate(struct.atom_names): struct.atom_types[i] = id_of_type_name[at] struct.atom_groups[i] = id_of_atom_group[at] isprotein.append(isprot[at]) mass.append(bmass[at]) self.parm["isprotein"] = numpy.array(isprotein, numpy.bool) self.struct.mass = numpy.array(mass) return True
[docs] def init_cutoff(self, r_in, r_out, cutoff_neighbours): """ Args: r_in(float): internal cutoff radius r_out(float): external cutoff radius cutoff_neighbours(list): list of neighbours get into the field with r_out radius """ self.parm["use_cutoff"] = True self.parm["cutoff_r"] = r_in self.parm["cutoff_d"] = r_out - r_in self.update_cutoff(cutoff_neighbours)
[docs] def update_cutoff(self, cutoff_neighbours): """ Updates list of neighbours in cutoff area Args: cutoff_neighbours(list): list of neighbours """ cutoff_neigh = [] neigh = self.struct.neighbours for i, ng in enumerate(cutoff_neighbours): cutoff_neigh.append([]) for nb in ng: if nb not in neigh[i]: cutoff_neigh[i].append(int(nb)) self.struct.cutoff_neighbours = cutoff_neigh