Exemple #1
0
def _parse_oniom_line(line_splits):
    """C-CT--0.2      0  1.000 1.100 1.200 L H-HC 123 0.0"""
    mm_info, mask, x, y, z, temp = line_splits[0:6]
    layer, link_splits = temp[0], temp[1:].split()
    # create atom and MM_obj
    el, mm_obj = _parse_mm_info(mm_info)
    atom = atoms.Atom(el, (float(x), float(y), float(z)))
    if mm_obj: 
        atom.set_mm(mm_obj) # high layer atoms might not have it
    # create Oniom object
    oniom_obj = atoms.Oniom(int(mask), layer)
    # process link atom
    if len(link_splits) == 1:
        raise RuntimeError('missing bound_to in link atom: %s' % (
            ' '.join(link_splits)))
    elif len(link_splits) > 1:
        link_splits.append('0.0')  # HAMMERATION
        link_mm_info, bound_to, scale1 = link_splits[:3]
        link_el, link_mm_obj = _parse_mm_info(link_mm_info)
        link_atom = atoms.Atom(link_el, (0, 0, 0)) # empty coords
        if link_mm_obj:
            link_atom.set_mm(link_mm_obj)
        oniom_obj.set_link(link_atom, int(bound_to), float(scale1))
    # add oniom_obj
    atom.set_oniom(oniom_obj)
    return atom
Exemple #2
0
def _parse_xyz_line(line_splited):
    (el, x, y, z) = line_splited
    el, mm_obj = _parse_mm_info(el)
    atom = atoms.Atom(el, (float(x), float(y), float(z)))
    if mm_obj:
        atom.set_mm(mm_obj)
    return atom
Exemple #3
0
def mol22atom(line):
    "Reads a mol2 atom line and returns the atoms indexes and bond order"
    """ex:\
    '      1 O1         -0.5240   -0.4910   -0.1630 os        1 MOL     -0.196235\n'
    """
    words = line.strip().split()

    # basic atom info
    element = words[5].split('.')[0]
    x, y, z = words[2:5]
    
    # mm info
    atom_type = words[1]
    if len(words) == 9:
        charge = words[8]
        name = words[1]
        atom_type = words[5] #changes the info of the atom_type if mol2 has
                             # 9 fields
    else:
        charge = None

    atom = atoms.Atom(atom_type,(float(x), float(y), float(z)))
    mm_obj = atoms.MM(atom_type, charge)
    atom.set_mm(mm_obj)

    #resinfo if mol2 has 9 fields
    if len(words) == 9:
        resinfo_obj = atoms.RESinfo(name, words[7], words[6], 'X')
        atom.set_resinfo(resinfo_obj)

    return atom
Exemple #4
0
def pdb2atom(line):
    # start atom
    el = line      [76:78].strip()
    if el == '':
        el = ''.join(i for i in line[12:16].strip() if not i.isdigit())[0] #get from atom name
                                                                    #after eliminating numbers
    x  = float(line[30:38])
    y  = float(line[38:46])
    z  = float(line[46:54])
    atom = atoms.Atom(el, (x,y,z))

    # residue info
    name        = line      [12:16].strip()     # atom name
    resName     = line      [17:20].strip()     # Residue name
    resNum      = spaceint(line[22:26])    # Residue number
    chain       = line      [21:22].strip()     # chain
    resinfo = atoms.RESinfo(name, resName, resNum, chain)

    # pdb info
    keyword   = line[ 0: 6]     
    serial    = spaceint(line[ 6:11]) 
    pdbinfo = atoms.PDBinfo(keyword, serial, 
        occupancy   = spacefloat(line[54:60]),
        bfact       = spacefloat(line[60:66]),
        altloc      = line[16:17],
        icode       = line[26:27],
        formalcharge = line[78:80].strip())

    # return
    atom.set_resinfo(resinfo)
    atom.set_pdbinfo(pdbinfo)
    return atom
Exemple #5
0
    def _gen_zmat(self, inpcrd_name):

        text = ''

        chargelist = self.read_flag('CHARGE')
        if 'ATOMIC_NUMBER' in self._flags:  # old amboniom_elements.py (glycam)
            elements = self._guess_elements()
        else:
            elements = self._read_elements()

        total_charge = 0

        X, Y, Z = self._coords_from_inpcrd(inpcrd_name)

        j = 0
        for i in self.atom_sel_idx:
            name = self.pdb_atom_name[i].replace('-', '').replace('+', '')
            residue_name = self.pdb_resname[i].replace('-',
                                                       '').replace('+', '')
            residue_number = self.pdb_resid[i]
            mm_type = self.upper_atom_types[i]
            charge = chargelist[i] / 18.2223
            total_charge += charge
            mask = '0'
            x = X[i]
            y = Y[i]
            z = Z[i]
            chain = ''
            layer = 'L'
            element = elements[j]
            j += 1
            link_element = link_mm_type = link_bound_to = link_scale1 = None

            # create atom
            this_atom = atoms.Atom(element, (x, y, z))
            resinfo = atoms.RESinfo(name, residue_name, residue_number, chain)
            this_atom.set_resinfo(resinfo)
            oniominfo = atoms.Oniom(mask, layer)
            this_atom.set_oniom(oniominfo)
            mm = atoms.MM(mm_type, charge)
            this_atom.set_mm(mm)

            # print z-matrix for atom
            text += iolines.atom2zmat(this_atom)

        # Add stuff to text
        header = ''
        #header += '%nproc=4\n'
        #header += '%mem=2GB\n'
        #header += '%chk=chk.chk\n'
        header += '# amber=softonly geom=connectivity\n\n'
        header += 'Se amanha nao chover vai estar um lindo dia de sol\n\n'
        header += 'Sum of partial charges: %f\n' % (total_charge)
        return header + text
Exemple #6
0
    def read_geometry(self, opt_step, scan_step):

        with open(self.name, 'r') as f:
            f.seek(self.bytedict['orientation:'][scan_step][opt_step])
            atoms_list = []
            for _ in range(5):
                f.readline()
            for model_atom in self.atoms_list:
                line = f.readline()
                atomic_number = int(line.split()[1])
                x, y, z = line.split()[3:6]
                element = atoms.PERIODIC_TABLE.GetSymbol(atomic_number)
                xyz = (float(x), float(y), float(z))
                atom = atoms.Atom(element, xyz)
                atoms_list.append(atom)
        return atoms_list
Exemple #7
0
def pdbqt2atom(line):
    # start atom
    atype = line[77:79].strip()
    x  = float(line[30:38])
    y  = float(line[38:46])
    z  = float(line[46:54])
    ad2el = {'H':'H', 'HD':'H', 'HS':'H', 'C':'C', 'A':'C', 'N':'N', 'NA':'N',
        'NS':'N', 'OA':'O', 'OS':'O', 'F':'F', 'Mg':'Mg', 'MG':'Mg', 'P':'P',
        'SA':'S', 'S':'S', 'Cl':'Cl', 'CL':'Cl', 'Ca':'Ca', 'CA':'Ca',
        'Mn':'Mn', 'MN':'Mn', 'Fe':'Fe', 'FE':'Fe', 'Zn':'Zn', 'ZN':'Zn',
        'Br':'Br', 'BR':'Br', 'I':'I', 'W':'O'} 
    atom = atoms.Atom(ad2el[atype], (x,y,z))

    # residue info
    name        = line      [12:16].strip()     # atom name
    resName     = line      [17:20].strip()     # Residue name
    resNum      = spaceint(line[22:26])    # Residue number
    chain       = line      [21:22].strip()     # chain
    resinfo = atoms.RESinfo(name, resName, resNum, chain)

    # pdb info
    keyword   = line[ 0: 6]     
    serial    = spaceint(line[ 6:11]) 
    pdbinfo = atoms.PDBinfo(keyword, serial, 
        occupancy   = spacefloat(line[54:60]),
        bfact       = spacefloat(line[60:66]),
        altloc      = line[16:17],
        icode       = line[26:27],
        formalcharge = '  ')

    # atype, charge
    mm = atoms.MM(atype, float(line[70:76]))

    # return
    atom.set_mm(mm)
    atom.set_resinfo(resinfo)
    atom.set_pdbinfo(pdbinfo)
    return atom