forked from deepchem/deepchem
-
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.
- Loading branch information
Showing
9 changed files
with
259 additions
and
26 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
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import unittest | ||
import deepchem as dc | ||
try: | ||
import pysam | ||
except ImportError: | ||
print("Error: Unable to import pysam. Please make sure it is installed.") | ||
import numpy as np | ||
|
||
|
||
class TestBAMLoader(unittest.TestCase): | ||
""" | ||
Tests for BAMLoader and BAMFeaturizer | ||
""" | ||
|
||
def setUp(self): | ||
super(TestBAMLoader, self).setUp() | ||
self.current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
def test_bam_loader_with_single_file(self): | ||
""" | ||
Tests BAMLoader with a single BAM file. | ||
""" | ||
bam_file_path = os.path.join(self.current_dir, "example.bam") | ||
loader = dc.data.BAMLoader() | ||
dataset = loader.create_dataset(bam_file_path) | ||
|
||
assert dataset.X.shape == (396, 7) | ||
|
||
def test_bam_loader_with_multiple_files(self): | ||
""" | ||
Tests BAMLoader with multiple BAM files. | ||
""" | ||
bam_files = [ | ||
os.path.join(self.current_dir, "example.bam"), | ||
os.path.join(self.current_dir, "example.bam") | ||
] | ||
loader = dc.data.BAMLoader() | ||
dataset = loader.create_dataset(bam_files) | ||
|
||
assert dataset.X.shape == (792, 7) | ||
|
||
def test_bam_featurizer(self): | ||
""" | ||
Tests BAMFeaturizer. | ||
""" | ||
bam_featurizer = dc.feat.BAMFeaturizer(max_records=5) | ||
bam_file_path = os.path.join(self.current_dir, "example.bam") | ||
bamfile = pysam.AlignmentFile(bam_file_path, "rb") | ||
dataset = bam_featurizer._featurize(bamfile) | ||
|
||
assert dataset.shape == (5, 7) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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