Skip to content

Commit

Permalink
fix annotationformat twice bug
Browse files Browse the repository at this point in the history
  • Loading branch information
VinzentRisch committed Jul 24, 2024
1 parent 4bb7358 commit 5cb10fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
14 changes: 7 additions & 7 deletions q2_amr/amrfinderplus/feature_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ def _get_file_paths(file, mags, proteins, loci):


def _move_or_create_files(src_dir: str, mag_id: str, file_operations: dict):
for file_name, condition, target_dir in file_operations:
if condition:
for file_name, target_dir in file_operations:
if os.path.exists(os.path.join(src_dir, file_name)):
shutil.move(
os.path.join(src_dir, file_name),
os.path.join(str(target_dir), f"{mag_id}_{file_name}"),
)
else:
with open(os.path.join(str(target_dir), file_name), "w"):
with open(os.path.join(str(target_dir), f"{mag_id}_{file_name}"), "w"):
pass


Expand Down Expand Up @@ -134,10 +134,10 @@ def annotate_feature_data_amrfinderplus(
# directory format, if organism, dna_sequence and proteins parameters
# are specified. Else create empty placeholder files.
file_operations = [
("amr_annotations.tsv", True, amr_annotations),
("amr_all_mutations.tsv", organism, amr_all_mutations),
("amr_genes.fasta", mags, amr_genes),
("amr_proteins.fasta", proteins, amr_proteins),
("amr_annotations.tsv", amr_annotations),
("amr_all_mutations.tsv", amr_all_mutations),
("amr_genes.fasta", amr_genes),
("amr_proteins.fasta", amr_proteins),
]

# Loop through each file operation
Expand Down
2 changes: 0 additions & 2 deletions q2_amr/amrfinderplus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def run_amrfinderplus_n(
"-o",
f"{working_dir}/amr_annotations.tsv",
"--print_node",
"--annotation_format",
"prodigal",
]
# Creates nucleotide fasta output if DNA sequences are given as input
if dna_sequences:
Expand Down
2 changes: 1 addition & 1 deletion q2_amr/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

from q2_amr import __version__
from q2_amr.amrfinderplus.database import fetch_amrfinderplus_db
from q2_amr.amrfinderplus.feature_data import annotate_feature_data_amrfinderplus
from q2_amr.amrfinderplus.sample_data import annotate_sample_data_amrfinderplus
from q2_amr.amrfinderplus.sequences import annotate_feature_data_amrfinderplus
from q2_amr.amrfinderplus.types._format import (
AMRFinderPlusAnnotationFormat,
AMRFinderPlusAnnotationsDirFmt,
Expand Down

0 comments on commit 5cb10fe

Please sign in to comment.