<commit_before>import { VariantAnnotation } from 'genome-nexus-ts-api-client';
import {
    generateHgvsgByMutation,
    Mutation,
    RemoteData,
} from 'cbioportal-utils';
import { getAnnotation } from './VariantAnnotationHelper';

export function getHgvsgColumnData(mutation: Mutation): string | null {
    return generateHgvsgByMutation(mutation) || null;
}

export function getHgvscColumnData(
    mutation: Mutation,
    indexedVariantAnnotations?: RemoteData<
        { [genomicLocation: string]: VariantAnnotation } | undefined
    >,
    selectedTranscriptId?: string
): string | null {
    const variantAnnotation = getAnnotation(
        mutation,
        indexedVariantAnnotations
    );

    if (!variantAnnotation) {
        return null;
    }

    let data: string | null =
        variantAnnotation.annotation_summary.transcriptConsequenceSummary.hgvsc;

    // return data from transcriptConsequenceSummaries if transcript dropdown is enabled
    if (selectedTranscriptId) {
        const transcriptConsequenceSummary = variantAnnotation.annotation_summary.transcriptConsequenceSummaries.find(
            transcriptConsequenceSummary =><commit_msg>mutation table download - handle incomplete VariantAnnotation  gracefully<commit_after>import { VariantAnnotation } from 'genome-nexus-ts-api-client';
import {
    generateHgvsgByMutation,
    Mutation,
    RemoteData,
} from 'cbioportal-utils';
import { getAnnotation } from './VariantAnnotationHelper';

export function getHgvsgColumnData(mutation: Mutation): string | null {
    return generateHgvsgByMutation(mutation) || null;
}

export function getHgvscColumnData(
    mutation: Mutation,
    indexedVariantAnnotations?: RemoteData<
        { [genomicLocation: string]: VariantAnnotation } | undefined
    >,
    selectedTranscriptId?: string
): string | null {
    const variantAnnotation = getAnnotation(
        mutation,
        indexedVariantAnnotations
    );

    if (!variantAnnotation) {
        return null;
    }

    let data: string | null =
        variantAnnotation.annotation_summary?.transcriptConsequenceSummary
            ?.hgvsc || null;

    // return data from transcriptConsequenceSummaries if transcript dropdown is enabled
    if (selectedTranscriptId) {
        const transcriptConsequenceSummary = variantAnnotation.annotation_summary?.transcriptConsequenceSummaries?.find(
            transcriptConsequenceSummary =>
{'fraction_non_alphanumeric': 0.07819611088125776, 'fraction_numerical': 0.0, 'mean_word_length': 3.9246435845213847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014746', 'n_tokens_mistral': 655, 'n_tokens_neox': 619, 'n_words': 142}