<commit_before>import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as _ from 'lodash';
import * as tracksHelper from './tracksHelper';
import {CopyNumberSeg, Mutation, Sample} from 'shared/api/generated/CBioPortalAPI';
import SampleManager from "../sampleManager";
import {ClinicalDataBySampleId} from "../../../shared/api/api-types-extended";

interface TracksPropTypes {
    mutations:Array<Mutation>;
    cnaSegments:Array<CopyNumberSeg>;
    sampleManager:SampleManager;
    samples:Sample[];
    width:number;
}

export const DEFAULT_GENOME_BUILD="GRCh37";

export default class Tracks extends React.Component<TracksPropTypes, {}> {

    componentDidMount() {

        // --- construct params ---
        let cnaSamples = _.keyBy(this.props.samples.filter(s=>s.copyNumberSegmentPresent), s=>s.sampleId);
        let mutSamples = _.keyBy(this.props.samples.filter(s=>s.sequenced), s=>s.sampleId);
        var config = tracksHelper.GenomicOverviewConfig(Object.keys(cnaSamples).length + Object.keys(mutSamples).length, this.props.width);
        // --- end of params ---

        // --- raphael config ---
        let rowIndex: number = 0;
        var paper = tracksHelper.createRaphaelCanvas(document.getElementsByClassName('genomicOverviewTracksContainer')[0], config);
        // --- end of raphael config ---

        // --- chromosome chart ---
        let genomeBuild = DEFAULT_GENOME_BUILD;
        if (this.props.mutations) {
            genomeBuild = this.props.mutations[0].ncbiBuild;
        }
        const chmInfo = tracksHelper.getChmInfo( genomeBuild);
        tracksHelper.plotChromosomes(paper,config,chmInfo);
        // --- end of chromosome chart ---


        _.each(this.props.sampleManager.samples, (sample: ClinicalDataBySampleId) => {

            // --- CNA bar chart ---
            if (cnaSamples[sample.id]) {
                let raphaelData: Array<any> = [];
                var _trackData = _.filter(this.props.cnaSegments, function (_cnaObj: CopyNumberSeg) {
                    return _cnaObj.sampleId === sample.id;
                });
                _.each(_trackData, function (_dataObj: CopyNumberSeg) {
                    var _tmp: Array<any> = [];
                    _tmp.push(_dataObj.sampleId);<commit_msg>Fix patient view crash when no mutations<commit_after>import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as _ from 'lodash';
import * as tracksHelper from './tracksHelper';
import {CopyNumberSeg, Mutation, Sample} from 'shared/api/generated/CBioPortalAPI';
import SampleManager from "../sampleManager";
import {ClinicalDataBySampleId} from "../../../shared/api/api-types-extended";

interface TracksPropTypes {
    mutations:Array<Mutation>;
    cnaSegments:Array<CopyNumberSeg>;
    sampleManager:SampleManager;
    samples:Sample[];
    width:number;
}

export const DEFAULT_GENOME_BUILD="GRCh37";

export default class Tracks extends React.Component<TracksPropTypes, {}> {

    componentDidMount() {

        // --- construct params ---
        let cnaSamples = _.keyBy(this.props.samples.filter(s=>s.copyNumberSegmentPresent), s=>s.sampleId);
        let mutSamples = _.keyBy(this.props.samples.filter(s=>s.sequenced), s=>s.sampleId);
        var config = tracksHelper.GenomicOverviewConfig(Object.keys(cnaSamples).length + Object.keys(mutSamples).length, this.props.width);
        // --- end of params ---

        // --- raphael config ---
        let rowIndex: number = 0;
        var paper = tracksHelper.createRaphaelCanvas(document.getElementsByClassName('genomicOverviewTracksContainer')[0], config);
        // --- end of raphael config ---

        // --- chromosome chart ---
        let genomeBuild = DEFAULT_GENOME_BUILD;
        if (this.props.mutations && this.props.mutations.length > 0) {
            genomeBuild = this.props.mutations[0].ncbiBuild;
        }
        const chmInfo = tracksHelper.getChmInfo( genomeBuild);
        tracksHelper.plotChromosomes(paper,config,chmInfo);
        // --- end of chromosome chart ---


        _.each(this.props.sampleManager.samples, (sample: ClinicalDataBySampleId) => {

            // --- CNA bar chart ---
            if (cnaSamples[sample.id]) {
                let raphaelData: Array<any> = [];
                var _trackData = _.filter(this.props.cnaSegments, function (_cnaObj: CopyNumberSeg) {
                    return _cnaObj.sampleId === sample.id;
                });
                _.each(_trackData, function (_dataObj: CopyNumberSeg) {
                    var _tmp: Array<any> = [];
                    _tmp.push(_dataObj.sampleId);
{'fraction_non_alphanumeric': 0.13105536332179932, 'fraction_numerical': 0.002378892733564014, 'mean_word_length': 2.6246081504702192, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, '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': '6123630', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1287, 'n_words': 263}