phenomedb.task

class phenomedb.task.CreateAnnotationMethod(annotation_method_name=None, description=None, task_run_id=None, username=None, db_env=None)

CreateAnnotationMethod: Creates an AnnotationMethod

class phenomedb.task.CreateAssay(assay_name=None, platform=None, targeted=None, ms_polarity=None, laboratory_name=None, long_name=None, long_platform=None, task_run_id=None, username=None, db_env=None)

CreateAssay: Creates an Assay

class phenomedb.task.CreateHarmonisedMetadataField(name=None, unit_name=None, datatype=None, unit_description=None, task_run_id=None, username=None, db_env=None, db_session=None, execution_date=None)
class phenomedb.task.CreateLab(lab_name=None, lab_affiliation=None, task_run_id=None, username=None, db_env=None)

CreateAssay: Creates an Assay

class phenomedb.task.CreateProject(project_name=None, description=None, project_folder_name=None, lims_id=None, task_run_id=None, username=None, db_env=None)

ImportNewProjectTask: Imports a new project

class phenomedb.task.CreateUnit(unit_name=None, unit_description=None, task_run_id=None, username=None, db_env=None)
class phenomedb.task.ManualSQL(sql_file=None, username=None, task_run_id=None, db_env=None)
class phenomedb.task.Task(task_run_id=None, pipeline_run_id=None, username=None, db_env=None, db_session=None, execution_date=None, validate=True, upstream_task_run_id=None, debug=False)

Base Task class.

Parameters:

ABC (abc.ABC) – abstract base class

Raises:

Exception – Raised when tabular file is not of correct type (xlsx,xls,csv,tsv)

Returns:

The Task class.

Return type:

phenomedb.task.Task

clean_project_name(project_name)

Clean the project name (lower and replace hypens (-) with underscores (_))

Parameters:

project_name (str) – The name of the project.

Returns:

The cleaned the project name.

Return type:

str

download_files_from_metabolights(study_id, prefixes=None, suffixes=None)

Download files from Metabolights (not working yet)

download_from_metabolights_api(prefixes=None, suffixes=None)

Download the study via the API (not yet implemented)

Parameters:

type (str) – file type to download (‘investigation’,’sample’,’assays’,’metabolites’)

get_class_name(instance)

Get the name of the class from the instance.

Parameters:

instance (phenomedb.task.Task) – The instance of the class.

Returns:

The class name.

Return type:

str

get_or_add_annotation_method(annotation_method_name, description=None)

Gets or adds a project to the database (by project_name)

get_or_add_assay(assay_name, platform=None, targeted=None, ms_polarity=None, long_name=None, long_platform=None, quantification_type=None)

Gets or adds a project to the database (by project_name)

get_or_add_harmonised_field(field_name, unit, datatype)

Gets or adds a project to the database (by project_name)

get_or_add_laboratory(lab_name, lab_affiliation=None)

Gets or adds a project to the database (by project_name)

get_or_add_project(project_name, project_description=None, project_folder_name=None, lims_id=None, short_description=None, persons=None, laboratory_id=None)

Gets or adds a project to the database (by project_name)

get_or_add_unit(unit_name, unit_description=None)

Gets or adds a unit to the database (by unit name)

load_tabular_file(file, sheet_name=0, dtype=None, header='infer', na_values=None, replace_na_with_none=True, strip_whitespace=True)

Load a tabular file into a pandas dataframe. Works with xlsx, xls, csv, tsv, and txt files.

Parameters:
  • file (str) – The file (and path) to open.

  • sheet_name (int, optional) – The name of the sheet to open (xlsx and xls), defaults to 0.

  • dtype (object, optional) – The column types of the file (pandas dtypes), defaults to None.

Raises:

Exception – Raises if not xlsx, xls, csv, tsv, or txt.

Returns:

The created pandas dataframe.

Return type:

pd.Dataframe

log_info(message)

Add the info log and print.

Parameters:

message (str) – The message to log.

run()

Run the task. You must implement the process method in your inherited class.