From d32baf5e31cfbdd8111be72f504f4664bfb213a4 Mon Sep 17 00:00:00 2001 From: Rafal Stepien Date: Wed, 31 Aug 2022 11:10:32 -0400 Subject: [PATCH 1/2] Apply bugfix --- eido/output_formatters.py | 7 ++-- tests/conftest.py | 40 ++++++++++++++++++- .../config.yaml | 0 .../multiline_output.csv | 0 .../samplesheet.csv | 0 .../subsamplesheet.csv | 0 .../peps/pep_nextflow_taxprofiler/config.yaml | 3 ++ .../peps/pep_nextflow_taxprofiler/output.csv | 7 ++++ .../pep_nextflow_taxprofiler/samplesheet.csv | 7 ++++ .../peps/pep_with_fasta_column/config.yaml | 3 ++ .../peps/pep_with_fasta_column/output.csv | 8 ++++ .../pep_with_fasta_column/samplesheet.csv | 6 +++ .../pep_with_fasta_column/subsamplesheet.csv | 8 ++++ tests/test_conversions.py | 33 ++++++++++++++- 14 files changed, 116 insertions(+), 6 deletions(-) rename tests/data/peps/{taxprofiler_pep => multiline_output}/config.yaml (100%) rename tests/data/peps/{taxprofiler_pep => multiline_output}/multiline_output.csv (100%) rename tests/data/peps/{taxprofiler_pep => multiline_output}/samplesheet.csv (100%) rename tests/data/peps/{taxprofiler_pep => multiline_output}/subsamplesheet.csv (100%) create mode 100644 tests/data/peps/pep_nextflow_taxprofiler/config.yaml create mode 100644 tests/data/peps/pep_nextflow_taxprofiler/output.csv create mode 100644 tests/data/peps/pep_nextflow_taxprofiler/samplesheet.csv create mode 100644 tests/data/peps/pep_with_fasta_column/config.yaml create mode 100644 tests/data/peps/pep_with_fasta_column/output.csv create mode 100644 tests/data/peps/pep_with_fasta_column/samplesheet.csv create mode 100644 tests/data/peps/pep_with_fasta_column/subsamplesheet.csv diff --git a/eido/output_formatters.py b/eido/output_formatters.py index 24801cad..e063727f 100644 --- a/eido/output_formatters.py +++ b/eido/output_formatters.py @@ -103,15 +103,16 @@ def _convert_sample_to_row( Representation of sample as a CSV row. """ sample_row = [] - for attribute in sample_attributes: - if MultilineOutputFormatter._sample_attribute_is_list(sample, attribute): + if MultilineOutputFormatter._sample_attribute_is_list( + sample, attribute + ) and getattr(sample, attribute): value = getattr(sample, attribute)[sample_index] else: value = getattr(sample, attribute, "") - sample_row.append(value) + sample_row.append(value or "") return ",".join(sample_row) diff --git a/tests/conftest.py b/tests/conftest.py index 83052142..f7b16dc8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,7 +57,7 @@ def schema_imports_file_path(schemas_path): @pytest.fixture def taxprofiler_project_path(peps_path): - return os.path.join(peps_path, "taxprofiler_pep", "config.yaml") + return os.path.join(peps_path, "multiline_output", "config.yaml") @pytest.fixture @@ -67,7 +67,25 @@ def taxprofiler_project(taxprofiler_project_path): @pytest.fixture def path_to_taxprofiler_csv_multiline_output(peps_path): - return os.path.join(peps_path, "taxprofiler_pep", "multiline_output.csv") + return os.path.join(peps_path, "multiline_output", "multiline_output.csv") + + +@pytest.fixture +def path_pep_with_fasta_column(peps_path): + return os.path.join(peps_path, "pep_with_fasta_column", "config.yaml") + + +@pytest.fixture +def project_pep_with_fasta_column(path_pep_with_fasta_column): + return Project(path_pep_with_fasta_column, sample_table_index="sample") + + +@pytest.fixture +def output_pep_with_fasta_column(path_pep_with_fasta_column): + with open( + os.path.join(os.path.dirname(path_pep_with_fasta_column), "output.csv") + ) as f: + return f.read() @pytest.fixture @@ -77,6 +95,24 @@ def taxprofiler_csv_multiline_output(path_to_taxprofiler_csv_multiline_output): ) +@pytest.fixture +def path_pep_nextflow_taxprofiler(peps_path): + return os.path.join(peps_path, "pep_nextflow_taxprofiler", "config.yaml") + + +@pytest.fixture +def project_pep_nextflow_taxprofiler(path_pep_nextflow_taxprofiler): + return Project(path_pep_nextflow_taxprofiler, sample_table_index="sample") + + +@pytest.fixture +def output_pep_nextflow_taxprofiler(path_pep_nextflow_taxprofiler): + with open( + os.path.join(os.path.dirname(path_pep_nextflow_taxprofiler), "output.csv") + ) as f: + return f.read() + + @pytest.fixture def save_result_mock(mocker): return mocker.patch("eido.conversion.save_result") diff --git a/tests/data/peps/taxprofiler_pep/config.yaml b/tests/data/peps/multiline_output/config.yaml similarity index 100% rename from tests/data/peps/taxprofiler_pep/config.yaml rename to tests/data/peps/multiline_output/config.yaml diff --git a/tests/data/peps/taxprofiler_pep/multiline_output.csv b/tests/data/peps/multiline_output/multiline_output.csv similarity index 100% rename from tests/data/peps/taxprofiler_pep/multiline_output.csv rename to tests/data/peps/multiline_output/multiline_output.csv diff --git a/tests/data/peps/taxprofiler_pep/samplesheet.csv b/tests/data/peps/multiline_output/samplesheet.csv similarity index 100% rename from tests/data/peps/taxprofiler_pep/samplesheet.csv rename to tests/data/peps/multiline_output/samplesheet.csv diff --git a/tests/data/peps/taxprofiler_pep/subsamplesheet.csv b/tests/data/peps/multiline_output/subsamplesheet.csv similarity index 100% rename from tests/data/peps/taxprofiler_pep/subsamplesheet.csv rename to tests/data/peps/multiline_output/subsamplesheet.csv diff --git a/tests/data/peps/pep_nextflow_taxprofiler/config.yaml b/tests/data/peps/pep_nextflow_taxprofiler/config.yaml new file mode 100644 index 00000000..51cc3784 --- /dev/null +++ b/tests/data/peps/pep_nextflow_taxprofiler/config.yaml @@ -0,0 +1,3 @@ +pep_version: "2.1.0" +sample_table: "samplesheet.csv" + diff --git a/tests/data/peps/pep_nextflow_taxprofiler/output.csv b/tests/data/peps/pep_nextflow_taxprofiler/output.csv new file mode 100644 index 00000000..d70a0e77 --- /dev/null +++ b/tests/data/peps/pep_nextflow_taxprofiler/output.csv @@ -0,0 +1,7 @@ +sample,instrument_platform,run_accession,fastq_1,fastq_2,fasta +2611,ILLUMINA,ERR5766174,,,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fasta/ERX5474930_ERR5766174_1.fa.gz +2613,ILLUMINA,ERR5766181,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474937_ERR5766181_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474937_ERR5766181_2.fastq.gz, +ERR3201952,OXFORD_NANOPORE,ERR3201952,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERR3201952.fastq.gz,, +2612,ILLUMINA,ERR5766176,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_2.fastq.gz, +2612,ILLUMINA,ERR5766176_B,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_B_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_B_2.fastq.gz, +2612,ILLUMINA,ERR5766180,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474936_ERR5766180_1.fastq.gz,, diff --git a/tests/data/peps/pep_nextflow_taxprofiler/samplesheet.csv b/tests/data/peps/pep_nextflow_taxprofiler/samplesheet.csv new file mode 100644 index 00000000..1b17b767 --- /dev/null +++ b/tests/data/peps/pep_nextflow_taxprofiler/samplesheet.csv @@ -0,0 +1,7 @@ +sample,instrument_platform,run_accession,fastq_1,fastq_2,fasta +2611,ILLUMINA,ERR5766174,,,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fasta/ERX5474930_ERR5766174_1.fa.gz +2612,ILLUMINA,ERR5766176,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_2.fastq.gz, +2612,ILLUMINA,ERR5766176_B,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_B_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474932_ERR5766176_B_2.fastq.gz, +2612,ILLUMINA,ERR5766180,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474936_ERR5766180_1.fastq.gz,, +2613,ILLUMINA,ERR5766181,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474937_ERR5766181_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERX5474937_ERR5766181_2.fastq.gz, +ERR3201952,OXFORD_NANOPORE,ERR3201952,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fastq/ERR3201952.fastq.gz,, diff --git a/tests/data/peps/pep_with_fasta_column/config.yaml b/tests/data/peps/pep_with_fasta_column/config.yaml new file mode 100644 index 00000000..a56d90b3 --- /dev/null +++ b/tests/data/peps/pep_with_fasta_column/config.yaml @@ -0,0 +1,3 @@ +pep_version: "2.0.0" +sample_table: "samplesheet.csv" +subsample_table: "subsamplesheet.csv" diff --git a/tests/data/peps/pep_with_fasta_column/output.csv b/tests/data/peps/pep_with_fasta_column/output.csv new file mode 100644 index 00000000..ac7dc5b2 --- /dev/null +++ b/tests/data/peps/pep_with_fasta_column/output.csv @@ -0,0 +1,8 @@ +sample,strandedness,instrument_platform,run_accession,fastq_1,fastq_2,fasta +WT_REP1,reverse,ABI_SOLID,runaccession1,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357076_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357076_2.fastq.gz, +WT_REP1,reverse,ABI_SOLID,runaccession2,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357071_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357071_2.fastq.gz, +WT_REP2,reverse,BGISEQ,123123123,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357072_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357072_2.fastq.gz, +RAP1_UNINDUCED_REP1,reverse,CAPILLARY,somerunaccesion,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357073_1.fastq.gz,, +RAP1_UNINDUCED_REP2,reverse,COMPLETE_GENOMICS,ERR2412421,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357074_1.fastq.gz,, +RAP1_UNINDUCED_REP2,reverse,COMPLETE_GENOMICS,xxxxxxxxxx,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357075_1.fastq.gz,, +RAP1_IAA_30M_REP1,reverse,DNBSEQ,None,,,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fasta/ERX5474930_ERR5766174_1.fa.gz diff --git a/tests/data/peps/pep_with_fasta_column/samplesheet.csv b/tests/data/peps/pep_with_fasta_column/samplesheet.csv new file mode 100644 index 00000000..6d9956d8 --- /dev/null +++ b/tests/data/peps/pep_with_fasta_column/samplesheet.csv @@ -0,0 +1,6 @@ +sample,strandedness,instrument_platform +WT_REP1,reverse,ABI_SOLID +WT_REP2,reverse,BGISEQ +RAP1_UNINDUCED_REP1,reverse,CAPILLARY +RAP1_UNINDUCED_REP2,reverse,COMPLETE_GENOMICS +RAP1_IAA_30M_REP1,reverse,DNBSEQ diff --git a/tests/data/peps/pep_with_fasta_column/subsamplesheet.csv b/tests/data/peps/pep_with_fasta_column/subsamplesheet.csv new file mode 100644 index 00000000..446f9a91 --- /dev/null +++ b/tests/data/peps/pep_with_fasta_column/subsamplesheet.csv @@ -0,0 +1,8 @@ +sample,run_accession,fastq_1,fastq_2,fasta,strandedness +WT_REP1,runaccession1,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357076_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357076_2.fastq.gz,,reverse +WT_REP1,runaccession2,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357071_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357071_2.fastq.gz,,reverse +WT_REP2,123123123,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357072_1.fastq.gz,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357072_2.fastq.gz,,reverse +RAP1_UNINDUCED_REP1,somerunaccesion,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357073_1.fastq.gz,,,reverse +RAP1_UNINDUCED_REP2,ERR2412421,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357074_1.fastq.gz,,,reverse +RAP1_UNINDUCED_REP2,xxxxxxxxxx,https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/testdata/GSE110004/SRR6357075_1.fastq.gz,,,reverse +RAP1_IAA_30M_REP1,None,,,https://raw.githubusercontent.com/nf-core/test-datasets/taxprofiler/data/fasta/ERX5474930_ERR5766174_1.fa.gz,reverse diff --git a/tests/test_conversions.py b/tests/test_conversions.py index 4d1f75a1..179020e2 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -33,7 +33,6 @@ def test_basic_filter(self, save_result_mock, project_object): def test_csv_filter( self, save_result_mock, taxprofiler_project, taxprofiler_csv_multiline_output ): - conv_result = run_filter( taxprofiler_project, "csv", @@ -43,3 +42,35 @@ def test_csv_filter( assert save_result_mock.called assert conv_result["samples"] == taxprofiler_csv_multiline_output + + def test_csv_filter_handles_empty_fasta_correclty( + self, + project_pep_with_fasta_column, + output_pep_with_fasta_column, + save_result_mock, + ): + conv_result = run_filter( + project_pep_with_fasta_column, + "csv", + verbose=False, + plugin_kwargs={"paths": {"samples": "out/basic_prj.txt"}}, + ) + + assert save_result_mock.called + assert conv_result == {"samples": output_pep_with_fasta_column} + + def test_eido_csv_filter_filters_nextflow_taxprofiler_input_correctly( + self, + project_pep_nextflow_taxprofiler, + output_pep_nextflow_taxprofiler, + save_result_mock, + ): + conv_result = run_filter( + project_pep_nextflow_taxprofiler, + "csv", + verbose=False, + plugin_kwargs={"paths": {"samples": "out/basic_prj.txt"}}, + ) + + assert save_result_mock.called + assert conv_result == {"samples": output_pep_nextflow_taxprofiler} From 6b48193c92bed6b95233d836c0dc23b24e1f2ad1 Mon Sep 17 00:00:00 2001 From: Rafal Stepien Date: Mon, 12 Sep 2022 11:44:43 -0400 Subject: [PATCH 2/2] Update changelog and versions --- docs/changelog.md | 6 +++++- eido/_version.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index f30b63e3..7d32d222 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,7 +1,11 @@ # Changelog This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. - +## [0.1.9] - 2022-09-12 +### Fixed +- CSV filter bug +### Added +- New test cases ## [0.1.8] - 2022-08-29 ### Changed - the way of merging tables for multiline output format from eido convert diff --git a/eido/_version.py b/eido/_version.py index 9cb17e79..c11f861a 100644 --- a/eido/_version.py +++ b/eido/_version.py @@ -1 +1 @@ -__version__ = "0.1.8" +__version__ = "0.1.9"