code: def read_dftbp(filename):
      
  
      infile = open(filename, 'r')
  
      lines = infile.readlines()
  
      # remove any comments
      for ss in lines:
          if ss.strip().startswith('#'):
              lines.remove(ss)
  
      natoms = int(lines[0].split()[0])
      symbols = lines[1].split()
  
      if (lines[0].split()[1].lower() == 'f'):
          is_scaled = True
          scale_pos = 1
          scale_latvecs = dftbpToBohr
      else:
          is_scaled = False
          scale_pos = dftbpToBohr
          scale_latvecs = dftbpToBohr
  
      # assign positions and expanded symbols
      positions = []
      expaned_symbols = []
  
      for ii in range(2, natoms+2):
          lsplit = lines[ii].split()
  
          expaned_symbols.append(symbols[int(lsplit[1]) - 1])
          positions.append([float(ss)*scale_pos for ss in lsplit[2:5]])
  
      # origin is ignored, may be used in future
      origin = [float(ss) for ss in lines[natoms+2].split()]
  
      # assign coords of unitcell
      cell = []
  
      for ii in range(natoms+3, natoms+6):
          lsplit = lines[ii].split()
  
          cell.append([float(ss)*scale_latvecs for ss in lsplit[:3]])
      cell = np.array(cell)
  
      if is_scaled:
          atoms = Atoms(symbols=expaned_symbols,
                        cell=cell,
                        scaled_positions=positions)
      else:
          atoms = Atoms(symbols=expaned_symbols,
                        cell=cell,
                        positions=positions)
  
      return atoms
docs: Reads DFTB+ structure files in gen format.
  
      Args:
          filename: name of the gen-file to be read
  
      Returns:
          atoms: an object of the phonopy.Atoms class, representing the structure
          found in filename