Skip to content

Commit

Permalink
Don't include unmatched sites as missing
Browse files Browse the repository at this point in the history
  • Loading branch information
WillHannon-MCB committed Apr 2, 2024
1 parent fbf3a1f commit 964cd18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
14 changes: 8 additions & 6 deletions configure_dms_viz/configure_dms_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions configure_dms_viz/pdb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 964cd18

Please sign in to comment.