From 64ad1711a2e526de18f544be8d672349a14dfedf Mon Sep 17 00:00:00 2001 From: Alejandro Velez-Arce Date: Tue, 3 Sep 2024 14:20:05 -0400 Subject: [PATCH 1/2] support all MPC datasets --- tdc/single_pred/mpc.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tdc/single_pred/mpc.py b/tdc/single_pred/mpc.py index c935b661..b8a28a09 100644 --- a/tdc/single_pred/mpc.py +++ b/tdc/single_pred/mpc.py @@ -22,8 +22,26 @@ def __init__(self, name, path="./data"): self.name = name self.data = None - def get_data(self): - from MoleculeACE import Data, Descriptors #TODO: support non-MoleculeACE + def get_from_gh(self, link): + import pandas as pd + import requests + import io + + data = requests.get(link) + try: + data.raise_for_status() + except: + raise Exception("invalid link provided. choose a link for datasets in https://github.com/bidd-group/MPCD") + self.data = pd.read_csv(io.StringIO(data.text)) + return self.data + + def get_data(self, link=None, get_from_gh=True): + if (not get_from_gh) and link is None: + raise Exception("provide dataset github link from https://github.com/bidd-group/MPCD") + elif get_from_gh: + return self.get_from_gh(link) + # support direct interfface with MoleculeACE API as well + from MoleculeACE import Data, Descriptors try: self.data = Data(self.name) self.data(Descriptors.SMILES) From 218e09a3d07d7cb256d2d8a1788b78686d7b25e8 Mon Sep 17 00:00:00 2001 From: Alejandro Velez-Arce Date: Tue, 3 Sep 2024 14:23:37 -0400 Subject: [PATCH 2/2] support all MPC datasets --- tdc/single_pred/mpc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tdc/single_pred/mpc.py b/tdc/single_pred/mpc.py index b8a28a09..a90358dd 100644 --- a/tdc/single_pred/mpc.py +++ b/tdc/single_pred/mpc.py @@ -31,13 +31,17 @@ def get_from_gh(self, link): try: data.raise_for_status() except: - raise Exception("invalid link provided. choose a link for datasets in https://github.com/bidd-group/MPCD") + raise Exception( + "invalid link provided. choose a link for datasets in https://github.com/bidd-group/MPCD" + ) self.data = pd.read_csv(io.StringIO(data.text)) return self.data def get_data(self, link=None, get_from_gh=True): if (not get_from_gh) and link is None: - raise Exception("provide dataset github link from https://github.com/bidd-group/MPCD") + raise Exception( + "provide dataset github link from https://github.com/bidd-group/MPCD" + ) elif get_from_gh: return self.get_from_gh(link) # support direct interfface with MoleculeACE API as well