Skip to content

Commit

Permalink
completed google lint. added torch dependencies to conda. tests pass.…
Browse files Browse the repository at this point in the history
… unskipped all but one.
  • Loading branch information
amva13 committed Mar 5, 2024
1 parent c30bb35 commit f42afa6
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 30 deletions.
5 changes: 5 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: tdc-conda-env
channels:
- conda-forge
- defaults
- pytorch
dependencies:
- dataclasses=0.8
- fuzzywuzzy=0.18.0
Expand All @@ -10,10 +11,14 @@ dependencies:
- python=3.9.13
- pip=23.3.1
- pandas=2.1.4
- pyg=2.5.0
- pytorch=2.2.1
- requests=2.31.0
- scikit-learn=1.3.0
- seaborn=0.12.2
- tqdm=4.65.0
- torchaudio=2.2.1
- torchvision=0.17.1
- pip:
- cellxgene-census==1.10.2
- rdkit==2023.9.5
Expand Down
6 changes: 5 additions & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
suite = loader.discover(start_dir)

runner = unittest.TextTestRunner()
runner.run(suite)
res = runner.run(suite)
if res.wasSuccessful():
print("All base tests passed")
else:
raise RuntimeError("Some base tests failed")
4 changes: 2 additions & 2 deletions tdc/test/dev_tests/chem_utils_test/test_molconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
print(os.getcwd())
pass

@unittest.skip("dev test")

def test_MolConvert(self):
from tdc.chem_utils import MolConvert

Expand All @@ -35,7 +35,7 @@ def test_MolConvert(self):

MolConvert.eligible_format()

# @unittest.skip("dev test")
#
def tearDown(self):
print(os.getcwd())

Expand Down
4 changes: 2 additions & 2 deletions tdc/test/dev_tests/chem_utils_test/test_molfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def setUp(self):
print(os.getcwd())
pass

@unittest.skip("dev test")

def test_MolConvert(self):
from tdc.chem_utils import MolFilter

filters = MolFilter(filters=["PAINS"], HBD=[0, 6])
filters(["CCSc1ccccc1C(=O)Nc1onc2c1CCC2"])

# @unittest.skip("dev test")
#
def tearDown(self):
print(os.getcwd())

Expand Down
4 changes: 2 additions & 2 deletions tdc/test/dev_tests/chem_utils_test/test_oracles.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
print(os.getcwd())
pass

@unittest.skip("dev test")

def test_Oracle(self):
from tdc import Oracle

Expand All @@ -35,7 +35,7 @@ def test_Oracle(self):
oracle = Oracle(name="Hop")
x = oracle(["CC(=O)OC1=CC=CC=C1C(=O)O", "C1=CC=C(C=C1)C=O"])

@unittest.skip("dev test")

def test_distribution(self):
from tdc import Evaluator

Expand Down
14 changes: 7 additions & 7 deletions tdc/test/dev_tests/utils_tests/test_misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
print(os.getcwd())
pass

@unittest.skip("dev test")
@unittest.skip("long running test")
def test_neg_sample(self):
from tdc.multi_pred import PPI

Expand All @@ -33,7 +33,7 @@ def test_neg_sample(self):
# data = ADME(name='Caco2_Wang')
# x = data.label_distribution()

@unittest.skip("dev test")

def test_get_label_map(self):
from tdc.multi_pred import DDI
from tdc.utils import get_label_map
Expand All @@ -42,26 +42,26 @@ def test_get_label_map(self):
split = data.get_split()
get_label_map(name="DrugBank", task="DDI")

@unittest.skip("dev test")

def test_balanced(self):
from tdc.single_pred import HTS

data = HTS(name="SARSCoV2_3CLPro_Diamond")
data.balanced(oversample=True, seed=42)

@unittest.skip("dev test")

def test_cid2smiles(self):
from tdc.utils import cid2smiles

smiles = cid2smiles(2248631)

@unittest.skip("dev test")

def test_uniprot2seq(self):
from tdc.utils import uniprot2seq

seq = uniprot2seq("P49122")

@unittest.skip("dev test")

def test_to_graph(self):
from tdc.multi_pred import DTI

Expand Down Expand Up @@ -95,7 +95,7 @@ def test_to_graph(self):
)
# output: {'pyg_graph': the PyG graph object, 'index_to_entities': a dict map from ID in the data to node ID in the PyG object, 'split': {'train': df, 'valid': df, 'test': df}}

# @unittest.skip("dev test")
#
def tearDown(self):
print(os.getcwd())

Expand Down
12 changes: 6 additions & 6 deletions tdc/test/dev_tests/utils_tests/test_splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ def setUp(self):
print(os.getcwd())
pass

@unittest.skip("dev test")

def test_random_split(self):
from tdc.single_pred import ADME

data = ADME(name="Caco2_Wang")
split = data.get_split(method="random")

@unittest.skip("dev test")

def test_scaffold_split(self):
## requires RDKit
from tdc.single_pred import ADME

data = ADME(name="Caco2_Wang")
split = data.get_split(method="scaffold")

@unittest.skip("dev test")

def test_cold_start_split(self):
from tdc.multi_pred import DTI

Expand Down Expand Up @@ -70,21 +70,21 @@ def test_cold_start_split(self):
self.assertEqual(0, len(train_entity.intersection(test_entity)))
self.assertEqual(0, len(valid_entity.intersection(test_entity)))

@unittest.skip("dev test")

def test_combination_split(self):
from tdc.multi_pred import DrugSyn

data = DrugSyn(name="DrugComb")
split = data.get_split(method="combination")

@unittest.skip("dev test")

def test_time_split(self):
from tdc.multi_pred import DTI

data = DTI(name="BindingDB_Patent")
split = data.get_split(method="time", time_column="Year")

@unittest.skip("dev test")

def test_tearDown(self):
print(os.getcwd())

Expand Down
26 changes: 16 additions & 10 deletions tdc/utils/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,17 @@ def NegSample(df, column_names, frac, two_types):
for i in neg_list:
neg_list_val.append([i[0], id2seq[i[0]], i[1], id2seq[i[1]], 0])

df = df.append(
pd.DataFrame(neg_list_val).rename(columns={
0: id1,
1: x1,
2: id2,
3: x2,
4: "Y"
})).reset_index(drop=True)
df = pd.concat([
df,
pd.DataFrame(neg_list_val).rename(columns={
0: id1,
1: x1,
2: id2,
3: x2,
4: "Y"
})
],
ignore_index=True, sort=False)
return df
else:
df_unique_id1 = np.unique(df[id1].values.reshape(-1))
Expand Down Expand Up @@ -254,12 +257,15 @@ def NegSample(df, column_names, frac, two_types):
for i in neg_list:
neg_list_val.append([i[0], id2seq1[i[0]], i[1], id2seq2[i[1]], 0])

df = df.append(
df = pd.concat([
df,
pd.DataFrame(neg_list_val).rename(columns={
0: id1,
1: x1,
2: id2,
3: x2,
4: "Y"
})).reset_index(drop=True)
})
],
ignore_index=True, sort=False)
return df

0 comments on commit f42afa6

Please sign in to comment.