Exemplo n.º 1
0
    def get_prochirality(self):
        """
        Determines whether its necessary to differentiate between
        two sides of the molecule. For example Protons in R-O-CH2-N-R.

        If the atom is prochiral, the side (re/si) is determined.
        """
        if self.element in halogens:
            self.prochiral = False
            return
        if self.invariom_name[1] is '@':
            self.prochiral = False
            if self.invariom_name[2] is '3':
                print('Warning! Approximating ADP in 3 membered ring for atom {}.'.format(self.name))
            return
        if not get_framework_neighbors(atom=self, useH=True):
            self.prochiral = False
            return
        neighbor0 = get_framework_neighbors(self, useH=True)
        if len(neighbor0) > 1:
            self.prochiral = False
            return
        neighbor0 = neighbor0[0]
        neighbors = [atom.element for atom in get_framework_neighbors(neighbor0,
                                                                          useH=True) if not atom == self]
        if any(self.element == i for i in neighbors):
            neighbors.remove(self.element)
            if not any(self.element == i for i in neighbors):
                if len(neighbors) > 1:
                    if not neighbors[0] == neighbors[1]:
                        self.prochiral = True
                        pos1 = self.cart
                        pos2 = neighbor0.cart
                        pos3 = cg.get_closest_atom_of_element(self.element, neighbor0, exclude=self).cart
                        plane_vector = cg.get_normal_vector_of_plane(pos1, pos2, pos3)
                        ref_element = max([proton_number[i] for i in neighbors])
                        ref_atom = cg.get_closest_atom_of_element(elementofnumber[ref_element], neighbor0,
                                                                  exclude=self)
                        ref_vector = neighbor0.cart - ref_atom.cart
                        ref_vector /= norm(ref_vector)
                        if dot(ref_vector, plane_vector) > 0:
                            self.side = 're'
                        else:
                            self.side = 'si'
                        return
        self.prochiral = False
Exemplo n.º 2
0
 def identify_molecules(self):
     """
     Takes an instance of the MOLECULE class as argument and returns a
     dictionary that keys an identifying integer to every atom name
     specifying which of the atoms in the molecule form an 'independent'
     molecule in the chemical sense.
     If all atoms are part of the same molecule, all atoms get the
     integer '0'.
     """
     blacklist = set()
     #===========================================================================
     # molecules=[]
     #===========================================================================
     self.ID = 0
     for atom1 in self.atoms:
         framework = []
         for atom2 in get_framework_neighbors(atom1):
             if not atom1.get_name() in blacklist and not atom2.get_name() in blacklist:
                 framework += framework_crawler(atom1, atom2)
                 framework += framework_crawler(atom2, atom1)
                 framework = list(set(framework))
                 [blacklist.add(atom.get_name()) for atom in framework]
                 #===============================================================
                 # molecules.append(framework)
                 #===============================================================
         if framework:
             chem_mol = framework
             for atom in framework:
                 atom.set_molecule_id(self.ID)
                 for h in get_framework_neighbors(atom, useH=True):
                     if h.get_element() == 'H':
                         h.set_molecule_id(self.ID)
                         chem_mol.append(h)
             self.ID += 1
             self.chem_mol.append(chem_mol)
     for atom in self.atoms:
         if atom.molecule_id == None:
             atom.set_molecule_id(self.ID)
             self.ID += 1
     return self.ID
Exemplo n.º 3
0
def iter_riding_hydrogen_atoms(atom):
    return atoms_of_element(get_framework_neighbors(atom=atom, useH=True))
Exemplo n.º 4
0
 def iter_bound_atoms(self):
     return get_framework_neighbors(self)
Exemplo n.º 5
0
 def averageADP(self):
     cartAdp = array([0]*6)
     for atom in get_framework_neighbors(self):
         cartAdp += atom.adp['cart_int']
     self.adp['cart_int'] = cartAdp