diff --git a/configure_dms_viz/configure_dms_viz.py b/configure_dms_viz/configure_dms_viz.py index bc69ace..1e2f758 100755 --- a/configure_dms_viz/configure_dms_viz.py +++ b/configure_dms_viz/configure_dms_viz.py @@ -618,23 +618,25 @@ def make_experiment_dictionary( if included_chains != "polymer": check_chains(get_structure(structure), included_chains.split(" ")) # Check that the wildtype residues are in the structure - perc_matching, perc_missing = check_wildtype_residues( - get_structure(structure), mut_metric_df, sitemap_df, excluded_chains + perc_matching, perc_missing, count_matching, count_missing = ( + check_wildtype_residues( + get_structure(structure), mut_metric_df, sitemap_df, excluded_chains + ) ) # Alert the user about the missing and matching residues if perc_matching < 0.5: color = "red" - message = f"Warning: Fewer than {perc_matching*100:.2F}% of the wildtype residues in the data match the corresponding residues in the structure." + message = f"Warning: Fewer than {perc_matching*100:.2F}% {count_matching} of the wildtype residues in the data match the corresponding residues in the structure." else: color = "yellow" - message = f"About {perc_matching*100:.2F}% of the wildtype residues in the data match the corresponding residues in the structure." + message = f"About {perc_matching*100:.2F}% {count_matching} of the wildtype residues in the data match the corresponding residues in the structure." click.secho(message=message, fg=color) if perc_missing >= 0.5: color = "red" - message = f"Warning: {perc_missing*100:.2F}% of the data sites are missing from the structure." + message = f"Warning: {perc_missing*100:.2F}% {count_missing} of the data sites are missing from the structure." else: color = "yellow" - message = f"About {perc_missing*100:.2F}% of the data sites are missing from the structure." + message = f"About {perc_missing*100:.2F}% {count_missing} of the data sites are missing from the structure." click.secho(message=message, fg=color) # Make a dictionary holding the experiment data diff --git a/configure_dms_viz/pdb_utils.py b/configure_dms_viz/pdb_utils.py index f12fd79..a62a099 100644 --- a/configure_dms_viz/pdb_utils.py +++ b/configure_dms_viz/pdb_utils.py @@ -197,8 +197,16 @@ def check_wildtype_residues(structure, mut_metric_df, sitemap_df, excluded_chain if site_not_in_structure and all(site_not_in_structure): missing_sites += 1 - # Calculate the matching and missing sites - total_matching_residues = matching_residues / total_sites + # How many residues match at sites present in the structure? + total_matching_residues = matching_residues / (total_sites - missing_sites) + total_matching_string = f"({matching_residues} of {total_sites - missing_sites})" + # How many sites in the data are missing in the structure? total_missing_sites = missing_sites / total_sites + total_missing_string = f"({missing_sites} of {total_sites})" - return (total_matching_residues, total_missing_sites) + return ( + total_matching_residues, + total_missing_sites, + total_matching_string, + total_missing_string, + )