package org.pdxfinder.dataloaders.updog;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import tech.tablesaw.api.Table;

@Service
public class TableSetCleaner {

    public Map<String, Table> cleanPdxTables(Map<String, Table> pdxTableSet) {
        List<String> columnsExceptFromLowercasing = Arrays.asList(
                "model_id",
                "sample_id",
                "patient_id",
                "name",
                "host_strain",
                "host_strain_full",
                "host_strain_nomenclature",
                "validation_host_strain_full",
                "provider_name",
                "provider_abbreviation",
                "abbreviation",
                "project",
                "internal_url",
                "internal_dosing_url",
                "platform"
        );
        pdxTableSet = TableSetUtilities.removeProviderNameFromFilename(pdxTableSet);
        pdxTableSet.remove("metadata-checklist.tsv");
        TableSetUtilities.removeDescriptionColumn(pdxTableSet);
        pdxTableSet = TableSetUtilities.removeHeaderRows(pdxTableSet);
        pdxTableSet = TableSetUtilities.removeBlankRows(pdxTableSet);
        pdxTableSet = TableSetUtilities.cleanValues(pdxTableSet, columnsExceptFromLowercasing);
        return pdxTableSet;
    }

    public Map<String, Table> cleanOmicsTables(Map<String, Table> omicsTableSet) {
        omicsTableSet = TableSetUtilities.removeProviderNameFromFilename(omicsTableSet);
        omicsTableSet = TableSetUtilities.removeHeaderRowsIfPresent(omicsTableSet);
        TableSetUtilities.removeDescriptionColumn(omicsTableSet);
        omicsTableSet = TableSetUtilities.removeBlankRows(omicsTableSet);
        return omicsTableSet;
    }

    public Table cleanOmicsTable(Table omicsTable){
        omicsTable = TableSetUtilities.removeHeaderRowsIfPresent(omicsTable);
        TableSetUtilities.removeColumnIfExists(omicsTable, "Field");
        return omicsTable;
    }

    public Map<String, Table> cleanTreatmentTables(Map<String, Table> treatmentTableSet) {
        treatmentTableSet = TableSetUtilities.removeProviderNameFromFilename(treatmentTableSet);
        treatmentTableSet = TableSetUtilities.removeHeaderRowsIfPresent(treatmentTableSet);
        TableSetUtilities.removeDescriptionColumn(treatmentTableSet);
        return treatmentTableSet;
    }
}

@@ -46,78 +46,8 @@
 ort 
-java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport 
 org.
@@ -112,16 +112,87 @@
 pi.Table
+;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0A@Serv
@@ -872,16 +872,49 @@
 latform%22
+,%0A                %22raw_data_file%22
 %0A       

Remove Raw_data_url from casing exceptions