<commit_before>import {getPercentage} from "../../../shared/lib/FormatUtils";
import * as React from "react";

export function getPatientSampleSummary(
    samples:any[],
    patients:any[]
) {
    if (samples.length !== patients.length) {
        return (
            <span>
                <strong>{patients.length}</strong> patients / <strong>{samples.length}</strong> samples
        </span>
    );
    } else {
        return (
            <span>
                <strong>{samples.length}</strong> patients/samples
        </span>
    );
    }
}

export function getGeneSummary(hugoSymbols:string[]) {
    switch (hugoSymbols.length) {
        case 0:
            return "";
        case 1:
            return hugoSymbols[0];
        case 2:
            return hugoSymbols.join(" & ");
        default:
            return `${hugoSymbols[0]}, ${hugoSymbols[1]} & ${(hugoSymbols.length === 3) ? hugoSymbols[2] : `${hugoSymbols.length - 2} other genes`}`;
    }
}

export function getAlterationSummary(
    numSamples:number, numPatients:number, numAlteredSamples:number, numAlteredPatients:number, numGenes:number
) {
    const sampleSummaryPrefix = `${numAlteredSamples} (${getPercentage(numAlteredSamples/numSamples, 0)}) of queried`;
    let patientSummary = "";
    let sampleSummary = "";
    if (numSamples !== numPatients) {
        // note that by the pigeonhole principle, its not possible to have same number of samples and patients and
        //  for there to be more than one sample in a single patient. thus in the case that there are same # of samples
        //  and patients, it must be that numAlteredSamples === numAlteredPatients. Thus we're not hiding any info
        //  by only showing # altered patients if there are different # of samples and patients.
        sampleSummary = `${sampleSummaryPrefix} samples`;
        patientSummary = `${numAlteredPatients} (${getPercentage(numAlteredPatients/numPatients, 0)}) of queried patients and `;
    } else {
        // if numSamples = numPatients, add this info to sampleSummary
        sampleSummary = `${sampleSummaryPrefix} patients/samples`;
    }
    return <strong>{`Queried gene${numGenes !== 1 ? "s are" : " is"} altered in ${patientSummary}${sampleSummary}`}</strong>;
}<commit_msg>results query header - github issue 5303 - format right header<commit_after>import {getPercentage} from "../../../shared/lib/FormatUtils";
import * as React from "react";

export function getPatientSampleSummary(
    samples:any[],
    patients:any[]
) {
    if (samples.length !== patients.length) {
        return (
            <span>
                <strong>{patients.length}</strong> patients / <strong>{samples.length}</strong> samples
        </span>
    );
    } else {
        return (
            <span>
                <strong>{samples.length}</strong> patients/samples
        </span>
    );
    }
}

export function getGeneSummary(hugoSymbols:string[]) {
    switch (hugoSymbols.length) {
        case 0:
            return "";
        case 1:
            return hugoSymbols[0];
        case 2:
            return hugoSymbols.join(" & ");
        default:
            return `${hugoSymbols[0]}, ${hugoSymbols[1]} & ${(hugoSymbols.length === 3) ? hugoSymbols[2] : `${hugoSymbols.length - 2} other genes`}`;
    }
}

export function getAlterationSummary(
    numSamples:number, numPatients:number, numAlteredSamples:number, numAlteredPatients:number, numGenes:number
) {
    const prefix = `Queried gene${numGenes !== 1 ? "s are" : " is"} altered in`;
    const sampleSummaryPrefix = `${numAlteredSamples} (${getPercentage(numAlteredSamples/numSamples, 0)}) of queried`;
    if (numSamples !== numPatients) {
        // note that by the pigeonhole principle, its not possible to have same number of samples and patients and
        //  for there to be more than one sample in a single patient. thus in the case that there are same # of samples
        //  and patients, it must be that numAlteredSamples === numAlteredPatients. Thus we're not hiding any info
        //  by only showing # altered patients if there are different # of samples and patients.
        return (
            <strong style={{display:"flex"}}>
                <span style={{marginRight: 13}}>{prefix}</span>
                <table>
                    <tr><td>&#8226;&nbsp;{`${numAlteredPatients} (${getPercentage(numAlteredPatients/numPatients, 0)}) of queried patients`}</td></tr>
                    <tr><td>&#8226;&nbsp;{`${sampleSummaryPrefix} samples`}</td></tr>
                </table>
            </strong>
        );
    } else {
        return (
            <strong>
                <span>{`${prefix} ${sampleSummaryPrefix} patients/samples`}</span>
            </strong>
        );
    }
}
{'fraction_non_alphanumeric': 0.13010526315789472, 'fraction_numerical': 0.008, 'mean_word_length': 2.5802562170308967, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '3831221', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1312, 'n_words': 363}