def get_energy()

in data/contact_map_utils.py [0:0]


def get_energy(pdb_file_path):
    """Get total pose energy from a PDB file.

    Args:
        pdb_file_path: String. Path to the pdb file.

    Return:
        Energy score.

    """
    if pdb_file_path.endswith(".pdb.gz"):
        pdb_file = gunzip_to_ram(pdb_file_path)
    else:
        pdb_file = open(pdb_file_path, "r")

    parse = False
    score = None
    for line in pdb_file:
        if line.startswith("#BEGIN_POSE_ENERGIES_TABLE"):
            parse = True
        if parse and line.startswith("pose"):
            score = float(line.strip().split()[-1])
    return score