Skip to content

Commit

Permalink
Merge branch '80_amrfinder_database_type' into 77_amrfinder_ncbi_data…
Browse files Browse the repository at this point in the history
…base
  • Loading branch information
VinzentRisch committed Jul 5, 2024
2 parents 1f252ac + 07e9f52 commit 13edaa5
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions q2_amr/amrfinderplus/types/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ def _validate_(self, level):
pass


def _path_maker(name):
return str(name)


class AMRFinderPlusDatabaseDirFmt(model.DirectoryFormat):
amr_lib = model.File("AMR.LIB", format=TextFormat)
amr_lib_comp = model.FileCollection(r"^AMR\.LIB\.h3.$", format=BinaryFormat)
Expand All @@ -46,10 +42,26 @@ class AMRFinderPlusDatabaseDirFmt(model.DirectoryFormat):
amr_cds_comp = model.FileCollection(r"^AMR_CDS\.n..$", format=BinaryFormat)
amr_cds = model.File("AMR_CDS", format=MixedCaseDNAFASTAFormat)

def __init__(self, path, mode):
super().__init__(path, mode)
@amr_lib_comp.set_path_maker
def amr_lib_comp_path_maker(self):
return r"^AMR\.LIB\.h3.$"

@amrprot_blast.set_path_maker
def amrprot_blast_path_maker(self):
return r"^AMRProt\.p..$"

@amr_dna.set_path_maker
def amr_dna_path_maker(self):
return r"^AMR_DNA-[a-zA-Z_]+$"

@amr_dna_comp.set_path_maker
def amr_dna_comp_path_maker(self):
return r"^AMR_DNA-[a-zA-Z_]+\.n..$"

@amr_cds_comp.set_path_maker
def amr_cds_comp_path_maker(self):
return r"^AMR_CDS\.n..$"

# Overwrite path maker methods for all file collections
for var_name, var_value in vars(self.__class__).items():
if isinstance(var_value, model.FileCollection):
var_value.set_path_maker(_path_maker)
@amr_dna_tab.set_path_maker
def amr_dna_tab_path_maker(self):
return r"^AMR_DNA-[a-zA-Z_]+\.tab$"

0 comments on commit 13edaa5

Please sign in to comment.