<commit_before>import { FIELDS_METADATA } from "~/components/utils/tooltip";
import TableRenderers from "~/components/views/discovery/TableRenderers";
import { SAMPLE_TABLE_COLUMNS_V2 } from "~/components/views/samples/constants";
import { WORKFLOWS } from "~utils/workflows";
import cs from "./samples_view.scss";

export const computeColumnsByWorkflow = ({
  basicIcon = false,
  allowedFeatures = [],
} = {}) => {
  const columnsByWorkflow = {};

  columnsByWorkflow[WORKFLOWS.SHORT_READ_MNGS.value] = [
    {
      dataKey: "sample",
      flexGrow: 1,
      width: 350,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderSample({
          sample: cellData,
          workflow: WORKFLOWS.SHORT_READ_MNGS.value,
          full: true,
          basicIcon,
        }),
      headerClassName: cs.sampleHeader,
    },
    {
      dataKey: "createdAt",
      label: "Created On",
      width: 120,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderDateWithElapsed,
    },
    {
      dataKey: "host",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "collectionLocationV2",
      label: "Location",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "totalReads",
      label: "Total Reads",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "nonHostReads",
      label: "Passed Filters",
      flexGrow: 1,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderNumberAndPercentage,
    },
    {
      dataKey: "qcPercent",
      label: "Passed QC",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "duplicateCompressionRatio",
      label: "DCR",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "erccReads",
      label: "ERCC Reads",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "notes",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "nucleotideType",
      label: "Nucleotide Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "pipelineVersion",
      label: "Pipeline Version",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "sampleType",
      label: "Sample Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "subsampledFraction",
      label: "SubSampled Fraction",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "totalRuntime",
      label: "Total Runtime",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatDuration(rowData[dataKey]),
    },
    {
      dataKey: "waterControl",
      label: "Water Control",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "meanInsertSize",
      label: "Mean Insert Size",
      flexGrow: 1,
      className: cs.basicCell,
    },
  ];
  for (const col of columnsByWorkflow[WORKFLOWS.SHORT_READ_MNGS.value]) {
    col["columnData"] = SAMPLE_TABLE_COLUMNS_V2[col["dataKey"]];
  }

  columnsByWorkflow[WORKFLOWS.CONSENSUS_GENOME.value] = [
    {
      dataKey: "sample",
      flexGrow: 1,
      width: 350,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderSample({
          sample: cellData,
          workflow: WORKFLOWS.CONSENSUS_GENOME.value,
          full: true,
          basicIcon,
          allowedFeatures,
        }),
      headerClassName: cs.sampleHeader,
    },
    {
      dataKey: "createdAt",
      label: "Created On",
      width: 120,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderDateWithElapsed,
    },
    {
      dataKey: "host",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "collectionLocationV2",
      label: "Location",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "notes",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "nucleotideType",
      label: "Nucleotide Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "sampleType",
      label: "Sample Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "waterControl",
      label: "Water Control",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "coverageDepth",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "totalReadsCG",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "gcPercent",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "refSnps",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "percentIdentity",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "nActg",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "percentGenomeCalled",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "nMissing",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "nAmbiguous",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "wetlabProtocol",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "technology",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "referenceGenome",
      flexGrow: 1,
      className: cs.basicCell,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderReferenceGenome(cellData),
    },
    {
      dataKey: "referenceGenomeLength",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
  ];

  for (const col of columnsByWorkflow[WORKFLOWS.CONSENSUS_GENOME.value]) {
    const dataKey = col["dataKey"];
    if (SAMPLE_TABLE_COLUMNS_V2.hasOwnProperty(dataKey)) {
      col["columnData"] = SAMPLE_TABLE_COLUMNS_V2[dataKey];
    } else if (FIELDS_METADATA.hasOwnProperty(dataKey)) {
      col["columnData"] = FIELDS_METADATA[dataKey];
      col["label"] = FIELDS_METADATA[dataKey].label;
    }
  }

  return columnsByWorkflow;
};<commit_msg>Change Reference Genome Length to non decimal (#805)<commit_after>import { FIELDS_METADATA } from "~/components/utils/tooltip";
import TableRenderers from "~/components/views/discovery/TableRenderers";
import { SAMPLE_TABLE_COLUMNS_V2 } from "~/components/views/samples/constants";
import { WORKFLOWS } from "~utils/workflows";
import cs from "./samples_view.scss";

export const computeColumnsByWorkflow = ({
  basicIcon = false,
  allowedFeatures = [],
} = {}) => {
  const columnsByWorkflow = {};

  columnsByWorkflow[WORKFLOWS.SHORT_READ_MNGS.value] = [
    {
      dataKey: "sample",
      flexGrow: 1,
      width: 350,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderSample({
          sample: cellData,
          workflow: WORKFLOWS.SHORT_READ_MNGS.value,
          full: true,
          basicIcon,
        }),
      headerClassName: cs.sampleHeader,
    },
    {
      dataKey: "createdAt",
      label: "Created On",
      width: 120,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderDateWithElapsed,
    },
    {
      dataKey: "host",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "collectionLocationV2",
      label: "Location",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "totalReads",
      label: "Total Reads",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "nonHostReads",
      label: "Passed Filters",
      flexGrow: 1,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderNumberAndPercentage,
    },
    {
      dataKey: "qcPercent",
      label: "Passed QC",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "duplicateCompressionRatio",
      label: "DCR",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "erccReads",
      label: "ERCC Reads",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "notes",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "nucleotideType",
      label: "Nucleotide Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "pipelineVersion",
      label: "Pipeline Version",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "sampleType",
      label: "Sample Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "subsampledFraction",
      label: "SubSampled Fraction",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "totalRuntime",
      label: "Total Runtime",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatDuration(rowData[dataKey]),
    },
    {
      dataKey: "waterControl",
      label: "Water Control",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "meanInsertSize",
      label: "Mean Insert Size",
      flexGrow: 1,
      className: cs.basicCell,
    },
  ];
  for (const col of columnsByWorkflow[WORKFLOWS.SHORT_READ_MNGS.value]) {
    col["columnData"] = SAMPLE_TABLE_COLUMNS_V2[col["dataKey"]];
  }

  columnsByWorkflow[WORKFLOWS.CONSENSUS_GENOME.value] = [
    {
      dataKey: "sample",
      flexGrow: 1,
      width: 350,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderSample({
          sample: cellData,
          workflow: WORKFLOWS.CONSENSUS_GENOME.value,
          full: true,
          basicIcon,
          allowedFeatures,
        }),
      headerClassName: cs.sampleHeader,
    },
    {
      dataKey: "createdAt",
      label: "Created On",
      width: 120,
      className: cs.basicCell,
      cellRenderer: TableRenderers.renderDateWithElapsed,
    },
    {
      dataKey: "host",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "collectionLocationV2",
      label: "Location",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "notes",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "nucleotideType",
      label: "Nucleotide Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "sampleType",
      label: "Sample Type",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "waterControl",
      label: "Water Control",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "coverageDepth",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumber(rowData[dataKey]),
    },
    {
      dataKey: "totalReadsCG",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "gcPercent",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "refSnps",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "percentIdentity",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "nActg",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "percentGenomeCalled",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatPercentage(rowData[dataKey]),
    },
    {
      dataKey: "nMissing",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "nAmbiguous",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
    {
      dataKey: "wetlabProtocol",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "technology",
      flexGrow: 1,
      className: cs.basicCell,
    },
    {
      dataKey: "referenceGenome",
      flexGrow: 1,
      className: cs.basicCell,
      cellRenderer: ({ cellData }) =>
        TableRenderers.renderReferenceGenome(cellData),
    },
    {
      dataKey: "referenceGenomeLength",
      flexGrow: 1,
      className: cs.basicCell,
      cellDataGetter: ({ dataKey, rowData }) =>
        TableRenderers.formatNumberWithCommas(rowData[dataKey]),
    },
  ];

  for (const col of columnsByWorkflow[WORKFLOWS.CONSENSUS_GENOME.value]) {
    const dataKey = col["dataKey"];
    if (SAMPLE_TABLE_COLUMNS_V2.hasOwnProperty(dataKey)) {
      col["columnData"] = SAMPLE_TABLE_COLUMNS_V2[dataKey];
    } else if (FIELDS_METADATA.hasOwnProperty(dataKey)) {
      col["columnData"] = FIELDS_METADATA[dataKey];
      col["label"] = FIELDS_METADATA[dataKey].label;
    }
  }

  return columnsByWorkflow;
};
{'fraction_non_alphanumeric': 0.12585277109999352, 'fraction_numerical': 0.007212007017087909, 'mean_word_length': 2.414374445430346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378013', 'n_tokens_mistral': 5131, 'n_tokens_neox': 5027, 'n_words': 877}