def _collect(self, lines):
        """ This routine reads the following from the Siesta file:
            - atomic positions
            - cell_parameters
            - atomic_species
        """
        for tag,value,unit in re.findall(
                '([\.A-Za-z]+)\s+%s\s+([A-Za-z]+)?' %
                self._num_regex,lines):
            tag = tag.lower()
            unit = unit.lower()
            if tag == "latticeconstant":
                self._tags['latticeconstantunit'] = unit.capitalize()
                if unit == 'ang':
                    self._tags[tag] = float(value) / Bohr
                elif unit == 'bohr':
                    self._tags[tag] = float(value)
                else:
                    raise ValueError('Unknown LatticeConstant unit: {}'.format(unit))

        for tag,value in re.findall('([\.A-Za-z]+)[ \t]+([a-zA-Z]+)',lines):
            tag = tag.replace('_','').lower()
            if tag == "atomiccoordinatesformat":
                self._tags[tag] = value.strip().lower() 

        #check if the necessary tags are present
        self.check_present('atomiccoordinatesformat')
        acell = self._tags['latticeconstant']

        #capture the blocks
        blocks = re.findall(
            '%block\s+([A-Za-z_]+)\s((?:.+\n)+?(?=(?:\s+)?%endblock))',
            lines, re.MULTILINE)
        for tag,block in blocks:
            tag = tag.replace('_','').lower()
            if   tag == "chemicalspecieslabel":
                lines = block.split('\n')[:-1]
                self._tags["atomicnumbers"] = dict([map(int,species.split()[:2])
                                                    for species in lines])
                self._tags[tag] = dict(
                    [(lambda x: (x[2],int(x[0])))(species.split())
                     for species in lines])
            elif tag == "latticevectors":
                self._tags[tag] = [[ float(v)*acell for v in vector.split()]
                                   for vector in block.split('\n')[:3]]
            elif tag == "atomiccoordinatesandatomicspecies":
                lines = block.split('\n')[:-1]
                self._tags["atomiccoordinates"] = [
                    [float(x)  for x in atom.split()[:3]] for atom in lines]
                self._tags["atomicspecies"] = [int(atom.split()[3])
                                               for atom in lines]
       
        #check if the block are present
        self.check_present("atomicspecies")
        self.check_present("atomiccoordinates")
        self.check_present("latticevectors")
        self.check_present("chemicalspecieslabel")
            
        #translate the atomicspecies to atomic numbers
        self._tags["atomicnumbers"] = [self._tags["atomicnumbers"][atype]
                                       for atype in self._tags["atomicspecies"]]
def _collect ( self , lines ) : for tag , value , unit in re . findall ( '([\.A-Za-z]+)\s+%s\s+([A-Za-z]+)?' % self . _num_regex , lines ) : tag = tag . lower ( ) unit = unit . lower ( ) if tag == "latticeconstant" : self . _tags [ 'latticeconstantunit' ] = unit . capitalize ( ) if unit == 'ang' : self . _tags [ tag ] = float ( value ) / Bohr elif unit == 'bohr' : self . _tags [ tag ] = float ( value ) else : raise ValueError ( 'Unknown LatticeConstant unit: {}' . format ( unit ) ) for tag , value in re . findall ( '([\.A-Za-z]+)[ \t]+([a-zA-Z]+)' , lines ) : tag = tag . replace ( '_' , '' ) . lower ( ) if tag == "atomiccoordinatesformat" : self . _tags [ tag ] = value . strip ( ) . lower ( ) self . check_present ( 'atomiccoordinatesformat' ) acell = self . _tags [ 'latticeconstant' ] blocks = re . findall ( '%block\s+([A-Za-z_]+)\s((?:.+\n)+?(?=(?:\s+)?%endblock))' , lines , re . MULTILINE ) for tag , block in blocks : tag = tag . replace ( '_' , '' ) . lower ( ) if tag == "chemicalspecieslabel" : lines = block . split ( '\n' ) [ : - 1 ] self . _tags [ "atomicnumbers" ] = dict ( [ map ( int , species . split ( ) [ : 2 ] ) for species in lines ] ) self . _tags [ tag ] = dict ( [ ( lambda x : ( x [ 2 ] , int ( x [ 0 ] ) ) ) ( species . split ( ) ) for species in lines ] ) elif tag == "latticevectors" : self . _tags [ tag ] = [ [ float ( v ) * acell for v in vector . split ( ) ] for vector in block . split ( '\n' ) [ : 3 ] ] elif tag == "atomiccoordinatesandatomicspecies" : lines = block . split ( '\n' ) [ : - 1 ] self . _tags [ "atomiccoordinates" ] = [ [ float ( x ) for x in atom . split ( ) [ : 3 ] ] for atom in lines ] self . _tags [ "atomicspecies" ] = [ int ( atom . split ( ) [ 3 ] ) for atom in lines ] self . check_present ( "atomicspecies" ) self . check_present ( "atomiccoordinates" ) self . check_present ( "latticevectors" ) self . check_present ( "chemicalspecieslabel" ) self . _tags [ "atomicnumbers" ] = [ self . _tags [ "atomicnumbers" ] [ atype ] for atype in self . _tags [ "atomicspecies" ] ]
This routine reads the following from the Siesta file:
            - atomic positions
            - cell_parameters
            - atomic_species