def test_save_df(self):
     kn.save_df(self.result_df, self.tmp_dir, self.file_name)
     ret = pd.read_csv(os.path.join(self.tmp_dir, self.file_name),
           sep='\t', header=0, index_col=False)
     os.remove(os.path.join(self.tmp_dir, self.file_name))
     self.assertEqual(True, ret.equals(self.test_df),
                      'test_save_df failed')
def save_timestamped_df(input_df, results_dir, output_file_name):
    """ Save dataframe to files with timestamped name.

    Args:
        fisher_contingency_pval: list of seven items lists.
        results_dir: directory to save outputs.
        output_file_name: file name.
    """
    file_name = kn.create_timestamped_filename(output_file_name, "df")
    kn.save_df(input_df, results_dir, file_name)
def map_and_save_droplist(spreadsheet_df, gene_names, droplist_name, run_parameters):
    """This is to map and save droplist

    Args:
        spreadsheet_df: user supplied spreadsheet dataframe.
        gene_names: list of genes.
        droplist_name: name of droplist file.
        run_parameters: dictionary of run parameters.

    Returns:
        property_rank_df: dataframe with ranked property names in each column.
    """

    gene_names_map    = run_parameters["gene_names_map"]
    results_directory = run_parameters['results_directory']

    droplist        = kn.find_dropped_node_names(spreadsheet_df, gene_names)
    map_df          = pd.read_csv(gene_names_map, index_col=0, header=None, sep='\t')
    new_droplist_df = pd.DataFrame(map_df.loc[droplist].values, columns=[droplist_name])
    file_name       = kn.create_timestamped_filename(droplist_name, "tsv")

    kn.save_df(new_droplist_df, results_directory, file_name)