Skip to content

Commit

Permalink
Added e2e test support, minor code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Ge94 committed Apr 25, 2024
1 parent b9f3c71 commit abebc69
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/input_example.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
genome_name genome_path accessions assembly_software binning_software binning_parameters stats_generation_software completeness contamination genome_coverage metagenome co-assembly broad_environment local_environment environmental_medium rRNA_presence taxonomy_lineage
genome_name genome_path accessions assembly_software binning_software binning_parameters stats_generation_software completeness contamination genome_coverage metagenome co-assembly broad_environment local_environment environmental_medium rRNA_presence NCBI_lineage
coassembly2728_3.fa ./coassembly2728_3.fa.gz SRR1622827,SRR1622828 MetaSPAdes_v3.15.3 metaWRAP_v1.3 default EukCC_v2.1.0 98.2 0.2 26.24 skin metagenome True human skin finger False 1;131567;2759;33154;4751;451864;5204;452284;1538075;162474;742845;55193;76775
ERR4647712_megahit_bin.fa ./ERR4647712_megahit_bin.fa.gz ERR4647712 megahit_v1.2.9 MGnify-genomes-generation-pipeline_v1.0.0 default CheckM2_v1.0.1 90.81 0.59 14.2 chicken gut metagenome False chicken gut mucosa True d__Bacteria;p__Firmicutes;c__Bacilli;o__Lactobacillales;f__Lactobacillaceae;g__Lactobacillus;s__Lactobacillus crispatus
17 changes: 7 additions & 10 deletions genomeuploader/genome_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ def round_stats(stats):
def compute_MAG_quality(completeness, contamination, RNApresence):
RNApresent = str(RNApresence).lower() in ["true", "yes", "y"]
quality = MQ
if completeness >= 90 and contamination <= 5 and RNApresent:
if float(completeness) >= 90 and float(contamination) <= 5 and RNApresent:
quality = HQ

completeness = str(round_stats(completeness))
contamination = str(round_stats(contamination))

return quality, completeness, contamination

Expand Down Expand Up @@ -333,12 +330,12 @@ def extract_genomes_info(inputFile, genomeType, live):
genomeInfo[gen]["isolationSource"] = genomeInfo[gen]["metagenome"]

try:
genomeInfo[gen]["completeness"] = str(round_stats(genomeInfo[gen]["completeness"]))
genomeInfo[gen]["contamination"] = str(round_stats(genomeInfo[gen]["contamination"]))

quality = compute_MAG_quality(genomeInfo[gen]["completeness"],
genomeInfo[gen]["contamination"], genomeInfo[gen]["rRNA_presence"])
genomeInfo[gen]["MAG_quality"] = quality
(genomeInfo[gen]["MAG_quality"],
genomeInfo[gen]["completeness"],
genomeInfo[gen]["contamination"]) = compute_MAG_quality(
str(round_stats(genomeInfo[gen]["completeness"])),
str(round_stats(genomeInfo[gen]["contamination"])),
genomeInfo[gen]["rRNA_presence"])
except IndexError:
pass

Expand Down
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ dependencies = [
"python-dotenv==1.0.1"
]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
"integration",
]

[project.optional-dependencies]
dev = [
"pre-commit==3.3.3",
Expand Down Expand Up @@ -59,9 +67,6 @@ ignore = [
"S308", # flake8-bandit suspicious-mark-safe-usage
"E501", # pycodestyle line-too-long
]
line-length = 140
src = ["fetchtool", "tests"]
target-version = "py38"

[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
Expand All @@ -83,5 +88,5 @@ current_version = "0.9.0"
commit = true
tag = true

[[tool.bumpversion.files]]
[tool.bumpversion.files]
filename = "genomeuploader/__init__.py"
1 change: 1 addition & 0 deletions requirements-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r requirements.yml
4 changes: 4 additions & 0 deletions tests/fixtures/ERR6769700_bin.1.fa.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
>contig1
AGAGTAGGCGAGCTAGCGAAC
>contig2
GATGAGCTACGAGCGATTAAC
12 changes: 12 additions & 0 deletions tests/fixtures/bin_upload/bin_backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ERR6769700": {
"instrumentModel": "DNBSEQ-G400",
"collectionDate": "2019-10-15",
"country": "Spain",
"latitude": "41.170048",
"longitude": "1.168491",
"projectDescription": "Metagenomic raw reads, assemblies, and bins derived from HoloFood chicken ileum samples. Samples selected for this batch were deeply sequenced, and were randomised among trials (feed), age, and breed to overcome batch effect. The samples in this project contributed to the chicken ileum MAG catalogue (project: PRJEB55375 [ERP140264]).",
"study": "ERP131894",
"assembler": "not provided",
"sampleAccession": "SAMEA10130103"}
}
2 changes: 2 additions & 0 deletions tests/fixtures/input_fixture.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
genome_name genome_path accessions assembly_software binning_software binning_parameters stats_generation_software completeness contamination genome_coverage metagenome co-assembly broad_environment local_environment environmental_medium rRNA_presence NCBI_lineage
ERR6769700_bin.1 ./tests/fixtures/ERR6769700_bin.1.fa.gz ERR6769700 megahit_v1.2.9 MGnify-genomes-generation-pipeline_v1.0.0 default CheckM2_v1.0.1 90.81314 0.59 14.2 chicken gut metagenome False chicken gut mucosa True d__Bacteria;p__Firmicutes;c__Bacilli;o__Lactobacillales;f__Lactobacillaceae;g__Lactobacillus;s__Lactobacillus crispatus
7 changes: 7 additions & 0 deletions tests/test_checkOutcome_e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- name: genomeuploader end to end test
command: "python genomeuploader/genome_upload.py -u ERP159782 --genome_info tests/fixtures/input_fixture.tsv --out tests/fixtures/ --bins --centre_name EMG"
files:
- path: "tests/fixtures/bin_upload/manifests/"
- path: "tests/fixtures/bin_upload/genome_samples.xml"
- path: "tests/fixtures/bin_upload/registered_bins_test.tsv"
- path: "tests/fixtures/bin_upload/submission.xml"

0 comments on commit abebc69

Please sign in to comment.