Skip to content

Commit

Permalink
Fix fasta network error v0.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
asistradition committed Mar 19, 2022
1 parent c1ab322 commit cc52350
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### Version 0.3.6
### Version 0.3.8

* Fixed bug when saving motif locations with `network_from_motifs_fasta`

### Version 0.3.7

* Improved memory usage for `network_from_motifs_fasta` when a large number of sequences or TFs are used

Expand Down
6 changes: 6 additions & 0 deletions inferelator_prior/network_from_motifs_fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def build_motif_prior_from_fasta(motif_file, promoter_fasta_file, scanner_type='
if gene_constraint_list is not None:
genes = select_genes(genes, gene_constraint_list)

if save_locs and output_prefix is not None:
save_locs = output_prefix + "_tf_binding_locs.tsv"

if save_locs_filtered and output_prefix is not None:
save_locs_filtered = output_prefix + "_tf_binding_locs_filtered.tsv"

return scan_and_build_by_tf(promoter_fasta_file, None, genes, None, output_prefix, motif_information,
debug=debug, motif_ic=motif_ic, tandem=tandem, scanner_thresh=scanner_thresh,
save_locs=save_locs, save_locs_filtered=save_locs_filtered, num_cores=num_cores,
Expand Down
41 changes: 41 additions & 0 deletions inferelator_prior/tests/test_network_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,44 @@ def test_file_output(self):
self.assertTrue(os.path.exists(temp_path_prefix + "g_edge_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "g_tf_binding_locs.tsv"))
self.assertTrue(os.path.exists(temp_path_prefix + "g_tf_binding_locs_filtered.tsv"))


def test_file_output_fasta(self):
cut, raw, _ = build_motif_prior_from_fasta(os.path.join(artifact_path, "test_ecori.meme"),
os.path.join(artifact_path, "test_motif_search.fasta"),
output_prefix=temp_path_prefix)

self.assertTrue(os.path.exists(temp_path_prefix + "_unfiltered_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "_edge_matrix.tsv.gz"))
self.assertFalse(os.path.exists(temp_path_prefix + "_tf_binding_locs.tsv"))
self.assertFalse(os.path.exists(temp_path_prefix + "_tf_binding_locs_filtered.tsv"))

cut, raw, _ = build_motif_prior_from_fasta(os.path.join(artifact_path, "test_ecori.meme"),
os.path.join(artifact_path, "test_motif_search.fasta"),
output_prefix=temp_path_prefix + "c",
save_locs=True)

self.assertTrue(os.path.exists(temp_path_prefix + "c_unfiltered_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "c_edge_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "c_tf_binding_locs.tsv"))

cut, raw, _ = build_motif_prior_from_fasta(os.path.join(artifact_path, "test_ecori.meme"),
os.path.join(artifact_path, "test_motif_search.fasta"),
output_prefix=temp_path_prefix + "d",
save_locs_filtered=True)

self.assertTrue(os.path.exists(temp_path_prefix + "d_unfiltered_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "d_edge_matrix.tsv.gz"))
self.assertFalse(os.path.exists(temp_path_prefix + "d_tf_binding_locs.tsv"))
self.assertTrue(os.path.exists(temp_path_prefix + "d_tf_binding_locs_filtered.tsv"))

cut, raw, _ = build_motif_prior_from_fasta(os.path.join(artifact_path, "test_ecori.meme"),
os.path.join(artifact_path, "test_motif_search.fasta"),
output_prefix=temp_path_prefix + "f",
save_locs_filtered=True,
save_locs=True)

self.assertTrue(os.path.exists(temp_path_prefix + "f_unfiltered_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "f_edge_matrix.tsv.gz"))
self.assertTrue(os.path.exists(temp_path_prefix + "f_tf_binding_locs.tsv"))
self.assertTrue(os.path.exists(temp_path_prefix + "f_tf_binding_locs_filtered.tsv"))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

install_requires = ["numpy", "pandas>=1.0", "HTSeq", "pybedtools", "scipy", "pathos", "sklearn", "tqdm"]
tests_require = ["coverage", "nose", "pysam"]
version = "0.3.7"
version = "0.3.8"

# Description from README.md
base_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down

0 comments on commit cc52350

Please sign in to comment.