meteor 2.0.4__tar.gz → 2.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {meteor-2.0.4 → meteor-2.0.6}/PKG-INFO +1 -1
- {meteor-2.0.4 → meteor-2.0.6}/meteor/mapper.py +5 -2
- {meteor-2.0.4 → meteor-2.0.6}/meteor/meteor.py +23 -15
- meteor-2.0.6/meteor/phylogeny.py +187 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/session.py +1 -1
- {meteor-2.0.4 → meteor-2.0.6}/meteor/strain.py +7 -3
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling.py +1 -1
- {meteor-2.0.4 → meteor-2.0.6}/meteor/treebuilder.py +17 -6
- {meteor-2.0.4 → meteor-2.0.6}/meteor/variantcalling.py +15 -6
- {meteor-2.0.4 → meteor-2.0.6}/pyproject.toml +1 -1
- meteor-2.0.4/meteor/phylogeny.py +0 -128
- {meteor-2.0.4 → meteor-2.0.6}/COPYING +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/README.md +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/__init__.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/counter.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/data/GMM_definition.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/data/category_pcm.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/data/zenodo.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/downloader.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/fastqimporter.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/merging.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/parser.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/profiler.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/referencebuilder.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/__init__.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/database/hs_8_4_oral_853MSPs.txt +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/database/mock_annotation.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/database/mock_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.1.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.2.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.3.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.4.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.fasta.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.rev.1.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/fasta/mock.rev.2.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/catalogue/mock/mock_reference.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/part1/part1.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/part1/part1_census_stage_0.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/total_raw.cram +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter/total_raw.cram.crai +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_counter.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_downloader/test.tar.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_downloader.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test2_1.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test2_2.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test3_1.fq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test3_2.fq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test_R1.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired/test_R2.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired_mask/test2_Zymo_6400_1.fq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired_mask/test2_Zymo_6400_2.fq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired_mask/test_Zymo_6300_R1.fastq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/paired_mask/test_Zymo_6300_R2.fastq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/single/test.fastq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/single/test2.fq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/single/test3.fastq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/single_mask/test2_Zymo_6400.fq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer/single_mask/test_Zymo_6300.fq +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_fastq_importer.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/database/eva71_lite_annotation +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/eva71_reference.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.1.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.2.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.3.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.4.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.fasta +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.rev.1.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71/fasta/eva71.rev.2.bt2 +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71_bench.bam +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71_bench.fq.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71_bench.sam +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper/eva71_bench_census_stage_0.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_mapper.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_census_stage_2_report.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_dbcan_as_msp_sum.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_genes.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_modules.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_modules_completeness.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_mustard_as_genes_sum.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/expected_output/test_project_raw.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample1/sample1.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample1/sample1_census_stage_1.ini +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample1/sample1_census_stage_1.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample2/sample2.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample2/sample2_census_stage_1.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample3/sample3.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/mapping/sample3/sample3_census_stage_1.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_census_stage_2.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_dbcan_as_msp_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_genes.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_modules.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_modules_completeness.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_msp.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_mustard_as_genes_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample1/sample1_raw.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_census_stage_2.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_dbcan_as_msp_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_genes.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_modules.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_modules_completeness.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_msp.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_mustard_as_genes_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample2/sample2_raw.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_census_stage_2.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_dbcan_as_msp_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_genes.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_modules.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_modules_completeness.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_msp.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_mustard_as_genes_sum.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/profiles/sample3/sample3_raw.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/ref_dir/database/test_gtdb_r207.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging/ref_dir/hs_8_4_oral_taxo_reference.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_merging.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_parser/module_def.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_parser.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/catalogue_reference.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/database/catalogue_annotation.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/database/catalogue_dbcan.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/database/catalogue_kegg.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/database/catalogue_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/catalogue/database/catalogue_mustard.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/merged_catalogue_info.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rarefaction.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_dbcan_by_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_kegg.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_kegg_by_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_mod_completeness.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_mod_completeness_kegg_only.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_modules.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_modules_kegg_only.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_no_norm_mustard.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_norm_fpkm_kegg.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_norm_fpkm_kegg_by_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_no_rf_norm_fpkm_msp.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_coverage.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_fpkm_raref_0_unmapped_0.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_fpkm_raref_0_unmapped_500.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_fpkm_raref_100_unmapped_0.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_fpkm_raref_900_unmapped_100.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_norm_fpkm_raref_900_unmapped_80.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_raref_100_unmapped_0.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/expected_output/sample_raref_900_unmapped_100.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/mapping/sample.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/mapping/sample_census_stage_1.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler/module.tsv +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_profiler.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_reference_builder/defect_catalogue.fasta.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_reference_builder/test_catalogue.fasta.gz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_reference_builder.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_strain.py +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71/database/eva71.bed +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71/eva71_reference.json +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71/fasta/eva71.fasta +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71_bench/eva71_bench.cram +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71_bench/eva71_bench.cram.crai +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71_bench/eva71_bench.tsv.xz +0 -0
- {meteor-2.0.4 → meteor-2.0.6}/meteor/tests/test_variantcalling/eva71_bench/eva71_bench_census_stage_1.json +0 -0
|
@@ -20,11 +20,13 @@ from packaging.version import Version, parse
|
|
|
20
20
|
from re import findall
|
|
21
21
|
from meteor.session import Session, Component
|
|
22
22
|
from time import perf_counter
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
# from tempfile import mkstemp
|
|
24
25
|
import pysam
|
|
25
26
|
import logging
|
|
26
27
|
import sys
|
|
27
28
|
|
|
29
|
+
|
|
28
30
|
@dataclass
|
|
29
31
|
class Mapper(Session):
|
|
30
32
|
"""Run the bowtie"""
|
|
@@ -126,7 +128,8 @@ class Mapper(Session):
|
|
|
126
128
|
[
|
|
127
129
|
"bowtie2",
|
|
128
130
|
parameters,
|
|
129
|
-
"--mm",
|
|
131
|
+
"--mm",
|
|
132
|
+
"--no-unal",
|
|
130
133
|
"-x",
|
|
131
134
|
str(bowtie_index.resolve()),
|
|
132
135
|
"-U",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import sys
|
|
18
18
|
import logging
|
|
19
|
+
import shutil
|
|
19
20
|
from argparse import ArgumentParser, ArgumentTypeError, Namespace, RawTextHelpFormatter
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
from meteor.session import Component
|
|
@@ -230,7 +231,6 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
230
231
|
fastq_parser.add_argument(
|
|
231
232
|
"-p",
|
|
232
233
|
dest="ispaired",
|
|
233
|
-
default=False,
|
|
234
234
|
action="store_true",
|
|
235
235
|
help="Fastq files are paired.",
|
|
236
236
|
)
|
|
@@ -541,10 +541,10 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
541
541
|
dest="max_depth",
|
|
542
542
|
default=100,
|
|
543
543
|
type=int,
|
|
544
|
-
help="Maximum depth taken in account (default
|
|
544
|
+
help="Maximum depth taken in account (default: %(default)d).",
|
|
545
545
|
)
|
|
546
546
|
strain_parser.add_argument(
|
|
547
|
-
"-t", dest="threads", default=1, type=
|
|
547
|
+
"-t", dest="threads", default=1, type=num_threads, help="Threads count."
|
|
548
548
|
)
|
|
549
549
|
# strain_parser.add_argument(
|
|
550
550
|
# "-c",
|
|
@@ -560,7 +560,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
560
560
|
choices=range(1, 10000),
|
|
561
561
|
metavar="MIN_SNP_DEPTH",
|
|
562
562
|
type=int,
|
|
563
|
-
help="""Minimum snp depth (default >=
|
|
563
|
+
help="""Minimum snp depth (default: >= %(default)d).
|
|
564
564
|
Values should be comprised between 1 and the maximum depth
|
|
565
565
|
(10000 reads are taken in account).""",
|
|
566
566
|
)
|
|
@@ -569,7 +569,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
569
569
|
dest="min_frequency_non_reference",
|
|
570
570
|
default=0.8,
|
|
571
571
|
type=isborned01,
|
|
572
|
-
help="Minimum frequency for non reference allele (default >=
|
|
572
|
+
help="Minimum frequency for non reference allele (default: >= %(default).1f).",
|
|
573
573
|
)
|
|
574
574
|
strain_parser.add_argument(
|
|
575
575
|
"-m",
|
|
@@ -578,7 +578,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
578
578
|
choices=range(1, 101),
|
|
579
579
|
metavar="MIN_MSP_COVERAGE",
|
|
580
580
|
type=int,
|
|
581
|
-
help="""Minimum number of genes from the MSP that are covered (default >=
|
|
581
|
+
help="""Minimum number of genes from the MSP that are covered (default: >= %(default)d).
|
|
582
582
|
Values should be comprised between 1 and 100
|
|
583
583
|
(maximum number of core genes taken in account).""",
|
|
584
584
|
)
|
|
@@ -587,7 +587,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
587
587
|
dest="min_gene_coverage",
|
|
588
588
|
default=0.8,
|
|
589
589
|
type=isborned01,
|
|
590
|
-
help="Minimum gene coverage from 0 to 1 (default >=
|
|
590
|
+
help="Minimum gene coverage from 0 to 1 (default: >= %(default).1f).",
|
|
591
591
|
)
|
|
592
592
|
strain_parser.add_argument(
|
|
593
593
|
"-o",
|
|
@@ -600,7 +600,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
600
600
|
"--kc",
|
|
601
601
|
dest="keep_consensus",
|
|
602
602
|
action="store_true",
|
|
603
|
-
help="Keep consensus marker genes (default False, set to True to recompute strain)",
|
|
603
|
+
help="Keep consensus marker genes (default: False, set to True to recompute strain)",
|
|
604
604
|
)
|
|
605
605
|
strain_parser.add_argument(
|
|
606
606
|
"--tmp",
|
|
@@ -623,14 +623,14 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
623
623
|
dest="max_gap",
|
|
624
624
|
default=0.5,
|
|
625
625
|
type=isborned01,
|
|
626
|
-
help="Removes sites constitued of >= cutoff gap character (default >=
|
|
626
|
+
help="Removes sites constitued of >= cutoff gap character (default: >= %(default).1f).",
|
|
627
627
|
)
|
|
628
628
|
tree_parser.add_argument(
|
|
629
629
|
"-c",
|
|
630
630
|
dest="gap_char",
|
|
631
631
|
default="-",
|
|
632
632
|
type=str,
|
|
633
|
-
help="Gap character (default
|
|
633
|
+
help="Gap character (default: %(default)s).",
|
|
634
634
|
)
|
|
635
635
|
tree_parser.add_argument(
|
|
636
636
|
"-f",
|
|
@@ -638,21 +638,21 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
638
638
|
default=None,
|
|
639
639
|
choices=["png", "svg", "pdf", "txt"],
|
|
640
640
|
type=str,
|
|
641
|
-
help="Output image format (default
|
|
641
|
+
help="Output image format (default: %(default)s).",
|
|
642
642
|
)
|
|
643
643
|
tree_parser.add_argument(
|
|
644
644
|
"-w",
|
|
645
645
|
dest="width",
|
|
646
646
|
default=500,
|
|
647
647
|
type=int,
|
|
648
|
-
help="Output image width (default
|
|
648
|
+
help="Output image width (default: %(default)dpx).",
|
|
649
649
|
)
|
|
650
650
|
tree_parser.add_argument(
|
|
651
651
|
"-H",
|
|
652
652
|
dest="height",
|
|
653
653
|
default=500,
|
|
654
654
|
type=int,
|
|
655
|
-
help="Output image height (default
|
|
655
|
+
help="Output image height (default: %(default)dpx).",
|
|
656
656
|
)
|
|
657
657
|
tree_parser.add_argument(
|
|
658
658
|
"-o",
|
|
@@ -662,7 +662,7 @@ def get_arguments() -> Namespace: # pragma: no cover
|
|
|
662
662
|
help="Path to output directory.",
|
|
663
663
|
)
|
|
664
664
|
tree_parser.add_argument(
|
|
665
|
-
"-t", dest="threads", default=
|
|
665
|
+
"-t", dest="threads", default=num_threads, type=int, help="Threads count."
|
|
666
666
|
)
|
|
667
667
|
tree_parser.add_argument(
|
|
668
668
|
"--tmp",
|
|
@@ -804,7 +804,7 @@ def main() -> None: # pragma: no cover
|
|
|
804
804
|
meteor.ref_name = "test"
|
|
805
805
|
meteor.ref_dir = Path(tmpdirname) / "ref"
|
|
806
806
|
meteor.threads = 1
|
|
807
|
-
meteor.tmp_path = Path(
|
|
807
|
+
meteor.tmp_path = Path(tmpdirname)
|
|
808
808
|
meteor.tmp_dir = Path(tmpdirname)
|
|
809
809
|
meteor.mapping_dir = Path(tmpdirname) / "map"
|
|
810
810
|
meteor.fastq_dir = Path(tmpdirname)
|
|
@@ -819,6 +819,9 @@ def main() -> None: # pragma: no cover
|
|
|
819
819
|
meteor.fastq_dir = Path(tmpdirname) / "test2"
|
|
820
820
|
counter = Counter(meteor, "best", "end-to-end", 80, 0.97, 100, False, True)
|
|
821
821
|
counter.execute()
|
|
822
|
+
# Remove the mapping directory and its contents
|
|
823
|
+
shutil.rmtree(Path(tmpdirname) / "test")
|
|
824
|
+
shutil.rmtree(Path(tmpdirname) / "test2")
|
|
822
825
|
meteor.mapped_sample_dir = meteor.mapping_dir / "test"
|
|
823
826
|
meteor.strain_dir = Path(tmpdirname) / "strain"
|
|
824
827
|
strain_detector = Strain(meteor, 100, 2, 0.2, 10, 0.2, False)
|
|
@@ -826,6 +829,8 @@ def main() -> None: # pragma: no cover
|
|
|
826
829
|
meteor.mapped_sample_dir = meteor.mapping_dir / "test2"
|
|
827
830
|
strain_detector = Strain(meteor, 100, 2, 0.2, 10, 0.2, False)
|
|
828
831
|
strain_detector.execute()
|
|
832
|
+
# Remove the mapping directory and its contents
|
|
833
|
+
shutil.rmtree(meteor.mapping_dir)
|
|
829
834
|
meteor.tree_dir = Path(tmpdirname) / "tree"
|
|
830
835
|
trees = TreeBuilder(
|
|
831
836
|
meteor,
|
|
@@ -836,6 +841,9 @@ def main() -> None: # pragma: no cover
|
|
|
836
841
|
"-",
|
|
837
842
|
)
|
|
838
843
|
trees.execute()
|
|
844
|
+
shutil.rmtree(meteor.strain_dir)
|
|
845
|
+
shutil.rmtree(meteor.tree_dir)
|
|
846
|
+
shutil.rmtree(meteor.ref_dir)
|
|
839
847
|
# Close logging
|
|
840
848
|
logger.handlers[0].close()
|
|
841
849
|
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
5
|
+
# (at your option) any later version.
|
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9
|
+
# GNU General Public License for more details.
|
|
10
|
+
# A copy of the GNU General Public License is available at
|
|
11
|
+
# http://www.gnu.org/licenses/gpl-3.0.html
|
|
12
|
+
|
|
13
|
+
"""Effective phylogeny"""
|
|
14
|
+
import re
|
|
15
|
+
import logging
|
|
16
|
+
import sys
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from meteor.session import Session, Component
|
|
19
|
+
from subprocess import check_call, run
|
|
20
|
+
from time import perf_counter
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
import tempfile
|
|
23
|
+
from tempfile import NamedTemporaryFile
|
|
24
|
+
from packaging.version import Version, parse
|
|
25
|
+
from collections import OrderedDict
|
|
26
|
+
from datetime import datetime
|
|
27
|
+
from typing import Iterable
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class Phylogeny(Session):
|
|
32
|
+
"""Run the fastree"""
|
|
33
|
+
|
|
34
|
+
meteor: type[Component]
|
|
35
|
+
msp_file_list: list[Path]
|
|
36
|
+
max_gap: float
|
|
37
|
+
gap_char: str
|
|
38
|
+
|
|
39
|
+
def compute_site_info(self, sequences: Iterable[str]) -> list[float]:
|
|
40
|
+
"""Calculate the percentage of "_" at each position
|
|
41
|
+
:param sequences: (List) A list of sequence
|
|
42
|
+
:return: (List) A list of the ratio of gap at each position
|
|
43
|
+
"""
|
|
44
|
+
return [float(col.count(self.gap_char)) / len(col) for col in zip(*sequences)]
|
|
45
|
+
|
|
46
|
+
def clean_sites(
|
|
47
|
+
self, msp_file: Path, output: tempfile._TemporaryFileWrapper
|
|
48
|
+
) -> dict[str, str]:
|
|
49
|
+
"""Clean msp sequence according to a certain level of gap at each sites.
|
|
50
|
+
:param msp_file: (Path) Fasta file
|
|
51
|
+
:param output_file: (Path) Output cleaned fasta file
|
|
52
|
+
:return: Dict of cleaned sequences
|
|
53
|
+
"""
|
|
54
|
+
gene_dict = OrderedDict(
|
|
55
|
+
(gene_id, seq) for gene_id, seq in self.get_sequences_class(msp_file)
|
|
56
|
+
)
|
|
57
|
+
info_ratio = self.compute_site_info(gene_dict.values())
|
|
58
|
+
resultdict = {}
|
|
59
|
+
for gene_id, seq in gene_dict.items():
|
|
60
|
+
# assert len(info_ratio) == len(seq)
|
|
61
|
+
output_seq = "".join(
|
|
62
|
+
seq[i] for i, perc in enumerate(info_ratio) if perc <= self.max_gap
|
|
63
|
+
)
|
|
64
|
+
print(f">{gene_id}\n{output_seq}\n", file=output)
|
|
65
|
+
resultdict[gene_id] = output_seq
|
|
66
|
+
return resultdict
|
|
67
|
+
|
|
68
|
+
def compute_mutation_rate(self, seq1, seq2):
|
|
69
|
+
"""Compute mutation rate between two sequences."""
|
|
70
|
+
if len(seq1) != len(seq2):
|
|
71
|
+
raise ValueError("Sequences must be of the same length.")
|
|
72
|
+
|
|
73
|
+
mutations = sum(nuc1 != nuc2 for nuc1, nuc2 in zip(seq1, seq2))
|
|
74
|
+
return mutations / len(seq1)
|
|
75
|
+
|
|
76
|
+
def set_tree_config(
|
|
77
|
+
self, raxml_ng_version: str, tree_files: list[Path]
|
|
78
|
+
) -> dict: # pragma: no cover
|
|
79
|
+
"""Define the census configuration
|
|
80
|
+
|
|
81
|
+
:param cmd: A string of the specific parameters
|
|
82
|
+
:param cram_file: A path to the sam file
|
|
83
|
+
:return: (Dict) A dict object with the census 1 config
|
|
84
|
+
"""
|
|
85
|
+
config = {
|
|
86
|
+
"meteor_version": self.meteor.version,
|
|
87
|
+
"phylogeny": {
|
|
88
|
+
"phylogeny_tool": "raxml-ng",
|
|
89
|
+
"phylogeny_version": raxml_ng_version,
|
|
90
|
+
"phylogeny_date": datetime.now().strftime("%Y-%m-%d"),
|
|
91
|
+
"tree_files": ",".join([tree.name for tree in tree_files]),
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
return config
|
|
95
|
+
|
|
96
|
+
def execute(self) -> None:
|
|
97
|
+
logging.info("Launch phylogeny analysis")
|
|
98
|
+
# Define the regex pattern to match the version number
|
|
99
|
+
version_pattern = re.compile(r"RAxML-NG v\. (\d+\.\d+\.\d+)")
|
|
100
|
+
raxml_ng_help = run(
|
|
101
|
+
["raxml-ng", "--version"], capture_output=True
|
|
102
|
+
).stdout.decode("utf-8")
|
|
103
|
+
match = version_pattern.search(raxml_ng_help)
|
|
104
|
+
# Check if a match is found
|
|
105
|
+
if match:
|
|
106
|
+
raxml_ng_version = match.group(1)
|
|
107
|
+
if parse(raxml_ng_version) < Version("1.0.0"):
|
|
108
|
+
logging.error(
|
|
109
|
+
"The raxml-ng version %s is outdated for meteor. Please update raxml-ng to >=1.0.0.",
|
|
110
|
+
raxml_ng_version,
|
|
111
|
+
)
|
|
112
|
+
sys.exit(1)
|
|
113
|
+
else:
|
|
114
|
+
logging.error("Failed to determine the raxml-ng version.")
|
|
115
|
+
# Start phylogenies
|
|
116
|
+
start = perf_counter()
|
|
117
|
+
tree_files: list[Path] = []
|
|
118
|
+
msp_count = len(self.msp_file_list)
|
|
119
|
+
for idx, msp_file in enumerate(self.msp_file_list, start=1):
|
|
120
|
+
logging.info(
|
|
121
|
+
"Start analysis of MSP %s: %d/%d", msp_file.name, idx, msp_count
|
|
122
|
+
)
|
|
123
|
+
with NamedTemporaryFile(
|
|
124
|
+
mode="wt", dir=self.meteor.tmp_dir, suffix=".fasta"
|
|
125
|
+
) as temp_clean:
|
|
126
|
+
tree_file = self.meteor.tree_dir / f"{msp_file.name}".replace(
|
|
127
|
+
".fasta", ""
|
|
128
|
+
)
|
|
129
|
+
# Clean sites
|
|
130
|
+
cleaned_seqs = self.clean_sites(msp_file, temp_clean)
|
|
131
|
+
logging.info("Clean sites for MSP %d/%d", idx, msp_count)
|
|
132
|
+
if len(cleaned_seqs) >= 4:
|
|
133
|
+
# Compute trees
|
|
134
|
+
result = check_call(
|
|
135
|
+
[
|
|
136
|
+
"raxml-ng",
|
|
137
|
+
"--threads",
|
|
138
|
+
str(self.meteor.threads),
|
|
139
|
+
"--msa",
|
|
140
|
+
temp_clean.name,
|
|
141
|
+
"--model",
|
|
142
|
+
"GTR+G",
|
|
143
|
+
"--redo",
|
|
144
|
+
"--prefix",
|
|
145
|
+
str(tree_file.resolve()),
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
if result != 0:
|
|
149
|
+
logging.error("raxml-ng failed with return code %d", result)
|
|
150
|
+
else:
|
|
151
|
+
logging.info(
|
|
152
|
+
"MSP %s have less than 4 sequences, we compute the mutation rate",
|
|
153
|
+
msp_file.name,
|
|
154
|
+
)
|
|
155
|
+
with open(tree_file.parent / "cleaned_sequences.fasta", "w") as f:
|
|
156
|
+
for seq_name, sequence in cleaned_seqs.items():
|
|
157
|
+
f.write(f">{seq_name}\n{sequence}\n")
|
|
158
|
+
mutation_rate = []
|
|
159
|
+
seq_ids = list(cleaned_seqs.keys())
|
|
160
|
+
for i in range(len(seq_ids)):
|
|
161
|
+
for j in range(i + 1, len(seq_ids)):
|
|
162
|
+
seq1 = cleaned_seqs[seq_ids[i]]
|
|
163
|
+
seq2 = cleaned_seqs[seq_ids[j]]
|
|
164
|
+
mutation_rate += [self.compute_mutation_rate(seq1, seq2)]
|
|
165
|
+
# Construct Newick format string
|
|
166
|
+
with open(tree_file.with_suffix(".tree"), "wt") as tree:
|
|
167
|
+
if len(seq_ids) == 2:
|
|
168
|
+
tree.write(
|
|
169
|
+
f"({seq_ids[0]}:{mutation_rate[0]}, {seq_ids[1]}:{mutation_rate[0]});"
|
|
170
|
+
)
|
|
171
|
+
else: # case 3
|
|
172
|
+
min_rate_idx = mutation_rate.index(min(mutation_rate))
|
|
173
|
+
if (
|
|
174
|
+
min_rate_idx == 0
|
|
175
|
+
): # seq1 and seq2 have the smallest distance
|
|
176
|
+
tree.write(
|
|
177
|
+
f"(({seq_ids[0]}:{mutation_rate[0]}, {seq_ids[1]}:{mutation_rate[0]}):{mutation_rate[1]}, {seq_ids[2]}:{mutation_rate[1]});"
|
|
178
|
+
)
|
|
179
|
+
else: # seq1 and seq3 have the smallest distance
|
|
180
|
+
tree.write(
|
|
181
|
+
f"(({seq_ids[0]}:{mutation_rate[1]}, {seq_ids[2]}:{mutation_rate[1]}):{mutation_rate[0]}, {seq_ids[1]}:{mutation_rate[0]});"
|
|
182
|
+
)
|
|
183
|
+
tree_files.append(tree_file)
|
|
184
|
+
logging.info("Completed MSP tree %d/%d", idx, msp_count)
|
|
185
|
+
logging.info("Completed phylogeny in %f seconds", perf_counter() - start)
|
|
186
|
+
config = self.set_tree_config(raxml_ng_version, tree_files)
|
|
187
|
+
self.save_config(config, self.meteor.tree_dir / "census_stage_4.json")
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import sys
|
|
16
16
|
import logging
|
|
17
|
+
import lzma
|
|
17
18
|
import pandas as pd
|
|
18
19
|
from dataclasses import dataclass, field
|
|
19
20
|
from meteor.variantcalling import VariantCalling
|
|
@@ -23,6 +24,7 @@ from pathlib import Path
|
|
|
23
24
|
from time import perf_counter
|
|
24
25
|
from io import StringIO
|
|
25
26
|
import pysam
|
|
27
|
+
from shutil import rmtree
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
@dataclass
|
|
@@ -160,7 +162,7 @@ class Strain(Session):
|
|
|
160
162
|
len(msp_with_overlapping_genes["msp_name"].values),
|
|
161
163
|
)
|
|
162
164
|
for msp_name in msp_with_overlapping_genes["msp_name"].values:
|
|
163
|
-
msp_file = self.json_data["directory"] / Path(msp_name + ".fasta")
|
|
165
|
+
msp_file = self.json_data["directory"] / Path(msp_name + ".fasta.xz")
|
|
164
166
|
msp_seq = ""
|
|
165
167
|
for gene_id in msp_content[msp_content["msp_name"] == msp_name][
|
|
166
168
|
"gene_id"
|
|
@@ -169,7 +171,7 @@ class Strain(Session):
|
|
|
169
171
|
msp_seq += gene_dict[gene_id]
|
|
170
172
|
else:
|
|
171
173
|
msp_seq += "-" * len(gene_dict[gene_id])
|
|
172
|
-
with
|
|
174
|
+
with lzma.open(msp_file, "wt", preset=0) as msp:
|
|
173
175
|
print(
|
|
174
176
|
f">{self.json_data['census']['sample_info']['sample_name']}\n{msp_seq}\n",
|
|
175
177
|
file=msp,
|
|
@@ -247,7 +249,7 @@ class Strain(Session):
|
|
|
247
249
|
)
|
|
248
250
|
consensus_file = (
|
|
249
251
|
self.json_data["directory"]
|
|
250
|
-
/ f"{sample_info['sample_name']}_consensus.fasta"
|
|
252
|
+
/ f"{sample_info['sample_name']}_consensus.fasta.xz"
|
|
251
253
|
)
|
|
252
254
|
# count_file = (
|
|
253
255
|
# self.json_data["mapped_sample_dir"] / f"{sample_info['sample_name']}.tsv"
|
|
@@ -278,3 +280,5 @@ class Strain(Session):
|
|
|
278
280
|
self.meteor.fastq_dir,
|
|
279
281
|
)
|
|
280
282
|
sys.exit(1)
|
|
283
|
+
else:
|
|
284
|
+
rmtree(self.meteor.tmp_dir, ignore_errors=True)
|
|
@@ -71,6 +71,6 @@ def test_execute(vc_builder: VariantCalling) -> None:
|
|
|
71
71
|
assert output_vcf.exists()
|
|
72
72
|
output_consensus = (
|
|
73
73
|
vc_builder.census["directory"]
|
|
74
|
-
/ f"{vc_builder.census['census']['sample_info']['sample_name']}_consensus.fasta"
|
|
74
|
+
/ f"{vc_builder.census['census']['sample_info']['sample_name']}_consensus.fasta.xz"
|
|
75
75
|
)
|
|
76
76
|
assert output_consensus.exists()
|
|
@@ -22,7 +22,8 @@ from meteor.phylogeny import Phylogeny
|
|
|
22
22
|
import logging
|
|
23
23
|
import sys
|
|
24
24
|
import pandas as pd
|
|
25
|
-
|
|
25
|
+
import lzma
|
|
26
|
+
from shutil import rmtree
|
|
26
27
|
|
|
27
28
|
@dataclass
|
|
28
29
|
class TreeBuilder(Session):
|
|
@@ -48,12 +49,15 @@ class TreeBuilder(Session):
|
|
|
48
49
|
# Concatenate files that occur in more than one directory
|
|
49
50
|
for filename, paths in msp_file_dict.items():
|
|
50
51
|
if len(paths) > 1:
|
|
51
|
-
res = self.meteor.tree_dir / f"{filename}"
|
|
52
|
+
res = self.meteor.tree_dir / f"{filename}".replace(
|
|
53
|
+
".fasta.xz", ".fasta"
|
|
54
|
+
)
|
|
52
55
|
with res.open("wt", encoding="UTF-8") as outfile:
|
|
53
56
|
for path in paths:
|
|
54
|
-
with open(path, "
|
|
57
|
+
with lzma.open(path, "rt") as infile:
|
|
55
58
|
outfile.write(infile.read())
|
|
56
59
|
msp_list += [res]
|
|
60
|
+
logging.info(f"{len(msp_list)} MSPs are available for tree analysis.")
|
|
57
61
|
return msp_list
|
|
58
62
|
|
|
59
63
|
def get_msp_distance(self, tree: ete3.TreeNode) -> pd.DataFrame:
|
|
@@ -79,8 +83,8 @@ class TreeBuilder(Session):
|
|
|
79
83
|
else:
|
|
80
84
|
logging.info("%d samples have been detected.", len(all_census))
|
|
81
85
|
msp_file_dict = defaultdict(list)
|
|
82
|
-
for filepath in self.meteor.strain_dir.glob("**/*.fasta"):
|
|
83
|
-
if not filepath.name.endswith("_consensus.fasta"):
|
|
86
|
+
for filepath in self.meteor.strain_dir.glob("**/*.fasta.xz"):
|
|
87
|
+
if not filepath.name.endswith("_consensus.fasta.xz"):
|
|
84
88
|
msp_file_dict[filepath.name].append(filepath)
|
|
85
89
|
# Concatenate msp files
|
|
86
90
|
msp_file_list = self.concatenate(msp_file_dict)
|
|
@@ -91,7 +95,13 @@ class TreeBuilder(Session):
|
|
|
91
95
|
phylogeny_process.execute()
|
|
92
96
|
# Analyze tree data
|
|
93
97
|
for msp_file in msp_file_list:
|
|
94
|
-
|
|
98
|
+
# Check for a .raxml.bestTree file
|
|
99
|
+
raxml_tree_file = self.meteor.tree_dir / f"{msp_file.stem}.raxml.bestTree"
|
|
100
|
+
if raxml_tree_file.exists():
|
|
101
|
+
tree_file = raxml_tree_file
|
|
102
|
+
else:
|
|
103
|
+
# If no .raxml.bestTree file exists, check for a .tree file
|
|
104
|
+
tree_file = self.meteor.tree_dir / f"{msp_file.stem}.tree"
|
|
95
105
|
img_file = self.meteor.tree_dir / f"{msp_file.stem}.{self.format}"
|
|
96
106
|
try:
|
|
97
107
|
msp_tree = Tree(str(tree_file.resolve()))
|
|
@@ -117,3 +127,4 @@ class TreeBuilder(Session):
|
|
|
117
127
|
)
|
|
118
128
|
except ete3.parser.newick.NewickError:
|
|
119
129
|
logging.info("Not sufficient info in %s.", str(tree_file.resolve()))
|
|
130
|
+
rmtree(self.meteor.tmp_dir, ignore_errors=True)
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
import logging
|
|
16
16
|
import sys
|
|
17
17
|
import tempfile
|
|
18
|
-
|
|
18
|
+
import lzma
|
|
19
|
+
from subprocess import check_call, run, Popen, PIPE
|
|
19
20
|
from dataclasses import dataclass
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
from datetime import datetime
|
|
@@ -232,7 +233,7 @@ class VariantCalling(Session):
|
|
|
232
233
|
)
|
|
233
234
|
consensus_file = (
|
|
234
235
|
self.census["directory"]
|
|
235
|
-
/ f"{self.census['census']['sample_info']['sample_name']}_consensus.fasta"
|
|
236
|
+
/ f"{self.census['census']['sample_info']['sample_name']}_consensus.fasta.xz"
|
|
236
237
|
)
|
|
237
238
|
reference_file = (
|
|
238
239
|
self.meteor.ref_dir
|
|
@@ -388,7 +389,7 @@ class VariantCalling(Session):
|
|
|
388
389
|
perf_counter() - startlowcovbed,
|
|
389
390
|
)
|
|
390
391
|
startlowcov = perf_counter()
|
|
391
|
-
|
|
392
|
+
bcftools_process = Popen(
|
|
392
393
|
[
|
|
393
394
|
"bcftools",
|
|
394
395
|
"consensus",
|
|
@@ -398,11 +399,19 @@ class VariantCalling(Session):
|
|
|
398
399
|
"-",
|
|
399
400
|
"-f",
|
|
400
401
|
str(reference_file.resolve()),
|
|
401
|
-
"-o",
|
|
402
|
-
str(consensus_file.resolve()),
|
|
403
402
|
str(vcf_file.resolve()),
|
|
404
|
-
]
|
|
403
|
+
],
|
|
404
|
+
stdout=PIPE,
|
|
405
405
|
)
|
|
406
|
+
# capture output of bcftools_process
|
|
407
|
+
bcftools_output = bcftools_process.communicate()[0]
|
|
408
|
+
|
|
409
|
+
# compress output using lzma
|
|
410
|
+
compressed_output = lzma.compress(bcftools_output)
|
|
411
|
+
|
|
412
|
+
# write compressed output to file
|
|
413
|
+
with open(str(consensus_file.resolve()), "wb") as f:
|
|
414
|
+
f.write(compressed_output)
|
|
406
415
|
logging.info(
|
|
407
416
|
"Completed low coverage regions filtering step in %f seconds",
|
|
408
417
|
perf_counter() - startlowcov,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "meteor"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.6"
|
|
4
4
|
description = "Meteor - A plateform for quantitative metagenomic profiling of complex ecosystems"
|
|
5
5
|
authors = ["Amine Ghozlane <amine.ghozlane@pasteur.fr>", "Florence Thirion <florence.thirion@inrae.fr>"]
|
|
6
6
|
license = "GPL-3.0-or-later"
|