Return the absorbing atom symboll and site index in the given structure.

    Args:
        absorbing_atom (str/int): symbol or site index
        structure (Structure)

    Returns:
        str, int: symbol and site index
967093
def get_absorbing_atom_symbol_index(absorbing_atom, structure):
    
    if isinstance(absorbing_atom, str):
        return absorbing_atom, structure.indices_from_symbol(absorbing_atom)[0]
    elif isinstance(absorbing_atom, int):
        return str(structure[absorbing_atom].specie), absorbing_atom
    else:
        raise ValueError("absorbing_atom must be either specie symbol or site index")
1355653
def structure_repr(self):
        
        ret = '{%s}' % ', '.join([str(x) for x in self.elements])
        return self._wrap_packed(ret)
1366754
def site_symbols(self):
        
        syms = [site.specie.symbol for site in self.structures[0]]
        return [a[0] for a in itertools.groupby(syms)]
513414
def parse_atom_tag_data(self, name, tag_content):
        ''''''
        current_atom_site = self.current_atom_site
        if current_atom_site.IsHETATM:
            # Early out - do not parse HETATM records
            return

        elif name == 'PDBx:atom_site':
            # We have to handle the atom_site close tag here since we jump based on self._BLOCK first in end_element

            #'''Add the residue to the residue map.'''
            self._BLOCK = None
            current_atom_site = self.current_atom_site
            current_atom_site.validate()
            if current_atom_site.IsATOM:
                # Only parse ATOM records
                r, seqres, ResidueAA, Residue3AA = current_atom_site.convert_to_residue(self.modified_residues)
                if r:
                    if not(self.pdb_id in cases_with_ACE_residues_we_can_ignore and Residue3AA == 'ACE'):
                        # skip certain ACE residues
                        full_residue_id = str(r)
                        if self._residues_read.get(full_residue_id):
                            assert(self._residues_read[full_residue_id] == (r.ResidueAA, seqres))
                        else:
                            self._residues_read[full_residue_id] = (r.ResidueAA, seqres)
                            self._residue_map[r.Chain] = self._residue_map.get(r.Chain, {})
                            assert(type(seqres) == int_type)
                            self._residue_map[r.Chain][str(r)] = seqres

        # Record type
        elif name == 'PDBx:group_PDB':
            # ATOM or HETATM
            if tag_content == 'ATOM':
                current_atom_site.IsATOM = True
            elif tag_content == 'HETATM':
                current_atom_site.IsHETATM = True
            else:
                raise Exception("PDBx:group_PDB was expected to be 'ATOM' or 'HETATM'. '%s' read instead." % tag_content)

        # Residue identifier - chain ID, residue ID, insertion code
        elif name == 'PDBx:auth_asym_id':
            assert(not(current_atom_site.PDBChainID))
            current_atom_site.PDBChainID = tag_content
            if not tag_content:
                assert(current_atom_site.PDBChainIDIsNull)
                if self.pdb_id.upper() == '2MBP':
                    current_atom_site.PDBChainID = 'A' # e.g. 2MBP
                else:
                    current_atom_site.PDBChainID = ' '

        elif name == 'PDBx:auth_seq_id':
            assert(not(current_atom_site.ATOMResidueID))
            current_atom_site.ATOMResidueID = int(tag_content)
        elif name == "PDBx:pdbx_PDB_ins_code":
            if current_atom_site.ATOMResidueiCodeIsNull:
                assert(len(tag_content) == 0)
            else:
                assert(current_atom_site.ATOMResidueiCode == ' ')
                current_atom_site.ATOMResidueiCode = tag_content
        elif name == "PDBx:auth_comp_id":
            assert(not(current_atom_site.ATOMResidueAA))
            current_atom_site.ATOMResidueAA = tag_content

        elif name == "PDBx:label_seq_id":
            assert(not(current_atom_site.SEQRESIndex))
            current_atom_site.SEQRESIndex = int(tag_content)
        elif name == "PDBx:label_comp_id":
            assert(not(current_atom_site.ATOMSeqresResidueAA))
            current_atom_site.ATOMSeqresResidueAA = tag_content
123617
def element(i)
      unless i.matched?
        unless (0 ... shape.last).member? i
          raise "Index must be in 0 ... #{shape.last} (was #{i})"
        end
        i = INT.new i
      end
      i.size = @index.size if i.is_a?(Variable) and @index.size.get
      @term.subst @index => i
    end
525667
def select_atoms(indices):
    '''

    '''
    rep = current_representation()
    rep.select({'atoms': Selection(indices, current_system().n_atoms)})
    return rep.selection_state
957521
private static double getRmsd(Atom[] catmp1, Atom[] catmp2) throws StructureException{

		Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(catmp1),
				Calc.atomsToPoints(catmp2));

		Calc.transform(catmp2, trans);

		//   if ( showAlig) {
		//      StructureAlignmentJmol jmol = new StructureAlignmentJmol();
		//      jmol.setTitle("AFPCHainer: getRmsd" + rmsd);
		//
		//      Chain c1 = new ChainImpl();
		//      c1.setName("A");
		//      for ( Atom a : catmp1){
		//         c1.addGroup(a.getParent());
		//      }
		//
		//      Chain c2 = new ChainImpl();
		//      c2.setName("B");
		//      for ( Atom a : catmp2){
		//         c2.addGroup(a.getParent());
		//      }
		//
		//      Structure fake = new StructureImpl();
		//      fake.setPDBCode("AFPCHainer: getRmsd" + rmsd);
		//      List<Chain> model1 = new ArrayList<Chain>();
		//      model1.add(c1);
		//      List<Chain> model2 = new ArrayList<Chain>();
		//      model2.add(c2);
		//      fake.addModel(model1);
		//      fake.addModel(model2);
		//      fake.setNmr(true);
		//
		//      jmol.setStructure(fake);
		//      jmol.evalString("select *; backbone 0.4; wireframe off; spacefill off; " +
		//      "select not protein and not solvent; spacefill on;");
		//      jmol.evalString("select */1 ; color red; model 1; ");
		//
		//      // now show both models again.
		//      jmol.evalString("model 0;");
		//   }

		return Calc.rmsd(catmp1,catmp2);
	}
1051830
def get_structure_with_only_magnetic_atoms(self, make_primitive=True):
        

        sites = [site for site in self.structure if abs(site.properties["magmom"]) > 0]

        structure = Structure.from_sites(sites)

        if make_primitive:
            structure = structure.get_primitive_structure(use_site_props=True)

        return structure
1042621
def parse_atoms(self, pdb):
    """"""
    
    atomre = re.compile("ATOM")
    
    atomlines = [line for line in pdb.lines if atomre.match(line)]
    
    chainresnums = {}
    
    for line in atomlines:
      chain = line[21]
      resname = line[17:20]
      resnum = line[22:27]
      #print resnum
      chainresnums.setdefault(chain, [])
      
      if resnum in chainresnums[chain]:
        assert self[chain][chainresnums[chain].index(resnum)] == resname
      else:
        if resnum[-1] == ' ':
          self.setdefault(chain, [])
          self[chain] += [resname]
          chainresnums[chain] += [resnum]
    
    return chainresnums
922878
def get_element_dos(self):
        

        el_dos = {}
        for site, atom_dos in self.pdos.items():
            el = site.specie
            for pdos in atom_dos.values():
                if el not in el_dos:
                    el_dos[el] = pdos
                else:
                    el_dos[el] = add_densities(el_dos[el], pdos)
        return {el: Dos(self.efermi, self.energies, densities)
                for el, densities in el_dos.items()}
800061
def get_covalent_bonds(self, tol=0.2):
        
        bonds = []
        for site1, site2 in itertools.combinations(self._sites, 2):
            if CovalentBond.is_bonded(site1, site2, tol):
                bonds.append(CovalentBond(site1, site2))
        return bonds
168258
def natoms(self):
        
        syms = [site.specie.symbol for site in self.structures[0]]
        return [len(tuple(a[1])) for a in itertools.groupby(syms)]
92702
def get_atom_map(structure):
    
    syms = [site.specie.symbol for site in structure]
    unique_pot_atoms = []
    [unique_pot_atoms.append(i) for i in syms if not unique_pot_atoms.count(i)]
    atom_map = {}
    for i, atom in enumerate(unique_pot_atoms):
        atom_map[atom] = i + 1
    return atom_map
805338
def _describe_atom(topology, index):
    
    at = topology.atom(index)
    if topology.n_chains > 1:
        return "%s %i %s %i %i" % (at.residue.name, at.residue.resSeq, at.name, at.index, at.residue.chain.index )
    else:
        return "%s %i %s %i"    % (at.residue.name, at.residue.resSeq, at.name, at.index)
1370326
def get_structure_with_nodes(self):
        
        new_s = Structure.from_sites(self.structure)
        for v in self.vnodes:
            new_s.append("X", v.frac_coords)
        return new_s
134330
def getAtomChars(t):
    
    s = c_char_p()
    if PL_get_atom_chars(t, byref(s)):
        return s.value
    else:
        raise InvalidTypeError("atom")
361888
def _parse(self):
        
        
        atom_counter = 0
        
        structure_build = self.structure_builder
        
        residues = self._extract_residues()
        
        cur_model = None
        cur_chain = None
        structure_build.init_seg(' ') # There is never a SEGID present
        
        for r in residues:

            # New model?
            if cur_model != r['model']:
                cur_model = r['model']
                try:
                    structure_build.init_model(cur_model)
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r) 
            
            # New chain?
            if cur_chain != r['chain']:
                cur_chain = r['chain']
                try:
                    structure_build.init_chain(cur_chain)
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r)

            # Create residue
            if r['name'] in AA_LIST: # Get residue type crudely since there is no HETATM / ATOM
                hetero_flag = ' '
            elif r['name'] == 'WAT' or r['name'] == 'HOH':
                hetero_flag = 'W'
            else:
                hetero_flag = 'H'
            
            # Some terminal atoms are added at residue 0. This residue has a small number of atoms.
            # Protonated non-terminal glycine has 7 atoms. Any of these residues is smaller.
            # HETATMs have only a couple of atoms (3 for water for example) and they are ok.
            
            if (len(r['atoms']) >= 7) or (hetero_flag != " "):
                try:
                    structure_build.init_residue(r['name'], hetero_flag, r['number'], r['icode'])
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r)
            
                # Create Atoms
                for atom in r['atoms']:
                    a = self._parse_atom(atom)

                    if not sum(a['coord']): # e.g. HG of metal bound CYS coords are 0,0,0.
                        continue
                        
                    try:
                        atom_counter += 1
                        # fullname = name; altloc is empty;
                        structure_build.init_atom(a['name'], a['coord'], a['bfactor'], a['occupancy'], ' ',
                                                    a['name'], atom_counter, a['element'],  hetero_flag)
                    except PDBConstructionException, message:
                        self._handle_builder_exception(message, r)      
            
            elif len(r['atoms']) < 7: # Terminal Residues
                                
                for atom in r['atoms']:
                    
                    a = self._parse_atom(atom)
                    
                    if not sum(a['coord']): # e.g. HG of metal bound CYS coords are 0,0,0.
                        continue

                    atom_counter += 1                    
                    ter_atom = Atom(a['name'], a['coord'], a['bfactor'], a['occupancy'], ' ',
                                    a['name'], atom_counter, a['element'], hetero_flag)
                    
                    if a['name'] in N_TERMINAL_ATOMS:
                        
                        inc_struct = self.structure_builder.get_structure()
                        for model in inc_struct:
                            for chain in model:
                                if chain.id == r['chain']:
                                    for residue in chain: # Find First residue matching name
                                        if residue.resname == r['name']:
                                            residue.add(ter_atom)
                                            break
                    
                    elif a['name'] in C_TERMINAL_ATOMS:

                        inc_struct = self.structure_builder.get_structure()
                        c_ter = None
                        for model in inc_struct:
                            for chain in model:
                                if chain.id == r['chain']:
                                    for residue in chain: # Find Last residue matching name
                                        if residue.resname == r['name']:
                                            c_ter = residue
                                    if c_ter:
                                        c_ter.add(ter_atom)