def global_pct_sim(segments):
    """
    Calculated as in global_pct_id(), but with the percent similarity field
    """
    match_length = 0
    similar_residues = 0
    for segment in segments:
        segment_length = abs(segment['contig_start'] - segment['contig_end']
            ) + 1
        match_length += segment_length
        matched_residues = segment_length * (segment['pct_sim'] / 100)
        similar_residues += matched_residues
    return similar_residues / match_length * 100
