diff --git a/CHANGELOG.md b/CHANGELOG.md index f38d441..bcc3efa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/inferelator_prior/network_from_motifs_fasta.py b/inferelator_prior/network_from_motifs_fasta.py index 9c22f59..3a0d9be 100644 --- a/inferelator_prior/network_from_motifs_fasta.py +++ b/inferelator_prior/network_from_motifs_fasta.py @@ -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, diff --git a/inferelator_prior/tests/test_network_maker.py b/inferelator_prior/tests/test_network_maker.py index b421f45..9e5996b 100644 --- a/inferelator_prior/tests/test_network_maker.py +++ b/inferelator_prior/tests/test_network_maker.py @@ -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")) diff --git a/setup.py b/setup.py index d788ce2..5a21bcc 100644 --- a/setup.py +++ b/setup.py @@ -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__))