Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ requirements:
- gridss
- insilicoseq
- mason
- megahit ==1.2.9
- megahit {{ megahit }}
- pysam {{ pysam }}
- qiime2 >={{ qiime2 }}
- q2-fondue >={{ q2_fondue }}
Expand Down
4 changes: 2 additions & 2 deletions q2_assembly/iss/tests/test_iss.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_rename_reads(self, p):
self.assertListEqual(obs_reads, exp_reads)

@patch("subprocess.run")
@patch("q2_assembly.iss._rename_reads_files")
@patch("q2_assembly.iss.iss._rename_reads_files")
def test_generate_reads(self, p1, p2):
samples = ["samp1", "samp2"]
result_fp = "/there"
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_generate_reads_duplicated_samples(self):
generate_reads(sample_names=["s1", "s2", "s3", "s1", "s2"])

@patch("shutil.move")
@patch("q2_assembly.iss._generate_reads")
@patch("q2_assembly.iss.iss._generate_reads")
@patch("tempfile.TemporaryDirectory")
def test_generate_reads_action(self, p1, p2, p3):
test_temp_dir = MockTempDir()
Expand Down
8 changes: 4 additions & 4 deletions q2_assembly/mason/tests/test_mason.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_process_mason_arg_bool(self):
exp = ["--k_bool"]
self.assertListEqual(obs, exp)

@patch("q2_assembly.mason._process_sample")
@patch("q2_assembly.mason.mason._process_sample")
def test_simulate_reads_mason_helper(self, p_process):
mock_genomes_dir_fmt = GenomeSequencesDirectoryFormat()

Expand All @@ -63,7 +63,7 @@ def test_simulate_reads_mason_helper(self, p_process):
)

with patch(
"q2_assembly.mason.GenomeSequencesDirectoryFormat",
"q2_assembly.mason.mason.GenomeSequencesDirectoryFormat",
return_value=mock_genomes_dir_fmt,
):
result = _simulate_reads_mason(
Expand Down Expand Up @@ -332,8 +332,8 @@ def test_combine_reads(self):
self.assertFalse(os.path.exists(f1))
self.assertFalse(os.path.exists(f2))

@patch("q2_assembly.mason.run_command")
@patch("q2_assembly.mason._combine_reads")
@patch("q2_assembly.mason.mason.run_command")
@patch("q2_assembly.mason.mason._combine_reads")
def test_process_sample(self, mock_combine_reads, mock_run_command):
sample = "sampleY"
genome_files = ["/tmp/genome1.fasta", "/tmp/genome2.fasta"]
Expand Down
53 changes: 30 additions & 23 deletions q2_assembly/megahit/tests/test_megahit.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def test_process_sample_with_error(self, p1, p2):
"test_sample", "fwd_reads.fastq.gz", None, self.fake_common_args, result
)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_paired(self, p1, p2):
input_files = self.get_data_path("reads/paired-end")
input = SingleLanePerSamplePairedEndFastqDirFmt(input_files, mode="r")
Expand All @@ -274,10 +274,14 @@ def test_assemble_megahit_paired(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls(
[call(os.path.join(str(obs), f"sample1_contigs.fa"), "sample1", "shortuuid"),
call(os.path.join(str(obs), f"sample2_contigs.fa"), "sample2", "shortuuid")]
)
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_single(self, p1, p2):
input_files = self.get_data_path("reads/single-end")
input = SingleLanePerSampleSingleEndFastqDirFmt(input_files, mode="r")
Expand All @@ -293,10 +297,14 @@ def test_assemble_megahit_single(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls(
[call(os.path.join(str(obs), f"sample1_contigs.fa"), "sample1", "shortuuid"),
call(os.path.join(str(obs), f"sample2_contigs.fa"), "sample2", "shortuuid")]
)
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_paired_coassemble(self, p1, p2):
input_files = self.get_data_path("reads/paired-end")
input = SingleLanePerSamplePairedEndFastqDirFmt(input_files, mode="r")
Expand All @@ -312,11 +320,11 @@ def test_assemble_megahit_paired_coassemble(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls([call(ANY, "all_contigs", "shortuuid")])
p2.assert_has_calls([call(os.path.join(str(obs), f"all_contigs.fa"), "all_contigs", "shortuuid")])
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_single_coassemble(self, p1, p2):
input_files = self.get_data_path("reads/single-end")
input = SingleLanePerSampleSingleEndFastqDirFmt(input_files, mode="r")
Expand All @@ -332,11 +340,11 @@ def test_assemble_megahit_single_coassemble(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls([call(ANY, "all_contigs", "shortuuid")])
p2.assert_has_calls([call(os.path.join(str(obs), f"all_contigs.fa"), "all_contigs", "shortuuid")])
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_paired_single_sample_coassemble(self, p1, p2):
input_files = self.get_data_path("reads/single-sample/paired-end")
input = SingleLanePerSamplePairedEndFastqDirFmt(input_files, mode="r")
Expand All @@ -352,11 +360,11 @@ def test_assemble_megahit_paired_single_sample_coassemble(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls([call(ANY, "all_contigs", "shortuuid")])
p2.assert_has_calls([call(os.path.join(str(obs), f"all_contigs.fa"), "all_contigs", "shortuuid")])
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_single_single_sample_coassemble(self, p1, p2):
input_files = self.get_data_path("reads/single-sample/single-end")
input = SingleLanePerSampleSingleEndFastqDirFmt(input_files, mode="r")
Expand All @@ -372,12 +380,11 @@ def test_assemble_megahit_single_single_sample_coassemble(self, p1, p2):
)

p1.assert_has_calls(exp_calls, any_order=False)
p2.assert_has_calls([call(ANY, "all_contigs", "shortuuid")])
p2.assert_has_calls([call(os.path.join(str(obs), f"all_contigs.fa"), "all_contigs", "shortuuid")])
self.assertIsInstance(obs, ContigSequencesDirFmt)

@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.assemble_megahit_helper")
def test_assemble_megahit_process_params(self, p1, p2):
@patch("q2_assembly.megahit.megahit.assemble_megahit_helper")
def test_assemble_megahit_process_params(self, p1):
input_files = self.get_data_path("reads/single-end")
input = SingleLanePerSampleSingleEndFastqDirFmt(input_files, mode="r")

Expand Down Expand Up @@ -446,21 +453,21 @@ def test_assemble_megahit_parallel_single(self):
self.assertIs(out.format, ContigSequencesDirFmt)

@parameterized.expand([("shortuuid",), ("uuid3",), ("uuid4",), ("uuid5",)])
@patch("q2_assembly.megahit.modify_contig_ids")
@patch("q2_assembly.megahit._process_sample")
@patch("q2_assembly.megahit.megahit.modify_contig_ids")
@patch("q2_assembly.megahit.megahit._process_sample")
def test_assemble_megahit_different_uuids(self, uuid_type, p1, p2):
input_files = self.get_data_path("reads/single-end")
input = SingleLanePerSampleSingleEndFastqDirFmt(input_files, mode="r")

_ = assemble_megahit_helper(
obs = assemble_megahit_helper(
reads=input,
coassemble=False,
uuid_type=uuid_type,
common_args=self.test_params_list,
)

p2.assert_has_calls(
[call(ANY, "sample1", uuid_type), call(ANY, "sample2", uuid_type)]
[call(os.path.join(str(obs), f"sample1_contigs.fa"), "sample1", uuid_type), call(os.path.join(str(obs), f"sample2_contigs.fa"), "sample2", uuid_type)]
)


Expand Down
42 changes: 25 additions & 17 deletions q2_assembly/quast/tests/test_quast.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,12 @@ def test_evaluate_quast_with_refs(self, p1):
self.assertListEqual(obs_samples, ["sample1", "sample2"])
p1.assert_called_once_with(exp_command, check=True)

@patch("q2_assembly.quast._create_tabular_results")
@patch("q2_assembly.quast.quast._create_tabular_results")
@patch("platform.system", return_value="Linux")
@patch("q2_assembly.quast._evaluate_quast", return_value=["sample1", "sample2"])
@patch("q2_assembly.quast._fix_html_reports", return_value=None)
@patch(
"q2_assembly.quast.quast._evaluate_quast", return_value=["sample1", "sample2"]
)
@patch("q2_assembly.quast.quast._fix_html_reports", return_value=None)
@patch("q2templates.render")
@patch("tempfile.TemporaryDirectory")
def test_visualize_quast_action_no_reads(self, p1, p2, p3, p4, p5, p6):
Expand Down Expand Up @@ -500,9 +502,11 @@ def test_visualize_quast_action_no_reads(self, p1, p2, p3, p4, p5, p6):
}
p2.assert_called_once_with(ANY, self._tmp, context=exp_context)

@patch("q2_assembly.quast._create_tabular_results")
@patch("q2_assembly.quast._evaluate_quast", return_value=["sample1", "sample2"])
@patch("q2_assembly.quast._fix_html_reports", return_value=None)
@patch("q2_assembly.quast.quast._create_tabular_results")
@patch(
"q2_assembly.quast.quast._evaluate_quast", return_value=["sample1", "sample2"]
)
@patch("q2_assembly.quast.quast._fix_html_reports", return_value=None)
@patch("q2templates.render")
@patch("tempfile.TemporaryDirectory")
def test_visualize_quast_action_single_end(self, p1, p2, p3, p4, p5):
Expand Down Expand Up @@ -577,9 +581,11 @@ def test_visualize_quast_action_single_end(self, p1, p2, p3, p4, p5):
}
p2.assert_called_once_with(ANY, self._tmp, context=exp_context)

@patch("q2_assembly.quast._create_tabular_results")
@patch("q2_assembly.quast._evaluate_quast", return_value=["sample1", "sample2"])
@patch("q2_assembly.quast._fix_html_reports", return_value=None)
@patch("q2_assembly.quast.quast._create_tabular_results")
@patch(
"q2_assembly.quast.quast._evaluate_quast", return_value=["sample1", "sample2"]
)
@patch("q2_assembly.quast.quast._fix_html_reports", return_value=None)
@patch("q2templates.render")
@patch("tempfile.TemporaryDirectory")
def test_visualize_quast_action_paired_end(self, p1, p2, p3, p4, p5):
Expand Down Expand Up @@ -652,9 +658,11 @@ def test_visualize_quast_action_paired_end(self, p1, p2, p3, p4, p5):
}
p2.assert_called_once_with(ANY, self._tmp, context=exp_context)

@patch("q2_assembly.quast._create_tabular_results")
@patch("q2_assembly.quast._evaluate_quast", return_value=["sample1", "sample2"])
@patch("q2_assembly.quast._fix_html_reports", return_value=None)
@patch("q2_assembly.quast.quast._create_tabular_results")
@patch(
"q2_assembly.quast.quast._evaluate_quast", return_value=["sample1", "sample2"]
)
@patch("q2_assembly.quast.quast._fix_html_reports", return_value=None)
@patch("q2templates.render")
@patch("tempfile.TemporaryDirectory")
def test_evaluate_quast_action_paired_end_no_icarus(self, p1, p2, p3, p4, p5):
Expand Down Expand Up @@ -726,7 +734,7 @@ def test_evaluate_quast_action_paired_end_no_icarus(self, p1, p2, p3, p4, p5):
p2.assert_called_once_with(ANY, self._tmp, context=exp_context)

@patch("pandas.read_csv")
@patch("q2_assembly.quast._parse_columns")
@patch("q2_assembly.quast.quast._parse_columns")
def test_create_tabular_results(self, p1, p2):
report_path = os.path.join(self.temp_dir.name, "transposed_report.tsv")
mock_df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
Expand All @@ -738,7 +746,7 @@ def test_create_tabular_results(self, p1, p2):
p1.assert_called_once_with(mock_df, [1000, 5000, 25000, 50000])

@patch("pandas.read_csv")
@patch("q2_assembly.quast._parse_columns")
@patch("q2_assembly.quast.quast._parse_columns")
def test_create_tabular_results_in_combined_subdir(self, p1, p2):
report_path = os.path.join(
self.temp_dir.name, "combined_reference", "transposed_report.tsv"
Expand Down Expand Up @@ -822,7 +830,7 @@ def test_evaluate_quast_pipeline_no_refs_normal(self):
action, export_data, make_artifact, mock_ctx = self.create_mock_ctx()

with patch(
"q2_assembly.quast.GenomeSequencesDirectoryFormat"
"q2_types.genome_data.GenomeSequencesDirectoryFormat"
) as MockGenomeSequencesDirectoryFormat:
MockGenomeSequencesDirectoryFormat.return_value = (
GenomeSequencesDirectoryFormat(
Expand Down Expand Up @@ -853,7 +861,7 @@ def test_evaluate_quast_pipeline_no_refs_no_downloaded_genomes(self):
action, export_data, make_artifact, mock_ctx = self.create_mock_ctx()

with patch(
"q2_assembly.quast.GenomeSequencesDirectoryFormat"
"q2_types.genome_data.GenomeSequencesDirectoryFormat"
) as MockGenomeSequencesDirectoryFormat:

with warnings.catch_warnings(record=True) as w:
Expand Down Expand Up @@ -892,7 +900,7 @@ def test_evaluate_quast_pipeline_no_refs_corrupt_files(self):
mock_temp_dir.return_value.__enter__.return_value = tmp
action, export_data, make_artifact, mock_ctx = self.create_mock_ctx()
with patch(
"q2_assembly.quast.GenomeSequencesDirectoryFormat"
"q2_assembly.quast.quast.GenomeSequencesDirectoryFormat"
) as MockGenomeSequencesDirectoryFormat:
with warnings.catch_warnings(record=True) as w:
# corrupt file
Expand Down
Loading
Loading