<commit_before>function Enrichr_request(inst_cgm){

  function enrichr_icon(){

    var low_opacity = 0.7;
    var high_opacity = 1.0;
    var icon_size = 42;

    d3.select('.viz_svg').append("svg:image")
     .attr('x', 50)
     .attr('y', 2)
     .attr('width', icon_size)
     .attr('height', icon_size)
     .attr("xlink:href","img/enrichr_logo.png")
     .style('opacity', low_opacity)
     .classed('enrichr_logo', true)
     .on('click', function(){
       toggle_enrichr_menu();
     })
     .on('mouseover', function(){
       d3.select(this).style('opacity', high_opacity);
     })
     .on('mouseout', function(){
       d3.select(this).style('opacity', low_opacity);
     });

    var enr_menu = d3.select(inst_cgm.params.root+' .viz_svg')
      .append('g')
      .classed('showing', false)
      .classed('enrichr_menu', true)
      .attr('transform', 'translate(85,40)')
      .style('display', 'none');

    enr_menu
      .append('rect')
      .classed('enr_menu_background', true)
      .style('width', 500)
      .style('height', 425)
      .style('opacity', 0.95)
      .style('fill', 'white')
      .style('stroke', '#A3A3A3')
      .style('stroke-width', '3px');

    enr_menu
      .append('text')
      .attr('transform', 'translate(20,30)')
      .attr('font-family', '"Helvetica Neue", Helvetica, Arial, sans-serif')
      .style('font-size','18px')
      .style('font-weight', 800)
      .style('cursor', 'default')
      .text('Choose Enrichr Library');

    var lib_section = enr_menu
      .append('g')
      .attr('transform', 'translate(20,60)')
      .style('width', 460)
      .style('height', 330)
      .classed('enr_lib_section','true');

    var possible_libraries = ['ChEA_2015','KEA_2015',
      'ENCODE_TF_ChIP-seq_2015',
      'ENCODE_Histone_Modifications_2015',
      'Disease_Perturbations_from_GEO_up',
      'Disease_Perturbations_from_GEO_down',
      'GO_Molecular_Function_2015',
      'GO_Biological_Process_2015',
      'GO_Cellular_Component_2015',
      'Reactome_2015',
      'PPI_Hub_Proteins'
      ];
    var vertical_space = 35;

    var lib_groups = lib_section
      .selectAll('g')
      .data(possible_libraries)
      .enter()
      .append('g')
      .attr('transform', function(d,i){
        var vert =  i*vertical_space
        var transform_string = 'translate(0,'+ vert+')';
        return transform_string;
      })

    lib_groups
      .append('circle')
      .attr('cx', 10)
      .attr('cy', -6)
      .attr('r', 7)
      .style('stroke', '#A3A3A3')
      .style('stroke-width', '2px')
      .style('fill','white')

    lib_groups
      .append('text')
      .attr('transform', 'translate(25,0)')
      .style('font-size','18px')
      .attr('font-family', '"Helvetica Neue", Helvetica, Arial, sans-serif')
      .style('cursor', 'default')
      .text(function(d){
        return d.replace(/_/g, ' ');
      });

    lib_groups
      .on('click', function(d){

        d3.select(inst_cgm.params.root+' .enr_lib_section')
          .selectAll('g')
          .select('circle')
          .style('fill','white');

        // indicate that library was selected
        d3.select(this)
          .select('circle')
          .style('fill','red')

        // request enrichment results from Enrichr
        enr_obj.enrichr_rows(d, update_viz_callback, 10);

        make_enr_wait_circle();
        animate_wait();

        setTimeout(toggle_enrichr_menu, 500);
      })

  }

  function toggle_enrichr_menu(){

    var enr_menu = d3.select(inst_cgm.params.root+' .enrichr_menu');

    if (enr_menu.classed('showing') === false){
      enr_menu
        .classed('showing', true)
        .style('display', 'block');

      d3.select(inst_cgm.params.root+' .enrichr_menu')
        .style('opacity',0)<commit_msg>improved behavior of enrichr functions, now can clear results<commit_after>function Enrichr_request(inst_cgm){

  function enrichr_icon(){

    var low_opacity = 0.7;
    var high_opacity = 1.0;
    var icon_size = 42;

    d3.select('.viz_svg').append("svg:image")
     .attr('x', 50)
     .attr('y', 2)
     .attr('width', icon_size)
     .attr('height', icon_size)
     .attr("xlink:href","img/enrichr_logo.png")
     .style('opacity', low_opacity)
     .classed('enrichr_logo', true)
     .on('click', function(){
       toggle_enrichr_menu();
     })
     .on('mouseover', function(){
       d3.select(this).style('opacity', high_opacity);
     })
     .on('mouseout', function(){
       d3.select(this).style('opacity', low_opacity);
     });

    var enr_menu = d3.select(inst_cgm.params.root+' .viz_svg')
      .append('g')
      .classed('showing', false)
      .classed('enrichr_menu', true)
      .attr('transform', 'translate(85,40)')
      .style('display', 'none');

    enr_menu
      .append('rect')
      .classed('enr_menu_background', true)
      .style('width', 500)
      .style('height', 425)
      .style('opacity', 0.95)
      .style('fill', 'white')
      .style('stroke', '#A3A3A3')
      .style('stroke-width', '3px');

    enr_menu
      .append('text')
      .attr('transform', 'translate(20,30)')
      .attr('font-family', '"Helvetica Neue", Helvetica, Arial, sans-serif')
      .style('font-size','18px')
      .style('font-weight', 800)
      .style('cursor', 'default')
      .text('Choose Enrichr Library');

    // clear results button
    enr_menu
      .append('text')
      .classed('enr_menu_clear', true)
      .attr('transform', 'translate(350, 30)')
      .attr('font-family', '"Helvetica Neue", Helvetica, Arial, sans-serif')
      .style('font-size','18px')
      .style('font-weight', 800)
      .style('cursor', 'default')
      .text('Clear Results')
      .style('fill', 'red')
      .style('opacity', 0.75)
      .style('display', 'none')
      .on('click', function(){

        // reset enrichr menu
        toggle_enrichr_menu();

        d3.select(this)
          .style('display', 'none');

        d3.select(inst_cgm.params.root+' .enr_lib_section')
          .selectAll('g')
          .select('circle')
          .style('fill','white');

        // clear categories
        inst_cgm.reset_cats();

      })

    var lib_section = enr_menu
      .append('g')
      .attr('transform', 'translate(20,60)')
      .style('width', 460)
      .style('height', 330)
      .classed('enr_lib_section','true');

    var possible_libraries = ['ChEA_2015','KEA_2015',
      'ENCODE_TF_ChIP-seq_2015',
      'ENCODE_Histone_Modifications_2015',
      'Disease_Perturbations_from_GEO_up',
      'Disease_Perturbations_from_GEO_down',
      'GO_Molecular_Function_2015',
      'GO_Biological_Process_2015',
      'GO_Cellular_Component_2015',
      'Reactome_2015',
      'PPI_Hub_Proteins'
      ];
    var vertical_space = 35;

    var lib_groups = lib_section
      .selectAll('g')
      .data(possible_libraries)
      .enter()
      .append('g')
      .attr('transform', function(d,i){
        var vert =  i*vertical_space
        var transform_string = 'translate(0,'+ vert+')';
        return transform_string;
      })

    lib_groups
      .append('circle')
      .attr('cx', 10)
      .attr('cy', -6)
      .attr('r', 7)
      .style('stroke', '#A3A3A3')
      .style('stroke-width', '2px')
      .style('fill','white')

    lib_groups
      .append('text')
      .attr('transform', 'translate(25,0)')
      .style('font-size','18px')
      .attr('font-family', '"Helvetica Neue", Helvetica, Arial, sans-serif')
      .style('cursor', 'default')
      .text(function(d){
        return d.replace(/_/g, ' ');
      });

    lib_groups
      .on('click', function(d){

        d3.select(inst_cgm.params.root+' .enr_lib_section')
          .selectAll('g')
          .select('circle')
          .style('fill','white');

        // indicate that library was selected
        d3.select(this)
          .select('circle')
          .style('fill','red')

        // turn on clear sign
        d3.select(inst_cgm.params.root+' .enr_menu_clear')
          .transition()
          .delay(1000)
          .style('display', 'block');

        // request enrichment results from Enrichr
        enr_obj.enrichr_rows(d, update_viz_callback, 10);

        make_enr_wait_circle();
        animate_wait();

        setTimeout(toggle_enrichr_menu, 500);
      })

  }

  function toggle_enrichr_menu(){

    var enr_menu = d3.select(inst_cgm.params.root+' .enrichr_menu');

    if (enr_menu.classed('showing') === false){
      enr_menu
        .classed('showing', true)
        .style('display', 'block');

      d3.select(inst_cgm.params.root+' .enrichr_menu')
        .style('opacity',0)
{'fraction_non_alphanumeric': 0.17413051064324764, 'fraction_numerical': 0.027218797254856344, 'mean_word_length': 2.5543613063249277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7425261', 'n_tokens_mistral': 3138, 'n_tokens_neox': 2925, 'n_words': 469}