tickets

Misc. functions to manipulate tickets.

pdm_utils.functions.tickets.construct_tickets(list_of_data_dict, eval_data_dict, description_field, required_keys, optional_keys, keywords)

Construct pdm_utils ImportTickets from parsed data dictionaries.

Parameters
  • list_of_data_dict (list) – List of import ticket data dictionaries.

  • eval_data_dict (dict) – Dictionary of boolean evaluation flags.

  • description_field (str) – Default value to set ticket.description_field attribute if not present in the data dictionary.

  • required_keys (set) – Set of keys required to be in the data dictionary.

  • optional_keys (set) – Set of optional keys that are not required to be in the data dictionary.

  • keywords (set) – Set of valid keyword values that are handled differently than other values.

Returns

List of pdm_utils ImportTicket objects.

Return type

list

pdm_utils.functions.tickets.get_genome(tkt, gnm_type='')

Construct a pdm_utils Genome object from a pdm_utils ImportTicket object.

Parameters
  • tkt (ImportTicket) – A pdm_utils ImportTicket object.

  • gnm_type (str) – Identifier for the type of genome.

Returns

A pdm_utils Genome object.

Return type

Genome

pdm_utils.functions.tickets.identify_duplicates(list_of_tickets, null_set={})

Compare all tickets to each other to identify ticket conflicts.

Identifies if the same id, PhageID, and Accession is present in multiple tickets.

Parameters
  • list_of_tickets (list) – A list of pdm_utils ImportTicket objects.

  • null_set (set) – A set of values that may be expected to be duplicated, that should not throw errors.

Returns

tuple (tkt_id_dupes, phage_id_dupes) WHERE tkt_id_dupes(set) is a set of duplicate ticket ids. phage_id_dupes(set) is a set of duplicate PhageIDs.

Return type

tuple

pdm_utils.functions.tickets.modify_import_data(data_dict, required_keys, optional_keys, keywords)

Modifies ticket data to conform to requirements for an ImportTicket object.

Parameters
  • data_dict (dict) – Dictionary of import ticket data.

  • required_keys (set) – Set of keys required to be in the data dictionary.

  • optional_keys (set) – Set of optional keys that are not required to be in the data dictionary.

  • keywords (set) – Set of valid keyword values that are handled differently than other values.

Returns

Indicates if the ticket is structured properly.

Return type

bool

pdm_utils.functions.tickets.parse_import_ticket_data(data_dict)

Converts import ticket data to a ImportTicket object.

Parameters

data_dict (dict) –

A dictionary of data with the following keys:

  1. Import action type

  2. Primary PhageID

  3. Host

  4. Cluster

  5. Subcluster

  6. Status

  7. Annotation Author (int)

  8. Feature field

  9. Accession

  10. Retrieve Record (int)

  11. Evaluation mode

Returns

A pdm_utils ImportTicket object.

Return type

ImportTicket

pdm_utils.functions.tickets.set_dict_value(data_dict, key, first, second)

Set the value for a specific key based on ‘type’ key-value.

Parameters
  • data_dict (dict) – Dictionary of import ticket data.

  • key (str) – Dictionary key to change value of.

  • first (str) – Value to assign to ‘key’ if ‘type’ == ‘add’.

  • second (str) – Value to assign to ‘key’ if ‘type’ != ‘add’.

pdm_utils.functions.tickets.set_empty(data_dict)

Convert None values to an empty string.

Parameters

data_dict (dict) – Dictionary of import ticket data.

pdm_utils.functions.tickets.set_keywords(data_dict, keywords)

Convert specific values in a dictionary to lowercase.

Parameters
  • data_dict (dict) – Dictionary of import ticket data.

  • keywords (set) – Set of valid keyword values that are handled differently than other values.

pdm_utils.functions.tickets.set_missing_keys(data_dict, expected_keys)

Add a list of keys-values to a dictionary if it doesn’t have those keys.

Parameters
  • data_dict (dict) – Dictionary of import ticket data.

  • expected_keys (set) – Set of keys expected to be in the dictionary.