matador.query package

The query module provides the DBQuery class that implements all database queries, either for individual compositions/formulae, or for matching calculations at the same accuracy to create phase diagrams.

class matador.query.DBQuery(client=False, collections=False, subcmd='query', debug=False, hull=False, quiet=False, mongo_settings=None, **kwargs)[source]

Bases: object

Class that implements queries to MongoDB structure database.

cursor

list or cursor of structures matching query.

Type:

list of dict or pymongo.Cursor

args

contains all keyword arguments used to construct the query (see matador query –help) for list.

Type:

dict

query_dict

dictionary passed to database for query

Type:

dict

calc_dict

if performing a matching query (e.g. self.args[‘subcmd’] = ‘hull’), this dictionary contains the parameters used to match to other structures

Type:

dict

repo

the pymongo collection that is being queried.

Type:

pymongo.collection.Collection

top

number of structures to print/export set by self.args.get(‘top’) (DEFAULT: 10).

Type:

int

cursor_min_limit

if a query returns more structures than this, do not implicitly convert to a list.

Type:

int

Parse arguments from matador or API call before calling query.

Keyword Arguments:
  • client (pm.MongoClient) – the MongoClient to connect to.

  • collections (dict of pm.collections.Collection) – dictionary of pymongo Collections.

  • subcmd (str) – either ‘query’ or ‘hull’, ‘voltage’, ‘hulldiff’. These will decide whether calcuation accuracies are matched in the final results.

cursor_min_limit = 1000
perform_query()[source]

Find results that match the query_dict inside the MongoDB database.

perform_hull_query()[source]

Perform the multiple queries necessary to find possible calculation sets to create a convex hull from.

Raises:

SystemExit – if no structures are found for hull.

perform_id_query()[source]

Query the text_id field for the ID provided in the args for a calc_match or hull/voltage query. Use the results of the text_id query to match to other entries that have the same calculation parameters. Sets self.query_dict and self.calc_dict.

Raises:

RuntimeError – if no structures are found.

query_stoichiometry(**kwargs)[source]

Alias for private function of the same name.

query_composition(**kwargs)[source]

Alias for private function of the same name.

query_tags(**kwargs)[source]

Alias for private function of the same name.

query_quality(**kwargs)[source]

Alias for private function of the same name.

Submodules

matador.query.query module

This file implements all queries to the database, including parsing user inputs, displaying results and calling other functionality.

class matador.query.query.DBQuery(client=False, collections=False, subcmd='query', debug=False, hull=False, quiet=False, mongo_settings=None, **kwargs)[source]

Bases: object

Class that implements queries to MongoDB structure database.

cursor

list or cursor of structures matching query.

Type:

list of dict or pymongo.Cursor

args

contains all keyword arguments used to construct the query (see matador query –help) for list.

Type:

dict

query_dict

dictionary passed to database for query

Type:

dict

calc_dict

if performing a matching query (e.g. self.args[‘subcmd’] = ‘hull’), this dictionary contains the parameters used to match to other structures

Type:

dict

repo

the pymongo collection that is being queried.

Type:

pymongo.collection.Collection

top

number of structures to print/export set by self.args.get(‘top’) (DEFAULT: 10).

Type:

int

cursor_min_limit

if a query returns more structures than this, do not implicitly convert to a list.

Type:

int

Parse arguments from matador or API call before calling query.

Keyword Arguments:
  • client (pm.MongoClient) – the MongoClient to connect to.

  • collections (dict of pm.collections.Collection) – dictionary of pymongo Collections.

  • subcmd (str) – either ‘query’ or ‘hull’, ‘voltage’, ‘hulldiff’. These will decide whether calcuation accuracies are matched in the final results.

cursor_min_limit = 1000
perform_query()[source]

Find results that match the query_dict inside the MongoDB database.

perform_hull_query()[source]

Perform the multiple queries necessary to find possible calculation sets to create a convex hull from.

Raises:

SystemExit – if no structures are found for hull.

perform_id_query()[source]

Query the text_id field for the ID provided in the args for a calc_match or hull/voltage query. Use the results of the text_id query to match to other entries that have the same calculation parameters. Sets self.query_dict and self.calc_dict.

Raises:

RuntimeError – if no structures are found.

query_stoichiometry(**kwargs)[source]

Alias for private function of the same name.

query_composition(**kwargs)[source]

Alias for private function of the same name.

query_tags(**kwargs)[source]

Alias for private function of the same name.

query_quality(**kwargs)[source]

Alias for private function of the same name.

class matador.query.query.EmptyCursor[source]

Bases: object

Empty cursor class for failures.

static count_documents(*args, **kwargs)[source]

Dummy function always returns 0.