Results export
gambit.results
Export query results in various formats.
- class gambit.results.AbstractResultsExporter
Bases:
ABCBase for classes that export formatted query results.
Subclasses must implement
export().- abstract export(file_or_path, results)
Write query results to file.
- Parameters:
file_or_path (FilePath | IO) – Open file-like object or file path to write to.
results (QueryResults) – Results to export.
- class gambit.results.BaseJSONResultsExporter
Bases:
AbstractResultsExporterBase class for JSON exporters.
Subclasses need to implement the
to_jsonmethod.- __init__(pretty=False)
Method generated by attrs for class BaseJSONResultsExporter.
- Parameters:
pretty (bool)
- Return type:
None
- export(file_or_path, results)
Write query results to file.
- Parameters:
file_or_path (FilePath | TextIO) – Open file-like object or file path to write to.
results (QueryResults) – Results to export.
- to_json(obj)
Convert object to JSON-compatible format (need not work recursively).
- class gambit.results.CSVResultsExporter
Bases:
AbstractResultsExporterExports query results in CSV format.
- format_opts
Dialect and other formatting arguments passed to
csv.writer().
- __init__(**format_opts)
- export(file_or_path, results)
Write query results to file.
- Parameters:
file_or_path (FilePath | TextIO) – Open file-like object or file path to write to.
results (QueryResults) – Results to export.
- get_row(item)
Get row values for single result item.
- Parameters:
item (QueryResultItem)
- Return type:
- class gambit.results.JSONResultsExporter
Bases:
BaseJSONResultsExporterExports query results in basic JSON format.
Currently it assumes that the query was run with
classify_strict=False, so the only relevant information fromClassifierResultis the closest genome match.- __init__(pretty=False)
Method generated by attrs for class JSONResultsExporter.
- Parameters:
pretty (bool)
- Return type:
None
- to_json(obj)
- to_json(results)
- to_json(item)
- to_json(gset)
- to_json(taxon)
- to_json(genome)
Convert object to JSON-compatible format (need not work recursively).
- class gambit.results.ResultsArchiveReader
Bases:
objectLoads query results from file created by
ResultsArchiveWriter.- session
SQLAlchemy session used to load database objects.
- Type:
sqlalchemy.orm.session.Session
- __init__(session)
- read(file_or_path)
Read query results from JSON file.
- results_from_json(data)
Recreate results object from loaded JSON data.
- Parameters:
- Return type:
- class gambit.results.ResultsArchiveWriter
Bases:
BaseJSONResultsExporterExports query results to “archive” format which captures all stored data.
This format is not intended to be read by users of the application. The exported data can be read and converted back into an identical
QueryResultsobject usingResultsArchiveReader.Only the ID attributes of database models are saved, when loading the saved results the models are recreated by database queries.
- to_json(obj)
- to_json(gset)
- to_json(taxon)
- to_json(genome)
Convert object to JSON-compatible format (need not work recursively).