Skip to content

Commit

Permalink
Merge pull request #64 from jodyphelan/master
Browse files Browse the repository at this point in the history
add tb tests
  • Loading branch information
cimendes authored Oct 11, 2021
2 parents a6bcd9d + 58512a2 commit ee85f6d
Show file tree
Hide file tree
Showing 7 changed files with 1,109 additions and 21 deletions.
18 changes: 10 additions & 8 deletions hAMRonization/TBProfilerIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import json
from .Interfaces import hAMRonizedResultIterator

required_metadata = ['analysis_software_version',
'reference_database_version']
required_metadata = []


class TBProfilerIterator(hAMRonizedResultIterator):
Expand All @@ -15,15 +14,16 @@ def __init__(self, source, metadata):

self.field_mapping = {
'filename': 'input_file_name',
'gene': 'gene_symbol',
'gene': 'gene_name',
'gene_symbol': 'gene_symbol',
'gene_name': 'gene_name',
'drug': 'drug_class',
'type': 'genetic_variation_type',
'frequency': 'variant_frequency',
'db_name': 'reference_database_id',
'db_version': 'reference_database_version',
'tbprofiler_version': 'analysis_software_version'

'software_name': 'analysis_software_version',
'tbprofiler_version': 'analysis_software_version',
'reference_accession': 'reference_accession'
}

super().__init__(source, self.field_mapping, self.metadata)
Expand All @@ -38,14 +38,16 @@ def parse(self, handle):
for drug in variant["drugs"]:
result = {
'filename': handle.name,
'gene': variant['gene'],
'gene_symbol': variant['gene'],
'gene_name': variant['gene'],
'drug': drug['drug'],
'type': 'protein_variant' if variant['change'][0]=="p" else "nucleotide_variant",
'frequency': variant['freq'],
'db_name': json_obj['db_version']['name'],
'db_version': json_obj['db_version']['commit'],
'tbprofiler_version': json_obj['tbprofiler_version']
'tbprofiler_version': json_obj['tbprofiler_version'],
'software_name': 'tb-profiler',
'reference_accession': variant['feature_id']
}
yield self.hAMRonize(result, self.metadata)

9 changes: 6 additions & 3 deletions hAMRonization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from hAMRonization import CSStarIO
from hAMRonization import AmrPlusPlusIO
from hAMRonization import ResFamsIO

from hAMRonization import TBProfilerIO

_FormatToIterator = {
"abricate": AbricateIO.AbricateIterator,
Expand All @@ -34,7 +34,8 @@
"staramr": StarAmrIO.StarAmrIterator,
"csstar": CSStarIO.CSStarIterator,
"amrplusplus": AmrPlusPlusIO.AmrPlusPlusIterator,
"resfams": ResFamsIO.ResFamsIterator
"resfams": ResFamsIO.ResFamsIterator,
"tbprofiler": TBProfilerIO.TBProfilerIterator
}

_ReportFileToUse = {
Expand All @@ -52,7 +53,8 @@
"staramr": "resfinder.tsv",
"csstar": "OUTPUT.tsv",
"amrplusplus": "gene.tsv",
"resfams": "resfams.tblout"
"resfams": "resfams.tblout",
"tbprofiler": "OUTPUT.results.json"
}


Expand All @@ -72,6 +74,7 @@
"amrplusplus": AmrPlusPlusIO.required_metadata,
"resfams": ResFamsIO.required_metadata,
"groot": GrootIO.required_metadata,
"tbprofiler": TBProfilerIO.required_metadata,
}


Expand Down
4 changes: 4 additions & 0 deletions hAMRonization/hAMRonizedResult.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class hAMRonizedResult():
reference_accession: str
analysis_software_name: str
analysis_software_version: str

# variant specific optional fields
variant_frequency: float = None
genetic_variation_type: str = None

# optional fields
sequence_identity: float = None
Expand Down
Loading

0 comments on commit ee85f6d

Please sign in to comment.