Skip to content

Commit

Permalink
Update fingerprint.py
Browse files Browse the repository at this point in the history
adjusted to have the metadata under the WaterBridge key with addition of _ligand_water and _water_protein additions
  • Loading branch information
talagayev authored Nov 14, 2024
1 parent bd61970 commit df3c1ba
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions prolif/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,18 +1090,26 @@ def run_bridged_analysis(self, traj, lig, prot, water, **kwargs):

# Merge data from ifp1 and ifp2 for each matching pair
for (lig_res, prot_res), interaction_data_ifp2 in matching_entries.items():
# Combine keys from both ifp1 and ifp2
all_keys = set(interaction_data_ifp1.keys()).union(interaction_data_ifp2.keys())
combined_interaction_data = {}

# Add merged values or single values if unique
for key in all_keys:
values_ifp1 = interaction_data_ifp1.get(key, "")
values_ifp2 = interaction_data_ifp2.get(key, "")
# Combine the values if both are present, otherwise take the single value
combined_interaction_data[key] = f"{values_ifp1};{values_ifp2}" if values_ifp1 and values_ifp2 else values_ifp1 or values_ifp2
# Prepare merged interaction data under a single key "WaterBridge"
combined_interaction_data["WaterBridge"] = {}

# Store the combined interaction data
# Collect and merge metadata for `ifp1` (ligand-water) interactions
for interaction_type, metadata_list in interaction_data_ifp1.items():
for metadata in metadata_list:
for key, value in metadata.items():
combined_key = f"{key}_ligand_water"
combined_interaction_data["WaterBridge"][combined_key] = value

# Collect and merge metadata for `ifp2` (water-protein) interactions
for interaction_type, metadata_list in interaction_data_ifp2.items():
for metadata in metadata_list:
for key, value in metadata.items():
combined_key = f"{key}_water_protein"
combined_interaction_data["WaterBridge"][combined_key] = value

# Store the combined interaction data for the (lig_res, prot_res) pair in `ifp`
ifp.update({(lig_res, prot_res): combined_interaction_data})

combined[frame1] = ifp
Expand Down

0 comments on commit df3c1ba

Please sign in to comment.