Beispiel #1
0
 def __lineToAtom(self, line):
     """put each coordinate line into atom class"""
     ai = Atom()
     tokens = line.strip().split()
     ai.number = int(tokens[0])
     ai.name = tokens[1]
     ai.an = tokens[2]
     ai.type1 = tokens[3]
     ai.type2 = tokens[4]
     ai.charge = float(tokens[5])
     ai.x[0] = float(tokens[6])
     ai.x[1] = float(tokens[7])
     ai.x[2] = float(tokens[8])
     ai.resn = int(tokens[9])
     ai.resname = tokens[10]
     ai.cg = int(tokens[11])
     return ai
Beispiel #2
0
 def __lineToAtom(self, line):
     """put each coordinate line into atom class"""
     ai = Atom()
     tokens = line.strip().split()
     ai.number = int(tokens[0])
     ai.name = tokens[1]
     ai.an = tokens[2]
     ai.type1 = tokens[3]
     ai.type2 = tokens[4]
     ai.charge = float(tokens[5])
     ai.x[0] = float(tokens[6])
     ai.x[1] = float(tokens[7])
     ai.x[2] = float(tokens[8])
     ai.resn = int(tokens[9])
     ai.resname = tokens[10]
     ai.cg = int(tokens[11])
     return ai
Beispiel #3
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        s.atomtypes = self.atomtypes
        s.n_atoms = self.n_atoms
        s.n_bonds = self.n_bonds
        s.n_angles = self.n_angles
        s.n_dihedrals = self.n_dihedrals
        s.n_impropers = self.n_impropers
        s.n_atomtypes = self.n_atomtypes
        s.n_bondtypes = self.n_bondtypes
        s.n_angletypes = self.n_angletypes
        s.n_dihedraltypes = self.n_dihedraltypes
        s.n_impropertypes = self.n_impropertypes
        s.bonds = self.bonds
        s.angles = self.angles
        s.dihedrals = self.dihedrals
        s.ffparams = self.ffparams

        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.resn = int(i[1])
                atom.name = self.elements[int(i[2]) - 1]
                atom.element = self.elements[int(i[2]) - 1]
                atom.type2 = int(i[2])
                atom.charge = float(i[3])
                atom.x[0] = float(i[4])
                atom.x[1] = float(i[5])
                atom.x[2] = float(i[6])
                s.atoms.append(atom)
        return s
Beispiel #4
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        s.atomtypes = self.atomtypes
        s.n_atoms = self.n_atoms
        s.n_bonds = self.n_bonds
        s.n_angles = self.n_angles
        s.n_dihedrals = self.n_dihedrals
        s.n_impropers = self.n_impropers
        s.n_atomtypes = self.n_atomtypes
        s.n_bondtypes = self.n_bondtypes
        s.n_angletypes = self.n_angletypes
        s.n_dihedraltypes = self.n_dihedraltypes
        s.n_impropertypes = self.n_impropertypes
        s.bonds = self.bonds
        s.angles = self.angles
        s.dihedrals = self.dihedrals
        s.ffparams = self.ffparams

        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.resn = int(i[1])
                atom.name = self.elements[int(i[2]) - 1]
                atom.element = self.elements[int(i[2]) - 1]
                atom.type2 = int(i[2])
                atom.charge = float(i[3])
                atom.x[0] = float(i[4]) 
                atom.x[1] = float(i[5]) 
                atom.x[2] = float(i[6]) 
                s.atoms.append(atom)
        return s