def pdb_atom_parse(line):
    """
    Extract data from an ATOM or HETATM line.
    """
    if '\n' in line:
        line = line[:line.index('\n')]
    line = line.ljust(80)
    result = {}
    result['serial'] = int(line[6:11])
    result['name'] = line[12:16]
    result['altLoc'] = line[16]
    result['resName'] = line[17:20]
    result['chainID'] = line[21]
    result['resSeq'] = int(line[22:26])
    result['iCode'] = line[26]
    result['x'] = float(line[30:38]) * 0.1
    result['y'] = float(line[38:46]) * 0.1
    result['z'] = float(line[46:54]) * 0.1
    try:
        result['occupancy'] = float(line[54:60])
    except:
        result['occupancy'] = 1.0
    try:
        result['tempFactor'] = float(line[60:66])
    except:
        result['tempFactor'] = 0.0
    result['element'] = line[76:78].strip()
    if result['element'] == '':
        result['element'] = result['name'].lstrip(' 0123456789')[0]
    result['charge'] = line[78:80]
    return result
