Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_min_props():
for Dl in [SeqStringDataset, SeqDataset]:
props = dir(Dl)
assert all([el in props for el in min_set_props])
def test_fasta_based_dataset():
# just test the functionality
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta")
ret_val = dl[0]
assert isinstance(ret_val["inputs"], np.ndarray)
assert ret_val["inputs"].shape == (1,)
# test with set wrong seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", required_seq_len=3)
with pytest.raises(Exception):
dl[0]
# test with short max_seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", max_seq_len=1)
with pytest.raises(Exception):
dl[0]
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="string")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.str_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="int")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.int_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="bool")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.bool_)
def test_fasta_based_dataset():
# just test the functionality
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta")
ret_val = dl[0]
assert isinstance(ret_val["inputs"], np.ndarray)
assert ret_val["inputs"].shape == (1,)
# test with set wrong seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", required_seq_len=3)
with pytest.raises(Exception):
dl[0]
# test with short max_seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", max_seq_len=1)
with pytest.raises(Exception):
dl[0]
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="string")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.str_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="int")
ret_val = dl[0]
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta")
ret_val = dl[0]
assert isinstance(ret_val["inputs"], np.ndarray)
assert ret_val["inputs"].shape == (1,)
# test with set wrong seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", required_seq_len=3)
with pytest.raises(Exception):
dl[0]
# test with short max_seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", max_seq_len=1)
with pytest.raises(Exception):
dl[0]
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="string")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.str_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="int")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.int_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="bool")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.bool_)
def test_fasta_based_dataset():
# just test the functionality
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta")
ret_val = dl[0]
assert isinstance(ret_val["inputs"], np.ndarray)
assert ret_val["inputs"].shape == (1,)
# test with set wrong seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", required_seq_len=3)
with pytest.raises(Exception):
dl[0]
# test with short max_seqlen:
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", max_seq_len=1)
with pytest.raises(Exception):
dl[0]
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="string")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.str_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="int")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.int_)
dl = SeqStringDataset(data_bpath + "sample_intervals.bed", data_bpath + "sample.fasta", label_dtype="bool")
ret_val = dl[0]
assert isinstance(ret_val['targets'][0], np.bool_)