<commit_before>// @flow

import React from 'react';
import Relay from 'react-relay';
import EntityPageVerticalTable from '@ncigdc/components/EntityPageVerticalTable';
import TableIcon from '@ncigdc/theme/icons/Table';
import MinusIcon from '@ncigdc/theme/icons/Minus';
import PlusIcon from '@ncigdc/theme/icons/Plus';

const strandIconMap = {
  '-1': <MinusIcon />,
  1: <PlusIcon />,
};

type TProps = {
  node: Object,
};

const GeneSummaryComponent = ({ node: gene }: TProps = {}) => (
  <EntityPageVerticalTable
    id="summary"
    title={<span><TableIcon style={{ marginRight: '1rem' }} />Summary</span>}
    thToTd={[
      { th: 'Symbol', td: gene.symbol },
      { th: 'Name', td: gene.name },
      { th: 'Synonyms',
        td: gene.synonyms.length && gene.synonyms.map(s => <div key={s}>{s}</div>),
        style: {
          whiteSpace: 'pre-wrap',
          wordBreak: 'breakWord',
        },
      },
      { th: 'Type', td: gene.biotype },
      {
        th: 'Location',
        td: `chr${gene.gene_chromosome}:${gene.gene_start}-${gene.gene_end} (GRCh38)`,
      },
      { th: 'Strand', td: gene.gene_strand && strandIconMap[gene.gene_strand.toString(10)] },
      { th: 'Description',
        collapsibleTd: gene.description,
        style: {
          whiteSpace: 'pre-wrap',
          wordBreak: 'breakWord',
          lineHeight: '2.2rem',
        },
      },
      { th: 'Annotation', td: gene.is_cancer_gene_census ? 'Cancer Gene Census' : '--' },
    ]}
    style={{
      summary: {
        marginBottom: '2rem',
      },
      column: {
        width: '100%',
        minWidth: 450,
      },
      alignSelf: 'flex-start',
      width: '100%',
    }}
  />
);

export const GeneSummaryQuery = {
  fragments: {
    node: () => Relay.QL`
      fragment on Gene {
        description
        gene_id
        symbol
        name
        synonyms
        biotype
        gene_chromosome
        gene_start<commit_msg>🔗 PRTL-1069 "Cancer Gene Census" links to exploration (#1621)<commit_after>// @flow

import React from 'react';
import Relay from 'react-relay';
import EntityPageVerticalTable from '@ncigdc/components/EntityPageVerticalTable';
import TableIcon from '@ncigdc/theme/icons/Table';
import MinusIcon from '@ncigdc/theme/icons/Minus';
import PlusIcon from '@ncigdc/theme/icons/Plus';
import ExploreLink from '@ncigdc/components/Links/ExploreLink';
import { makeFilter } from '@ncigdc/utils/filters';

const strandIconMap = {
  '-1': <MinusIcon />,
  1: <PlusIcon />,
};

type TProps = {
  node: Object,
};

const GeneSummaryComponent = ({ node: gene }: TProps = {}) => (
  <EntityPageVerticalTable
    id="summary"
    title={<span><TableIcon style={{ marginRight: '1rem' }} />Summary</span>}
    thToTd={[
      { th: 'Symbol', td: gene.symbol },
      { th: 'Name', td: gene.name },
      { th: 'Synonyms',
        td: gene.synonyms.length && gene.synonyms.map(s => <div key={s}>{s}</div>),
        style: {
          whiteSpace: 'pre-wrap',
          wordBreak: 'breakWord',
        },
      },
      { th: 'Type', td: gene.biotype },
      {
        th: 'Location',
        td: `chr${gene.gene_chromosome}:${gene.gene_start}-${gene.gene_end} (GRCh38)`,
      },
      { th: 'Strand', td: gene.gene_strand && strandIconMap[gene.gene_strand.toString(10)] },
      { th: 'Description',
        collapsibleTd: gene.description,
        style: {
          whiteSpace: 'pre-wrap',
          wordBreak: 'breakWord',
          lineHeight: '2.2rem',
        },
      },
      { th: 'Annotation',
        td: gene.is_cancer_gene_census ? (
          <ExploreLink
            merge
            query={{
              searchTableTab: 'genes',
              filters: makeFilter([
                { field: 'genes.is_cancer_gene_census', value: [gene.is_cancer_gene_census] },
              ], false),
            }}
          >
            Cancer Gene Census
          </ExploreLink>
        ) : '--',
      },
    ]}
    style={{
      summary: {
        marginBottom: '2rem',
      },
      column: {
        width: '100%',
        minWidth: 450,
      },
      alignSelf: 'flex-start',
      width: '100%',
    }}
  />
);

export const GeneSummaryQuery = {
  fragments: {
    node: () => Relay.QL`
      fragment on Gene {
        description
        gene_id
        symbol
        name
        synonyms
        biotype
        gene_chromosome
        gene_start
{'fraction_non_alphanumeric': 0.15496809480401094, 'fraction_numerical': 0.010483135824977211, 'mean_word_length': 2.1896802325581395, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '2764152', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1422, 'n_words': 290}