Skip to content

Commit

Permalink
Merge pull request #94 from phac-nml/update_docs_0.6.0
Browse files Browse the repository at this point in the history
Updated StarAMR README, Tutorial, and settings to include MLST
  • Loading branch information
apetkau authored Sep 11, 2019
2 parents 06ce46b + 3269fe1 commit a6e7f95
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 106 deletions.
105 changes: 76 additions & 29 deletions README.md

Large diffs are not rendered by default.

207 changes: 131 additions & 76 deletions doc/tutorial/staramr-tutorial.ipynb

Large diffs are not rendered by default.

Binary file modified images/search_command.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/settings_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion staramr/blast/JobHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, blast_database_objects_map: Dict[str, AbstractBlastDatabase],
raise Exception("threads is None")

self._threads = threads
self._mlst_version = None

if output_directory is None:
raise Exception("output_directory is None")
Expand All @@ -65,6 +66,7 @@ def __init__(self, blast_database_objects_map: Dict[str, AbstractBlastDatabase],

self._thread_pool_executor = ThreadPoolExecutor(max_workers=self._threads)
self._max_mlst_columns = 10

self.reset()

def reset(self):
Expand Down Expand Up @@ -185,14 +187,32 @@ def _get_blast_map(self, name: str) -> Dict:

def _get_mlst_data(self) -> str:

return self._mlst_data;
return self._mlst_data

def _get_future_blasts_from_map(self, name: str) -> Dict:
if name not in self._future_blasts_map:
self._future_blasts_map[name] = []

return self._future_blasts_map[name]

def _get_mlst_version(self) -> str:
command = ['mlst', '--version']

try:
output = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)

mlst_version = str(output.stdout, 'utf-8')

# Parses out the mlst when the string is given back ex `mlst 2.x.x` and removes new line
mlst_version = (mlst_version[5:]).rstrip()

except subprocess.CalledProcessError as e:
err_msg = str(e.stderr.strip())

raise Exception('Could not run mlst, error {}'.format(err_msg))

return mlst_version

def is_pointfinder_configured(self) -> bool:
"""
Whether or not PointFinder is being used.
Expand Down Expand Up @@ -232,6 +252,10 @@ def get_mlst_outputs(self) -> str:

return self._get_mlst_data();

def get_mlst_version(self) -> str:

return self._get_mlst_version(self) # type: ignore

def get_pointfinder_outputs(self) -> Dict:
"""
Gets the PointFinder output files in the form of a dictionary which looks like:
Expand Down
4 changes: 4 additions & 0 deletions staramr/subcommand/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from staramr.SubCommand import SubCommand
from staramr.Utils import get_string_with_spacing
from staramr.blast.JobHandler import JobHandler
from staramr.databases.AMRDatabasesManager import AMRDatabasesManager
from staramr.databases.resistance.ARGDrugTable import ARGDrugTable
from staramr.exceptions.CommandParseException import CommandParseException
Expand Down Expand Up @@ -294,8 +295,11 @@ def run(self, args):

try:
database_info = database_repos.info()
database_info['mlst_version'] = JobHandler.get_mlst_version(JobHandler)

database_info.update(arg_drug_table.get_resistance_table_info())
sys.stdout.write(get_string_with_spacing(database_info))

except DatabaseNotFoundException as e:
logger.error("No database found. Perhaps try restoring the default with 'staramr db restore-default'")
else:
Expand Down
2 changes: 2 additions & 0 deletions staramr/subcommand/Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ def _generate_results(self, database_repos, resfinder_database, pointfinder_data
logger.info("Finished. Took %s minutes.", time_difference_minutes)

settings = database_repos.info()

settings['mlst_version'] = JobHandler.get_mlst_version(JobHandler)
settings['command_line'] = ' '.join(sys.argv)
settings['version'] = self._version
settings['start_time'] = start_time.strftime(self.TIME_FORMAT)
Expand Down

0 comments on commit a6e7f95

Please sign in to comment.