<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";
import {stringListToSet} from "../../../shared/lib/StringUtils";

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

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

    constructor(){
        super();
    }

    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 ---
        var chmInfo = tracksHelper.getChmInfo();
        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);
                    _tmp.push(_dataObj.chromosome);
                    _tmp.push(_dataObj.end);
                    _tmp.push(_dataObj.start);
                    _tmp.push(_dataObj.numberOfProbes);
                    _tmp.push(_dataObj.segmentMean);
                    raphaelData.push(_tmp);
                });
                tracksHelper.plotCnSegs(paper, config, chmInfo, rowIndex, raphaelData, 1, 3, 2, 5, sample.id);
                rowIndex = rowIndex + 1;

                if (this.props.sampleManager.samples.length > 1) {
                    const $container = $(`#cnaTrack${sample.id}`);
                    const pos = {x: parseInt($container.attr('x')) - 10, y: parseInt($container.attr('y')) - 5};
                    const $newContainer = $('<svg height="12" width="12" />').attr(pos);
                    $container.replaceWith($newContainer);

                    let comp: any = this.props.sampleManager.getComponentForSample(sample.id);

                    ReactDOM.render(
                        comp,
                        $newContainer[0]
                    );
                }
            }
        });
        // --- end of CNA bar chart ---


        // --- mutation events bar chart ---
        _.each(this.props.sampleManager.samples, (sample: ClinicalDataBySampleId) => {
            if (mutSamples[sample.id]) {
                var _trackData = _.filter(this.props.mutations, function (_mutObj: any) {
                    return _mutObj.sampleId === sample.id;
                });
                tracksHelper.plotMuts(paper, config, chmInfo, rowIndex, _trackData, sample.id);
                rowIndex = rowIndex + 1;

                if (this.props.sampleManager.samples.length > 1) {
                    const id = `#mutTrack${sample.id}`;
                    const $container = $(id);
                    const pos = {x: parseInt($container.attr('x')) - 10, y: parseInt($container.attr('y')) - 5};
                    const $newContainer = $(`<svg id="${id}" height="12" width="12" />`);
                    $newContainer.attr(pos);
                    $container.replaceWith($newContainer);

                    let comp: any = this.props.sampleManager.getComponentForSample(sample.id);

                    ReactDOM.render(
                        comp,
                        $newContainer[0]
                    );
                }
            };
        });
        // --- end of mutation events bar chart ---




    }

<commit_msg>Fix genomic overview when dot in sample name<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";
import {stringListToSet} from "../../../shared/lib/StringUtils";

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

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

    constructor(){
        super();
    }

    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 ---
        var chmInfo = tracksHelper.getChmInfo();
        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);
                    _tmp.push(_dataObj.chromosome);
                    _tmp.push(_dataObj.end);
                    _tmp.push(_dataObj.start);
                    _tmp.push(_dataObj.numberOfProbes);
                    _tmp.push(_dataObj.segmentMean);
                    raphaelData.push(_tmp);
                });
                tracksHelper.plotCnSegs(paper, config, chmInfo, rowIndex, raphaelData, 1, 3, 2, 5, sample.id);
                rowIndex = rowIndex + 1;

                if (this.props.sampleManager.samples.length > 1) {
                    const $container = $(`[id="cnaTrack${sample.id}"]`);
                    const pos = {x: parseInt($container.attr('x')) - 10, y: parseInt($container.attr('y')) - 5};
                    const $newContainer = $('<svg height="12" width="12" />').attr(pos);
                    $container.replaceWith($newContainer);

                    let comp: any = this.props.sampleManager.getComponentForSample(sample.id);

                    ReactDOM.render(
                        comp,
                        $newContainer[0]
                    );
                }
            }
        });
        // --- end of CNA bar chart ---


        // --- mutation events bar chart ---
        _.each(this.props.sampleManager.samples, (sample: ClinicalDataBySampleId) => {
            if (mutSamples[sample.id]) {
                var _trackData = _.filter(this.props.mutations, function (_mutObj: any) {
                    return _mutObj.sampleId === sample.id;
                });
                tracksHelper.plotMuts(paper, config, chmInfo, rowIndex, _trackData, sample.id);
                rowIndex = rowIndex + 1;

                if (this.props.sampleManager.samples.length > 1) {
                    const id = `mutTrack${sample.id}`;
                    const $container = $(`[id="${id}"]`);
                    const pos = {x: parseInt($container.attr('x')) - 10, y: parseInt($container.attr('y')) - 5};
                    const $newContainer = $(`<svg id="${id}" height="12" width="12" />`);
                    $newContainer.attr(pos);
                    $container.replaceWith($newContainer);

                    let comp: any = this.props.sampleManager.getComponentForSample(sample.id);

                    ReactDOM.render(
                        comp,
                        $newContainer[0]
                    );
                }
            };
        });
        // --- end of mutation events bar chart ---




    }


{'fraction_non_alphanumeric': 0.1354389721627409, 'fraction_numerical': 0.00556745182012848, 'mean_word_length': 1.755457227138643, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, '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': '6953484', 'n_tokens_mistral': 2657, 'n_tokens_neox': 2459, 'n_words': 487}