Skip to content

Commit

Permalink
Merge pull request #47 from pepkit/dev
Browse files Browse the repository at this point in the history
Release v0.1.9
  • Loading branch information
rafalstepien authored Sep 12, 2022
2 parents e65b235 + 6b48193 commit d0b8236
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 8 deletions.
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion eido/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.8"
__version__ = "0.1.9"
7 changes: 4 additions & 3 deletions eido/output_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
40 changes: 38 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/data/peps/pep_nextflow_taxprofiler/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pep_version: "2.1.0"
sample_table: "samplesheet.csv"

7 changes: 7 additions & 0 deletions tests/data/peps/pep_nextflow_taxprofiler/output.csv
Original file line number Diff line number Diff line change
@@ -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,,
7 changes: 7 additions & 0 deletions tests/data/peps/pep_nextflow_taxprofiler/samplesheet.csv
Original file line number Diff line number Diff line change
@@ -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,,
3 changes: 3 additions & 0 deletions tests/data/peps/pep_with_fasta_column/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pep_version: "2.0.0"
sample_table: "samplesheet.csv"
subsample_table: "subsamplesheet.csv"
8 changes: 8 additions & 0 deletions tests/data/peps/pep_with_fasta_column/output.csv
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/data/peps/pep_with_fasta_column/samplesheet.csv
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/data/peps/pep_with_fasta_column/subsamplesheet.csv
Original file line number Diff line number Diff line change
@@ -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
33 changes: 32 additions & 1 deletion tests/test_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}

0 comments on commit d0b8236

Please sign in to comment.