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

add tb tests #64

Merged
merged 11 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment I've made this non mandatory but potentially in the final spec it should be?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be lost when I approve and merge. Can you open an issue? ❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!


# optional fields
sequence_identity: float = None
Expand Down
Loading