@classmethod
def from_cut3d_outfile(cls, filepath, structure):
    """
        Generates a HirshfeldCharges object from the outputfile of cut3d and a structure.
        """
    electron_charges = []
    reference_charges = []
    with open(filepath, 'rt') as f:
        lines = f.readlines()
    start_hirshfeld_i = None
    for i, l in enumerate(lines):
        if 'Hirshfeld analysis' in l:
            start_hirshfeld_i = i + 3
            break
    else:
        raise RuntimeError('The file does not contain Hirshfeld charges')
    for i in range(start_hirshfeld_i, start_hirshfeld_i + len(structure)):
        l = lines[i]
        electron_charges.append(float(l.split()[2]))
        reference_charges.append(-float(l.split()[1]))
    return cls(electron_charges, structure, reference_charges)
