3. Spreadsheet Creator

The core module of the creator package. Takes the user input, validates them and creates the dataframes.

class ptmd.lib.creator.core.DataframeCreator(user_input: dict)

Bases: object

Class to create the dataframes from the user input.

Parameters

user_input – the user input

delete_file() None

Delete the sample sheet file.

get_array_of_unique_chemicals() list[str]

Get an array of unique chemicals from the exposure conditions.

Returns

The array of unique chemicals names.

save_file(path: str) str

Save the sample sheet to a file.

Parameters

path – The path to the file.

Returns

The path to the file the sample sheet was saved to.

to_dataframe() tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]

Convert the object to a pandas DataFrame.

Returns

The pandas DataFrame.

validate() None

Validates the user input against the JSON SChema

Returns

None

validate_timepoints_and_timeframe() None

Make sure the timepoints are not over extending the end date.

Module to created spreadsheets from the HarvesterInput, style and save them to disk.

ptmd.lib.creator.dataframes.add_blanks_to_sample_dataframe(sample_df: DataFrame, replicate_blank: int, organism_code: str, exposure_batch: str) DataFrame

Add the blanks to the sample dataframe.

Parameters
  • sample_df – The sample dataframe.

  • replicate_blank – The number of blanks to add.

  • organism_code – The organism code to use.

  • exposure_batch – The exposure batch to use.

Returns

The sample dataframe with the blanks.

ptmd.lib.creator.dataframes.build_general_dataframe(harvester: Any) DataFrame

Builds a DataFrame with the general information of the harvester.

Parameters

harvester – The harvester to build the DataFrame from.

Returns

A DataFrame with the general information of the harvester.

ptmd.lib.creator.dataframes.build_sample_dataframe(harvester: Any, chemicals_mapping: dict[str, str], organism_code: str) DataFrame

Builds a DataFrame with the sample information of the harvester.

Parameters
  • harvester – The harvester to build the DataFrame from.

  • chemicals_mapping – A dictionary mapping chemicals names to ptox codes.

  • organism_code – The organism code to use.

Returns

A DataFrame