<commit_before>import {CancerStudyQueryUrlParams, normalizeQuery, QueryStore} from "./QueryStore";

export type NonMolecularProfileQueryParams = Pick<CancerStudyQueryUrlParams,
    'cancer_study_id' | 'cancer_study_list' | 'Z_SCORE_THRESHOLD' | 'RPPA_SCORE_THRESHOLD' | 'data_priority' |
    'case_set_id' | 'case_ids' | 'gene_list' | 'tab_index' | 'transpose_matrix' | 'Action'>;

export type MolecularProfileQueryParams = Pick<CancerStudyQueryUrlParams,
    'genetic_profile_ids_PROFILE_MUTATION_EXTENDED' | 'genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION' |
    'genetic_profile_ids_PROFILE_MRNA_EXPRESSION' | 'genetic_profile_ids_PROFILE_METHYLATION' |
    'genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION'>;


export function currentQueryParams(store:QueryStore) {
    let nonProfileParams = nonMolecularProfileParams(store);
    let profileParams = molecularProfileParams(store);
    let path = queryUrl(store, nonProfileParams);
    return queryParams(nonProfileParams, profileParams, path);
}

export function queryUrl(store:QueryStore, nonMolecularProfileParams:NonMolecularProfileQueryParams) {

    /*if (store.selectedStudyIds.length != 1)
    {
        let studyIds = store.selectedStudyIds;
        if (!studyIds.length) {
            studyIds = store.cancerStudies.result.map(study => study.studyId);
        }

        const hash = `crosscancer/overview/${nonMolecularProfileParams.data_priority}/${encodeURIComponent(nonMolecularProfileParams.gene_list)}/${encodeURIComponent(studyIds.join(","))}`;
        return `cross_cancer.do?#${hash}`;
    } else {
        return 'index.do';
    }*/
    return 'index.do';
}

export function queryParams(nonMolecularProfileParams:NonMolecularProfileQueryParams,
                            molecularProfileParams:MolecularProfileQueryParams,
                            path:string) {
    let params:CancerStudyQueryUrlParams = Object.assign({}, nonMolecularProfileParams, molecularProfileParams);

    // Remove params with no value, because they may cause problems.
    // For example, the server will always transpose if transpose_matrix is present, no matter the value.
    for (let key in params) {
        if (!(params as any)[key]) {
            delete (params as any)[key];
        }
    }

    return {pathname: path, query:params};
}

export function nonMolecularProfileParams(store:QueryStore):NonMolecularProfileQueryParams {
    let ret:NonMolecularProfileQueryParams = {
        cancer_study_id: store.singleSelectedStudyId || 'all',
        Z_SCORE_THRESHOLD: store.zScoreThreshold,
        RPPA_SCORE_THRESHOLD: store.rppaScoreThreshold,
        data_priority: store.dataTypePriorityCode,
        case_set_id: store.selectedSampleListId || '-1', // empty string won't work
        case_ids: store.asyncCustomCaseSet.result.map(caseRow => (caseRow.studyId + '|' + caseRow.sampleId)).join('\r\n'),
        gene_list: normalizeQuery(store.geneQuery) || ' ', // empty string won't work
        tab_index: store.forDownloadTab ? 'tab_download' : 'tab_visualize' as any,
        transpose_matrix: store.transposeDataMatrix ? 'on' : undefined,
        Action: 'Submit',
    };

    if (store.selectedStudyIds.length !== 1) {
        ret = Object.assign(ret, { cancer_study_list: store.selectedStudyIds.join(",") });
    }

    return ret;
}

export function molecularProfileParams(store:QueryStore, molecularProfileIds?:ReadonlyArray<string>) {
    return {
        genetic_profile_ids_PROFILE_MUTATION_EXTENDED: store.getSelectedProfileIdFromMolecularAlterationType("MUTATION_EXTENDED", molecularProfileIds),
        genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION: store.getSelectedProfileIdFromMolecularAlterationType("COPY_NUMBER_ALTERATION", molecularProfileIds),
        genetic_profile_ids_PROFILE_MRNA_EXPRESSION: store.getSelectedProfileIdFromMolecularAlterationType("MRNA_EXPRESSION", molecularProfileIds),
        genetic_profile_ids_PROFILE_METHYLATION: store.getSelectedProfileIdFromMolecularAlterationType("METHYLATION", molecularProfileIds) || store.getSelectedProfileIdFromMolecularAlterationType("METHYLATION_BINARY", molecularProfileIds),
        genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION: store.getSelectedProfileIdFromMolecularAlterationType("PROTEIN_LEVEL", molecularProfileIds)
    };
}<commit_msg>Unify the separator<commit_after>import {CancerStudyQueryUrlParams, normalizeQuery, QueryStore} from "./QueryStore";

export type NonMolecularProfileQueryParams = Pick<CancerStudyQueryUrlParams,
    'cancer_study_id' | 'cancer_study_list' | 'Z_SCORE_THRESHOLD' | 'RPPA_SCORE_THRESHOLD' | 'data_priority' |
    'case_set_id' | 'case_ids' | 'gene_list' | 'tab_index' | 'transpose_matrix' | 'Action'>;

export type MolecularProfileQueryParams = Pick<CancerStudyQueryUrlParams,
    'genetic_profile_ids_PROFILE_MUTATION_EXTENDED' | 'genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION' |
    'genetic_profile_ids_PROFILE_MRNA_EXPRESSION' | 'genetic_profile_ids_PROFILE_METHYLATION' |
    'genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION'>;


export function currentQueryParams(store:QueryStore) {
    let nonProfileParams = nonMolecularProfileParams(store);
    let profileParams = molecularProfileParams(store);
    let path = queryUrl(store, nonProfileParams);
    return queryParams(nonProfileParams, profileParams, path);
}

export function queryUrl(store:QueryStore, nonMolecularProfileParams:NonMolecularProfileQueryParams) {

    /*if (store.selectedStudyIds.length != 1)
    {
        let studyIds = store.selectedStudyIds;
        if (!studyIds.length) {
            studyIds = store.cancerStudies.result.map(study => study.studyId);
        }

        const hash = `crosscancer/overview/${nonMolecularProfileParams.data_priority}/${encodeURIComponent(nonMolecularProfileParams.gene_list)}/${encodeURIComponent(studyIds.join(","))}`;
        return `cross_cancer.do?#${hash}`;
    } else {
        return 'index.do';
    }*/
    return 'index.do';
}

export function queryParams(nonMolecularProfileParams:NonMolecularProfileQueryParams,
                            molecularProfileParams:MolecularProfileQueryParams,
                            path:string) {
    let params:CancerStudyQueryUrlParams = Object.assign({}, nonMolecularProfileParams, molecularProfileParams);

    // Remove params with no value, because they may cause problems.
    // For example, the server will always transpose if transpose_matrix is present, no matter the value.
    for (let key in params) {
        if (!(params as any)[key]) {
            delete (params as any)[key];
        }
    }

    return {pathname: path, query:params};
}

export function nonMolecularProfileParams(store:QueryStore):NonMolecularProfileQueryParams {
    let ret:NonMolecularProfileQueryParams = {
        cancer_study_id: store.singleSelectedStudyId || 'all',
        Z_SCORE_THRESHOLD: store.zScoreThreshold,
        RPPA_SCORE_THRESHOLD: store.rppaScoreThreshold,
        data_priority: store.dataTypePriorityCode,
        case_set_id: store.selectedSampleListId || '-1', // empty string won't work
        case_ids: store.asyncCustomCaseSet.result.map(caseRow => (caseRow.studyId + ':' + caseRow.sampleId)).join('\r\n'),
        gene_list: normalizeQuery(store.geneQuery) || ' ', // empty string won't work
        tab_index: store.forDownloadTab ? 'tab_download' : 'tab_visualize' as any,
        transpose_matrix: store.transposeDataMatrix ? 'on' : undefined,
        Action: 'Submit',
    };

    if (store.selectedStudyIds.length !== 1) {
        ret = Object.assign(ret, { cancer_study_list: store.selectedStudyIds.join(",") });
    }

    return ret;
}

export function molecularProfileParams(store:QueryStore, molecularProfileIds?:ReadonlyArray<string>) {
    return {
        genetic_profile_ids_PROFILE_MUTATION_EXTENDED: store.getSelectedProfileIdFromMolecularAlterationType("MUTATION_EXTENDED", molecularProfileIds),
        genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION: store.getSelectedProfileIdFromMolecularAlterationType("COPY_NUMBER_ALTERATION", molecularProfileIds),
        genetic_profile_ids_PROFILE_MRNA_EXPRESSION: store.getSelectedProfileIdFromMolecularAlterationType("MRNA_EXPRESSION", molecularProfileIds),
        genetic_profile_ids_PROFILE_METHYLATION: store.getSelectedProfileIdFromMolecularAlterationType("METHYLATION", molecularProfileIds) || store.getSelectedProfileIdFromMolecularAlterationType("METHYLATION_BINARY", molecularProfileIds),
        genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION: store.getSelectedProfileIdFromMolecularAlterationType("PROTEIN_LEVEL", molecularProfileIds)
    };
}
{'fraction_non_alphanumeric': 0.09534883720930233, 'fraction_numerical': 0.0006976744186046512, 'mean_word_length': 4.911340206185567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2004291', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2493, 'n_words': 398}