Example #1
0
 def read(self, feature, *args, **kwargs):
     if feature == 'molecular orbitals':
         n = args[0]
         basis_functions = self.data.gbasis
     if feature == 'molecule':
         # Angstrom to nanometers
         # CJS added option to get molecule from steps of optimisation
         # or optimisations for PES scans
         # TODO error checking
         if kwargs.has_key('step'):
             return Molecule.from_arrays(
                 r_array=self.data.atomcoords[kwargs['step']] / 10,
                 type_array=np.array(
                     [symbols[a] for a in self.data.atomnos]))
         elif kwargs.has_key('scan'):
             return Molecule.from_arrays(
                 r_array=self.data.scancoords[kwargs['scan']] / 10,
                 type_array=np.array(
                     [symbols[a] for a in self.data.atomnos]))
         else:
             return Molecule.from_arrays(
                 r_array=self.data.atomcoords[-1] / 10,
                 type_array=np.array(
                     [symbols[a] for a in self.data.atomnos]))
     else:
         return getattr(self.data, feature)
Example #2
0
def test_residue():
    
    m = Molecule.from_arrays(type_array=['H', 'H', 'H', 'O', 'O'], 
                             residue_name=['VAL', 'ALA'],
                             maps={('atom', 'residue'): [0, 0, 0, 1, 1]})
    assert_npequal(m.sub(residue_index=0).type_array, ['H', 'H', 'H'])
    
    s = System([m, m])
    assert_npequal(s.maps['atom', 'residue'].value, [0, 0, 0, 1, 1, 2, 2, 2, 3, 3])
Example #3
0
def test_random_lattice():
    '''Testing random made box'''
    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])
    wat = Molecule.from_arrays(type_array=['O', 'H', 'H'])

    s = random_lattice_box([na, cl, wat], [160, 160, 160], [4, 4, 4])
    eq_(s.dimensions['molecule'], 160 * 3)
    eq_(s.dimensions['atom'], 160 * 5)
Example #4
0
def test_random_lattice():
    '''Testing random made box'''
    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])
    wat = Molecule.from_arrays(type_array=['O', 'H', 'H'])

    s = random_lattice_box([na, cl, wat], [160, 160, 160], [4, 4, 4])
    eq_(s.dimensions['molecule'], 160 * 3)
    eq_(s.dimensions['atom'], 160 * 5)
Example #5
0
def test_residue():

    m = Molecule.from_arrays(type_array=['H', 'H', 'H', 'O', 'O'],
                             residue_name=['VAL', 'ALA'],
                             maps={('atom', 'residue'): [0, 0, 0, 1, 1]})
    assert_npequal(m.sub(residue_index=0).type_array, ['H', 'H', 'H'])

    s = System([m, m])
    assert_npequal(s.maps['atom', 'residue'].value,
                   [0, 0, 0, 1, 1, 2, 2, 2, 3, 3])
Example #6
0
def split_groups(mol):
    groups = []
    unselected = [x for x in range(mol.n_atoms)]
    while len(unselected) > 0:
        new_atoms = set()
        new_atoms.add(unselected[0])
        atoms = []
        new_bonds = []
        new_bond_orders = []
        while len(new_atoms) > 0:
            a = list(new_atoms)[0]
            atoms.append(a)
            new_atoms.remove(a)

            for bond_index, bond in enumerate(mol.bonds):
                if atoms[-1] == bond[0] and bond[1] not in atoms:
                    new_atoms.add(bond[1])
                if atoms[-1] == bond[1] and bond[0] not in atoms:
                    new_atoms.add(bond[0])
                if a in bond and bond.tolist() not in new_bonds:
                    new_bonds.append(bond.tolist())
                    new_bond_orders.append(mol.bond_orders[bond_index])
        atoms.sort()
        groups.append([atoms, new_bonds, new_bond_orders])
        unselected = [x for x in range(mol.n_atoms) if x not in sum([y[0] for y in groups],[])]
    molecules = []
    for group in groups:
        new_bonds_reduced = np.array([[group[0].index(x[0]), group[0].index(x[1])] for x in group[1]])
        numpy_vectors = [system.r_array[x] for x in group[0]]
        new_molecule = Molecule.from_arrays(r_array=np.array(numpy_vectors),
                                            type_array=system.type_array[a],
                                            bonds=new_bonds_reduced,
                                            bond_orders=group[2]
                                            )
        new_molecule.export['vectors'] = numpy_vectors
        molecules.append(new_molecule)
    return molecules