diff --git a/experiments/chem_info/bulk_sims.py b/experiments/chem_info/bulk_sims.py index a83535918..f6ae9bbdd 100644 --- a/experiments/chem_info/bulk_sims.py +++ b/experiments/chem_info/bulk_sims.py @@ -29,8 +29,11 @@ top_indices = sorted(range(len(similarities)), key=lambda j: -similarities[j])[:6] # Include self top_neighbors = [ {"query_id": compound_ids[i], "neighbor_id": compound_ids[j], "similarity": similarities[j]} - for j in top_indices if compound_ids[j] != compound_ids[i] - ][:5] # Exclude self and limit to top 5 + for j in top_indices + if compound_ids[j] != compound_ids[i] + ][ + :5 + ] # Exclude self and limit to top 5 results.extend(top_neighbors) # Convert results to a DataFrame @@ -44,4 +47,4 @@ query_id = tox_df[id_column].iloc[1] query_neighbors_df = neighbors_df[neighbors_df["query_id"] == query_id] print(f"\nBULK: Neighbors for query ID {query_id}:") -print(query_neighbors_df) \ No newline at end of file +print(query_neighbors_df) diff --git a/experiments/chem_info/knn_sims.py b/experiments/chem_info/knn_sims.py index 3e768c57e..680577403 100644 --- a/experiments/chem_info/knn_sims.py +++ b/experiments/chem_info/knn_sims.py @@ -1,4 +1,3 @@ - # Workbench Imports from workbench.api.df_store import DFStore from workbench.utils.chem_utils import compute_morgan_fingerprints diff --git a/src/workbench/algorithms/graph/light/proximity_graph.py b/src/workbench/algorithms/graph/light/proximity_graph.py index 3af4a49d6..e65d39c53 100644 --- a/src/workbench/algorithms/graph/light/proximity_graph.py +++ b/src/workbench/algorithms/graph/light/proximity_graph.py @@ -107,10 +107,9 @@ def get_neighborhood(self, node_id: Union[str, int], radius: int = 1) -> nx.Grap if __name__ == "__main__": from workbench.algorithms.dataframe.fingerprint_proximity import FingerprintProximity from workbench.web_interface.components.plugins.graph_plot import GraphPlot - from workbench.api import FeatureSet, DFStore, GraphStore + from workbench.api import DFStore, GraphStore from workbench.utils.chem_utils import compute_morgan_fingerprints - # Example DataFrame for FeaturesProximity feature_data = { "id": [1, 2, 3, 4], @@ -174,7 +173,7 @@ def get_neighborhood(self, node_id: Union[str, int], radius: int = 1) -> nx.Grap # Now a real dataset with fingerprints """ - + from workbench.api import FeatureSet fs = FeatureSet("aqsol_mol_descriptors") df = fs.pull_dataframe() df = df.sample(1000) @@ -199,7 +198,6 @@ def get_neighborhood(self, node_id: Union[str, int], radius: int = 1) -> nx.Grap g_store.upsert("test/fingerprint_graph", nx_graph) """ - # Pull in the tox21 data tox_df = DFStore().get("/datasets/chem_info/tox21") tox_df = tox_df.sample(1000) diff --git a/src/workbench/repl/workbench_shell.py b/src/workbench/repl/workbench_shell.py index 33e928092..d7b263f3a 100644 --- a/src/workbench/repl/workbench_shell.py +++ b/src/workbench/repl/workbench_shell.py @@ -495,9 +495,10 @@ def switch_to_direct_meta(self): def get_meta(self): return self.meta - def plot_manager(self, data, plot_type: str="table", **kwargs): + def plot_manager(self, data, plot_type: str = "table", **kwargs): """Plot Manager for Workbench""" from workbench.web_interface.components.plugins import ag_table, graph_plot, scatter_plot + if plot_type == "table": # Check what type of data we have if isinstance(data, pd.DataFrame):