Returns a tuple with the sequential indices of the sites
        that contain an element with the given chemical symbol.
551270
def indices_from_symbol(self, symbol: str) -> tuple:
        
        return tuple((i for i, specie in enumerate(self.species)
                      if specie.symbol == symbol))
952913
def get_atoms(structure, **kwargs):
        
        if not structure.is_ordered:
            raise ValueError("ASE Atoms only supports ordered structures")
        symbols = [str(site.specie.symbol) for site in structure]
        positions = [site.coords for site in structure]
        cell = structure.lattice.matrix
        return Atoms(symbols=symbols, positions=positions, pbc=True,
                     cell=cell, **kwargs)
584519
public static String getChemicalSeries(String symbol) {
        Elements e = Elements.ofString(symbol);
        for (Series s : Series.values())
            if (s.contains(e)) return s.name();
        return null;
    }
580175
def nelect(self):
        
        # if structure is not sorted this can cause problems, so must take
        # care to remove redundant symbols when counting electrons
        site_symbols = list(set(self.poscar.site_symbols))
        nelect = 0.
        for ps in self.potcar:
            if ps.element in site_symbols:
                site_symbols.remove(ps.element)
                nelect += self.structure.composition.element_composition[
                              ps.element] * ps.ZVAL

        if self.use_structure_charge:
            return nelect - self.structure.charge
        else:
            return nelect
1158378
def all_combinations_for_elements(self, element_symbols):
        
        d = OrderedDict()
        for symbol in element_symbols:
            d[symbol] = self.select_symbols(symbol, ret_list=True)

        from itertools import product
        return list(product(*d.values()))
993797
def sites_at_edges( self ):
        
        min_x = min( [ s.r[0] for s in self.sites ] )
        max_x = max( [ s.r[0] for s in self.sites ] )
        min_y = min( [ s.r[1] for s in self.sites ] )
        max_y = max( [ s.r[1] for s in self.sites ] )
        min_z = min( [ s.r[2] for s in self.sites ] )
        max_z = max( [ s.r[2] for s in self.sites ] )
        x_max = [ s for s in self.sites if s.r[0] == min_x ]
        x_min = [ s for s in self.sites if s.r[0] == max_x ]
        y_max = [ s for s in self.sites if s.r[1] == min_y ]
        y_min = [ s for s in self.sites if s.r[1] == max_y ]
        z_max = [ s for s in self.sites if s.r[2] == min_z ]
        z_min = [ s for s in self.sites if s.r[2] == max_z ]
        return ( x_max, x_min, y_max, y_min, z_max, z_min )
931350
function () {
			if (sequence) {
				var localNodes = sequence.nodes;
				var localIndex = (localNodes) ? localNodes.indexOf(node) : null;

				if (localNodes) {
					if (localIndex === (localNodes.length - 1)) {
						return sequence.sequences || [];
					} else {
						return [];
					}
				}
			}
		}
525667
def select_atoms(indices):
    '''

    '''
    rep = current_representation()
    rep.select({'atoms': Selection(indices, current_system().n_atoms)})
    return rep.selection_state
1299613
def sequence(self):
        
        seq = [x.mol_code for x in self._monomers]
        return ' '.join(seq)
939041
def pseudos_with_symbols(self, symbols):
        
        pseudos = self.select_symbols(symbols, ret_list=True)
        found_symbols = [p.symbol for p in pseudos]
        duplicated_elements = [s for s, o in collections.Counter(found_symbols).items() if o > 1]

        if duplicated_elements:
            raise ValueError("Found multiple occurrences of symbol(s) %s" % ', '.join(duplicated_elements))
        missing_symbols = [s for s in symbols if s not in found_symbols]

        if missing_symbols:
            raise ValueError("Missing data for symbol(s) %s" % ', '.join(missing_symbols))

        return pseudos
171056
def get_octahedra(self, atoms, periodicity=3):
        '''
        
        '''
        octahedra = []
        for n, i in enumerate(atoms):
            found = []
            if i.symbol in Perovskite_Structure.B:
                for m, j in enumerate(self.virtual_atoms):
                    if j.symbol in Perovskite_Structure.C and self.virtual_atoms.get_distance(n, m) <= self.OCTAHEDRON_BOND_LENGTH_LIMIT:
                        found.append(m)

            if (periodicity == 3 and len(found) == 6) or (periodicity == 2 and len(found) in [5, 6]):
                octahedra.append([n, found])

        if not len(octahedra): raise ModuleError("Cannot extract valid octahedra: not enough corner atoms found!")
        return octahedra
417123
def get_indices():
    
    doc = BeautifulSoup(urlopen(BASEURL))

    divs = doc.select('.indices_txt')
    if not divs:
        return None

    sibling = divs[1].nextSibling
    if not sibling:
        return None

    data = sibling.nextSibling
    if not data:
        return None

    # the indices are in an HTML comment
    data = BeautifulSoup(data)

    divs = data.select('.selected')
    return map(lambda d: int(d.text), divs)
877306
def discrete_index(self, indices):
        
        elements = []
        for i in indices:
            elements.append(self[i])
        return elements
217928
def chemicals(self):
        
        path = ['enhancement', 'chemicalgroup', 'chemicals']
        items = listify(chained_get(self._head, path, []))
        chemical = namedtuple('Chemical', 'source chemical_name cas_registry_number')
        out = []
        for item in items:
            for chem in listify(item['chemical']):
                number = chem.get('cas-registry-number')
                try:  # Multiple numbers given
                    num = ";".join([n['$'] for n in number])
                except TypeError:
                    num = number
                new = chemical(source=item['@source'], cas_registry_number=num,
                               chemical_name=chem['chemical-name'])
                out.append(new)
        return out or None
1232460
def get_pmeshes(self, sites, permutation=None):
        
        pmeshes = []
        # _vertices = [site.coords for site in sites]
        if permutation is None:
            _vertices = [site.coords for site in sites]
        else:
            _vertices = [sites[ii].coords for ii in permutation]
        _face_centers = []
        number_of_faces = 0
        for face in self._faces:
            if len(face) in [3, 4]:
                number_of_faces += 1
            else:
                number_of_faces += len(face)

            _face_centers.append(np.array([np.mean([_vertices[face_vertex][ii]
                                                    for face_vertex in face])
                                           for ii in range(3)]))

        out = '{}\n'.format(len(_vertices) + len(_face_centers))
        for vv in _vertices:
            out += '{:15.8f} {:15.8f} {:15.8f}\n'.format(vv[0], vv[1], vv[2])
        for fc in _face_centers:
            out += '{:15.8f} {:15.8f} {:15.8f}\n'.format(fc[0], fc[1], fc[2])
        out += '{:d}\n'.format(number_of_faces)
        for iface, face in enumerate(self._faces):
            if len(face) == 3:
                out += '4\n'
            elif len(face) == 4:
                out += '5\n'
            else:
                for ii in range(len(face)):
                    out += '4\n'
                    out += '{:d}\n'.format(len(_vertices) + iface)
                    out += '{:d}\n'.format(face[ii])
                    out += '{:d}\n'.format(face[np.mod(ii + 1, len(face))])
                    out += '{:d}\n'.format(len(_vertices) + iface)
            if len(face) in [3, 4]:
                for face_vertex in face:
                    out += '{:d}\n'.format(face_vertex)
                out += '{:d}\n'.format(face[0])
        pmeshes.append({"pmesh_string": out})
        return pmeshes
796743
def add_oxidation_state_by_site_fraction(structure, oxidation_states):
        
        try:
            for i, site in enumerate(structure):
                new_sp = collections.defaultdict(float)
                for j, (el, occu) in enumerate(get_z_ordered_elmap(site
                        .species)):
                    specie = Specie(el.symbol, oxidation_states[i][j])
                    new_sp[specie] += occu
                structure[i] = new_sp
            return structure
        except IndexError:
            raise ValueError("Oxidation state of all sites must be "
                             "specified in the list.")
337135
def _get_indices(self, element, labels='all', mode='or'):
        
        """
        # Parse and validate all input values.
        element = self._parse_element(element, single=True)
        labels = self._parse_labels(labels=labels, element=element)
        if element+'.all' not in self.keys():
            raise Exception('Cannot proceed without {}.all'.format(element))

        # Begin computing label array
        if mode in ['or', 'any', 'union']:
            union = sp.zeros_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                union = union + self[element+'.'+item.split('.')[-1]]
            ind = union
        elif mode in ['and', 'all', 'intersection']:
            intersect = sp.ones_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                intersect = intersect*self[element+'.'+item.split('.')[-1]]
            ind = intersect
        elif mode in ['xor', 'exclusive_or']:
            xor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xor = xor + sp.int8(info)
            ind = (xor == 1)
        elif mode in ['nor', 'not', 'none']:
            nor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nor = nor + sp.int8(info)
            ind = (nor == 0)
        elif mode in ['nand']:
            nand = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nand = nand + sp.int8(info)
            ind = (nand < len(labels)) * (nand > 0)
        elif mode in ['xnor', 'nxor']:
            xnor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xnor = xnor + sp.int8(info)
            ind = (xnor > 1)
        else:
            raise Exception('Unsupported mode: '+mode)
        # Extract indices from boolean mask
        ind = sp.where(ind)[0]
        ind = ind.astype(dtype=int)
        return ind