def _parse_first_line(line, fname):
    """ parse the first line of the basis set

    :param line: the line string
    :param fname: the filename string
    :return: (atomic_number, basis_type, num_shells)
    """
    from aiida.common.exceptions import ParsingError
    first_line = line.strip().split()
    if not len(first_line) == 2:
        raise ParsingError(
            "The first line should contain only two fields: '{}' for file {}"
            .format(line, fname))
    atomic_number_str = first_line[0]
    if not atomic_number_str.isdigit():
        raise ParsingError(
            "The first field should be the atomic number '{}' for file {}".
            format(line, fname))
    anumber = int(atomic_number_str)
    atomic_number = None
    basis_type = None
    if anumber < 99:
        atomic_number = anumber
        basis_type = 'all-electron'
    elif 200 < anumber < 999:
        raise NotImplementedError(
            'valence electron basis sets not currently supported')
    elif anumber > 1000:
        atomic_number = anumber % 100
        basis_type = 'all-electron'
    if atomic_number is None:
        raise ParsingError('Illegal atomic number {} for file {}'.format(
            anumber, fname))
    num_shells_str = first_line[1]
    if not num_shells_str.isdigit():
        raise ParsingError(
            'The second field should be the number of shells {} for file {}'
            .format(line, fname))
    num_shells = int(num_shells_str)
    newline = '{0} {1}\n'.format(atomic_number if basis_type ==
        'all-electron' else 200 + atomic_number, num_shells)
    return atomic_number, basis_type, num_shells, newline
