forked from js-ish/DOoC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request js-ish#5 from zzzseeu/feat-MutSmiXAttention-models
feat: MutSmiXAttention models-pipelines-datasets-test
- Loading branch information
Showing
7 changed files
with
84 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
moltx~=1.0.2 | ||
moltx~=1.0.4 | ||
networkx~=3.1 | ||
scikit-learn~=1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
import torch | ||
from dooc import models, nets | ||
from dooc import models | ||
import random | ||
|
||
|
||
# def test_MutSmiXAttention(): | ||
# smiles_src = torch.randint(0, 64, [2, 4]) | ||
# smiles_tgt = torch.randint(0, 64, [2, 6]) | ||
# mutations_src = torch.randn(2, 3008, dtype=torch.float32) | ||
# d_model = 768 | ||
# model = models.MutSmiXAttention(d_model) | ||
# out = model(smiles_src, smiles_tgt, mutations_src) | ||
# assert out.shape == (1,) | ||
def test_MutSmiXAttention(): | ||
smiles_src = torch.randint(0, 64, [2, 200]) | ||
smiles_tgt = torch.randint(0, 64, [2, 200]) | ||
mutations = [[random.choice([0, 1]) for _ in range(3008)], | ||
[random.choice([0, 1]) for _ in range(3008)]] | ||
mutations_src = torch.tensor(mutations, dtype=torch.float).to("cpu") | ||
model = models.MutSmiXAttention() | ||
out = model(smiles_src, smiles_tgt, mutations_src) | ||
assert out.shape == (2, 1) | ||
|
||
|
||
def test_MutSmiFullConnection(datadir): | ||
def test_MutSmiFullConnection(): | ||
smiles_src = torch.randint(0, 64, [2, 200]) | ||
smiles_tgt = torch.randint(0, 64, [2, 200]) | ||
mutations = [[random.choice([0, 1]) for _ in range(3008)], | ||
[random.choice([0, 1]) for _ in range(3008)]] | ||
mutations_src = torch.tensor(mutations, dtype=torch.float).to("cpu") | ||
d_model = 768 | ||
gene_conf = nets.GeneGNNConfig( | ||
gene_dim=3008, | ||
drug_dim=2048, | ||
num_hiddens_genotype=6, | ||
num_hiddens_drug=[100, 50, 6], | ||
num_hiddens_final=6, | ||
gene2ind_path=f"{datadir}/gene2ind.txt", | ||
ont_path=f"{datadir}/drugcell_ont.txt", | ||
) | ||
model = models.MutSmiFullConnection(d_model, gene_conf=gene_conf) | ||
model = models.MutSmiFullConnection() | ||
out = model(smiles_src, smiles_tgt, mutations_src) | ||
assert out.shape == (2, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,32 @@ | ||
import random | ||
from dooc import pipelines, models, nets | ||
from dooc import pipelines, models | ||
from moltx import tokenizers as tkz | ||
from moltx.models import AdaMRTokenizerConfig | ||
|
||
|
||
# def test_MutSmiXAttention(): | ||
# tokenizer = tkz.MoltxTokenizer.from_pretrain( | ||
# conf=AdaMRTokenizerConfig.Prediction | ||
# ) | ||
# d_model = 768 | ||
# model = models.MutSmiXAttention(d_model) | ||
# model.load_ckpt('/path/to/mutsmixattention.ckpt') | ||
# pipeline = pipelines.MutSmiXAttention(tokenizer, model) | ||
# mutation = [random.choice([1, 0]) for _ in range(3008)] | ||
# smiles = "CC[N+](C)(C)Cc1ccccc1Br" | ||
# predict = pipeline(mutation, smiles) | ||
# assert isinstance(predict, float) | ||
def test_MutSmiXAttention(): | ||
tokenizer = tkz.MoltxTokenizer.from_pretrain( | ||
conf=AdaMRTokenizerConfig.Prediction | ||
) | ||
model = models.MutSmiXAttention() | ||
# model.load_ckpt('/path/to/mutsmixattention.ckpt') | ||
pipeline = pipelines.MutSmiXAttention(smi_tokenizer=tokenizer, | ||
model=model) | ||
mutation = [random.choice([1, 0]) for _ in range(3008)] | ||
smiles = "CC[N+](C)(C)Cc1ccccc1Br" | ||
predict = pipeline(mutation, smiles) | ||
assert isinstance(predict, float) | ||
|
||
|
||
def test_MutSmiFullConnection(datadir): | ||
def test_MutSmiFullConnection(): | ||
tokenizer = tkz.MoltxTokenizer.from_pretrain( | ||
conf=AdaMRTokenizerConfig.Prediction | ||
) | ||
d_model = 768 | ||
gene_conf = nets.GeneGNNConfig( | ||
gene_dim=3008, | ||
drug_dim=2048, | ||
num_hiddens_genotype=6, | ||
num_hiddens_drug=[100, 50, 6], | ||
num_hiddens_final=6, | ||
gene2ind_path=f"{datadir}/gene2ind.txt", | ||
ont_path=f"{datadir}/drugcell_ont.txt", | ||
) | ||
model = models.MutSmiFullConnection(d_model, gene_conf) | ||
model = models.MutSmiFullConnection() | ||
# model.load_ckpt('/path/to/mutsmifullconnection.ckpt') | ||
pipeline = pipelines.MutSmiFullConnection(smi_tokenizer=tokenizer, | ||
model=model) | ||
mutation = [[random.choice([1, 0]) for _ in range(3008)]] | ||
mutation = [random.choice([1, 0]) for _ in range(3008)] | ||
smiles = "CC[N+](C)(C)Cc1ccccc1Br" | ||
predict = pipeline(mutation, smiles) | ||
assert isinstance(predict, float) |