示例#1
0
文件: hbond.py 项目: lidaobing/itcc
def detect_donor(mol):
    '''detect_donor(mol) -> yield (H-idx, H's neighbour's idx)
    '''
    for idx, atom in enumerate(mol.atoms):
        if atom.no != 1:
            continue
        neighbours = tools.neighbours(mol, idx)
        neighbour = neighbours[0]
        if mol.atoms[neighbour].no in [7, 8, 16]:
            yield (idx, neighbour)
示例#2
0
文件: utils.py 项目: lidaobing/itcc
def sub_pyramid_check(fname, atoms):
    mol = read.readxyz(file(fname))
    if atoms is None:
        atoms = range(len(mol))
    res = []
    for atom in atoms:
        neis = neighbours(mol, atom)
        if len(neis) != 4:
            continue
        if is_pyramid(mol.coords[atom],
                      mol.coords[neis[0]],
                      mol.coords[neis[1]],
                      mol.coords[neis[2]],
                      mol.coords[neis[3]]):
            res.append(atom)
    return res
示例#3
0
文件: pdb.py 项目: lidaobing/itcc
def write(mol, ofile=sys.stdout, comment = None):
    if comment is None:
        comment = 'generated by itcc'
    if comment:
        ofile.write('HEADER    %s\n' % comment)
    for i in range(len(mol)):
        atom, coord = mol[i]
        ofile.write('%-6s%5i  %-3s %3s  %4i    %8.3f%8.3f%8.3f%6.2f%6.2f\n' %
                    ('HETATM', i+1, atom.symbol, 'UNK', 1,
                     coord[0], coord[1], coord[2], 1.0, 0.0))
    for i in range(len(mol)):
        ns = tools.neighbours(mol, i)
        if not ns: continue
        ofile.write('CONNECT %4i' % (i+1))
        for x in ns:
            ofile.write(' %4i' % (x+1))
        ofile.write('\n')
    ofile.write('END\n')
示例#4
0
 def test_1(self):
     mol = read.readxyz(StringIO.StringIO(test_methane_in))
     neighbours = tools.neighbours(mol, 0)
     neighbours.sort()
     neighbours = tuple(neighbours)
     self.assertEqual(neighbours, (1,2,3,4))