Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add three new parameters to run_amrfinderplus_n #97

Merged
merged 66 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d33e0cb
added new amrfinder directory and moved types to card directory
VinzentRisch Jun 28, 2024
32e8b7c
dirformat with filecollections
VinzentRisch Jul 1, 2024
d1b2ca6
dirformat with validating all filepaths
VinzentRisch Jul 1, 2024
facc75d
added test data to package data
VinzentRisch Jul 2, 2024
f948195
added amrprot.pot file to git
VinzentRisch Jul 2, 2024
c445800
merge main
VinzentRisch Jul 3, 2024
0670d7e
added new annotation format
VinzentRisch Jul 3, 2024
bfafdb8
added sampledata and feature data dir fmts
VinzentRisch Jul 4, 2024
bb9220c
register all formats
VinzentRisch Jul 4, 2024
317e5cb
using filecollections for the database format
VinzentRisch Jul 4, 2024
71a8da2
merge 80
VinzentRisch Jul 4, 2024
0bf7f20
renamed to dirfmt
VinzentRisch Jul 4, 2024
060f24d
merge 80
VinzentRisch Jul 4, 2024
8378b45
overwrite all pathmakers with code from busco moshpit
VinzentRisch Jul 4, 2024
82a1558
added field to annotation format
VinzentRisch Jul 4, 2024
f42d845
changed name of file in annotation format to allow oter names
VinzentRisch Jul 4, 2024
7e31553
added mags action
VinzentRisch Jul 5, 2024
514688c
registered annotations types in plusgin setup
VinzentRisch Jul 5, 2024
6deb616
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 5, 2024
a017eeb
changes
VinzentRisch Jul 5, 2024
07e9f52
Revert "overwrite all pathmakers with code from busco moshpit"
VinzentRisch Jul 5, 2024
78c4329
Merge branch '80_amrfinder_database_type' into 85_amrfinderplusannota…
VinzentRisch Jul 5, 2024
09156bb
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 5, 2024
9237c73
working action
VinzentRisch Jul 5, 2024
34a34b8
removed nested structure of annotaion type
VinzentRisch Jul 5, 2024
c004300
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 5, 2024
4e38e21
working action with non nested output format
VinzentRisch Jul 5, 2024
16db485
changed magid to id in mags annotaiton
VinzentRisch Jul 8, 2024
8a902ed
moved run fucntion into utils added protein option
VinzentRisch Jul 8, 2024
0cb8492
changed utils to not inlcude _ in filenames
VinzentRisch Jul 9, 2024
4f09ee7
changed type of featuredata one to also include mutations in name
VinzentRisch Jul 9, 2024
f10dcb3
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 9, 2024
bbaca6e
changed type and path_maker
VinzentRisch Jul 10, 2024
81f0fbb
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 10, 2024
7577214
added sampledata contigs as input
VinzentRisch Jul 10, 2024
b97152f
added validation positive for emty files
VinzentRisch Jul 10, 2024
ac8f92c
Merge branch '85_amrfinderplusannotation_type' into 87_annotate_mags_…
VinzentRisch Jul 10, 2024
fa019d5
fixed bug in mutations empty file creation
VinzentRisch Jul 10, 2024
86babac
fixed other bug in mutations empty file creation
VinzentRisch Jul 10, 2024
783870d
changed utils protein and nucleotide naming
VinzentRisch Jul 11, 2024
4b9c200
changed utils protein and nucleotide naming 2
VinzentRisch Jul 11, 2024
107c039
Revert "changed utils protein and nucleotide naming"
VinzentRisch Jul 11, 2024
92c8400
Revert "changed utils protein and nucleotide naming 2"
VinzentRisch Jul 11, 2024
3813a2b
changed mag and samplename addition to main function
VinzentRisch Jul 11, 2024
14a3b62
added tests for utils and sample data
VinzentRisch Jul 12, 2024
db37f81
changed the way manifest is loaded
VinzentRisch Jul 12, 2024
1b49424
merge main
VinzentRisch Jul 16, 2024
a0343d9
added database_format_version
VinzentRisch Jul 16, 2024
a1abc26
Merge branch '91_adding_database_format_version' into 87_annotate_mag…
VinzentRisch Jul 16, 2024
06e809a
added cureated_indet as parameter
VinzentRisch Jul 16, 2024
bff9595
bugfix missing parameter
VinzentRisch Jul 16, 2024
26e66a6
Merge branch 'main' into 87_annotate_mags_amrfinderplus
VinzentRisch Jul 16, 2024
c9a12a9
bug parameter added in mocked function
VinzentRisch Jul 16, 2024
b215266
merge main
VinzentRisch Jul 16, 2024
1d94b24
renaming tests
VinzentRisch Jul 16, 2024
f642503
chnages after review
VinzentRisch Jul 17, 2024
e4c6bfd
added s in utils sequneces
VinzentRisch Jul 17, 2024
7a05e70
changed plugin setup description
VinzentRisch Jul 17, 2024
57e20da
removed AMRFinderplusannotation type
VinzentRisch Jul 23, 2024
16b413f
removed multidirvalidation mixing
VinzentRisch Jul 23, 2024
869e03c
chnages in annotation action
VinzentRisch Jul 23, 2024
73c2c50
merge 94
VinzentRisch Jul 23, 2024
e3f2abb
added three new parameters
VinzentRisch Jul 23, 2024
f636e73
added typemap for parameters
VinzentRisch Jul 24, 2024
a80b152
Merge branch 'main' into 96_add_parameters
VinzentRisch Jul 25, 2024
1986cb8
added stop
VinzentRisch Jul 26, 2024
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
5 changes: 5 additions & 0 deletions q2_amr/amrfinderplus/sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def annotate_sample_data_amrfinderplus(
curated_ident: bool = False,
coverage_min: float = 0.5,
translation_table: str = "11",
report_common: bool = False,
gpipe_org: bool = False,
threads: int = None,
) -> (
AMRFinderPlusAnnotationsDirFmt,
Expand Down Expand Up @@ -72,6 +74,9 @@ def annotate_sample_data_amrfinderplus(
curated_ident=curated_ident,
coverage_min=coverage_min,
translation_table=translation_table,
annotation_format=None,
report_common=report_common,
gpipe_org=gpipe_org,
threads=threads,
)

Expand Down
3 changes: 3 additions & 0 deletions q2_amr/amrfinderplus/tests/test_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def mock_run_amrfinderplus_n(
curated_ident,
coverage_min,
translation_table,
annotation_format,
report_common,
gpipe_org,
threads,
):
with open(os.path.join(working_dir, "amr_annotations.tsv"), "w"):
Expand Down
56 changes: 56 additions & 0 deletions q2_amr/amrfinderplus/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def test_run_amrfinderplus_n(self, mock_run_command):
curated_ident=False,
coverage_min=1,
translation_table="11",
annotation_format="prodigal",
report_common=True,
gpipe_org=True,
threads=4,
)
mock_run_command.assert_called_once_with(
Expand Down Expand Up @@ -57,6 +60,10 @@ def test_run_amrfinderplus_n(self, mock_run_command):
"1",
"--translation_table",
"11",
"--annotation_format",
"prodigal",
"--report_common",
"--gpipe_org",
],
"path_dir",
verbose=True,
Expand All @@ -77,6 +84,9 @@ def test_run_amrfinderplus_n_minimal(self, mock_run_command):
curated_ident=True,
coverage_min=None,
translation_table=None,
annotation_format=None,
report_common=False,
gpipe_org=False,
threads=None,
)
mock_run_command.assert_called_once_with(
Expand All @@ -93,3 +103,49 @@ def test_run_amrfinderplus_n_minimal(self, mock_run_command):
"path_dir",
verbose=True,
)

@patch("q2_amr.amrfinderplus.utils.run_command")
def test_run_amrfinderplus_n_value_error_report_common(self, mock_run_command):
with self.assertRaisesRegex(
ValueError, "--p-report-common requires " "--p-plus and --p-organism"
):
run_amrfinderplus_n(
working_dir="path_dir",
amrfinderplus_db="amrfinderplus_db",
dna_sequences=None,
protein_sequences=None,
gff=None,
organism=None,
plus=False,
report_all_equal=False,
ident_min=None,
curated_ident=True,
coverage_min=None,
translation_table=None,
annotation_format=None,
report_common=True,
gpipe_org=False,
threads=None,
)

@patch("q2_amr.amrfinderplus.utils.run_command")
def test_run_amrfinderplus_n_value_error_gpipe_org(self, mock_run_command):
with self.assertRaisesRegex(ValueError, "--p-gpipe_org requires --p-organism"):
run_amrfinderplus_n(
working_dir="path_dir",
amrfinderplus_db="amrfinderplus_db",
dna_sequences=None,
protein_sequences=None,
gff=None,
organism=None,
plus=False,
report_all_equal=False,
ident_min=None,
curated_ident=True,
coverage_min=None,
translation_table=None,
annotation_format=None,
report_common=False,
gpipe_org=True,
threads=None,
)
16 changes: 16 additions & 0 deletions q2_amr/amrfinderplus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ def run_amrfinderplus_n(
curated_ident,
coverage_min,
translation_table,
annotation_format,
report_common,
gpipe_org,
threads,
):
# Check for unallowed parameter combinations
if report_common and (not plus or not organism):
raise ValueError("--p-report-common requires --p-plus and --p-organism")
if gpipe_org and not organism:
raise ValueError("--p-gpipe_org requires --p-organism")

cmd = [
"amrfinder",
"--database",
Expand Down Expand Up @@ -73,6 +82,13 @@ def run_amrfinderplus_n(
cmd.extend(["--coverage_min", str(coverage_min)])
if translation_table:
cmd.extend(["--translation_table", str(translation_table)])
if annotation_format:
cmd.extend(["--annotation_format", str(annotation_format)])
if report_common:
cmd.append("--report_common")
if gpipe_org:
cmd.append("--gpipe_org")

try:
run_command(cmd, working_dir, verbose=True)
except subprocess.CalledProcessError as e:
Expand Down
43 changes: 42 additions & 1 deletion q2_amr/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,35 @@
"Vibrio_vulnificus",
]

organisms_gpipe = [
"Acinetobacter",
"Burkholderia_cepacia_complex",
"Burkholderia_pseudomallei",
"Campylobacter",
"Citrobacter_freundii",
"Clostridioides_difficile",
"Enterobacter_asburiae",
"Enterobacter_cloacae",
"Enterococcus_faecalis",
"Enterococcus_faecium",
"Escherichia_coli_Shigella",
"Klebsiella_oxytoca",
"Klebsiella",
"Neisseria_gonorrhoeae",
"Neisseria_meningitidis",
"Pseudomonas_aeruginosa",
"Salmonella",
"Serratia",
"Staphylococcus_aureus",
"Staphylococcus_pseudintermedius",
"Streptococcus_agalactiae",
"Streptococcus_pneumoniae",
"Streptococcus_pyogenes",
"Vibrio_cholerae",
"Vibrio_parahaemolyticus",
"Vibrio_vulnificus",
]

translation_tables = [
"1",
"2",
Expand Down Expand Up @@ -1156,20 +1185,29 @@
"33",
]

P_gpipe_org, P_organism, _ = TypeMap(
{
(Bool % Choices(True), Str % Choices(organisms_gpipe)): Int,
(Bool % Choices(False), Str % Choices(organisms)): Int,
}
)

plugin.methods.register_function(
function=annotate_sample_data_amrfinderplus,
inputs={
"sequences": SampleData[MAGs | Contigs],
"amrfinderplus_db": AMRFinderPlusDatabase,
},
parameters={
"organism": Str % Choices(organisms),
"organism": P_organism,
"plus": Bool,
"report_all_equal": Bool,
"ident_min": Float % Range(0, 1, inclusive_start=True, inclusive_end=True),
"curated_ident": Bool,
"coverage_min": Float % Range(0, 1, inclusive_start=True, inclusive_end=True),
"translation_table": Str % Choices(translation_tables),
"report_common": Bool,
"gpipe_org": P_gpipe_org,
"threads": Int % Range(0, None, inclusive_start=False),
},
outputs=[
Expand Down Expand Up @@ -1204,6 +1242,9 @@
"coverage_min": "Minimum proportion of reference gene covered for a "
"BLAST-based hit (Methods BLAST or PARTIAL).",
"translation_table": "Translation table used for BLASTX.",
"report_common": "Report proteins common to a taxonomy group.",
"gpipe_org": "Use Pathogen Detection taxgroup names as arguments to the "
"organism option.",
"threads": "The number of threads to use for processing. AMRFinderPlus "
"defaults to 4 on hosts with >= 4 cores. Setting this number higher"
" than the number of cores on the running host may cause blastp to "
Expand Down
Loading