<commit_before>var opts = {};

opts.el = document.getElementById('msa_menu');
//opts.zoomer = { textVisible: false};
opts.vis = {metacell: true, overviewbox: true};
opts.columns = {hidden: [1,2,3]};
var m = new msa.msa(opts);

// the menu is independent to the MSA container
var menuOpts = {};
menuOpts.el = document.getElementById("msa_menubar");
menuOpts.msa = m;
var defMenu = new msa.menu.defaultmenu(menuOpts);

m.addView("menu", defMenu);

//var overviewbox = m.getView("stage").getView("overviewbox");
//overviewbox.el.style.marginTop = "30px";

// search in URL for fasta or clustal
function getURLParameter(name) {return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null}

if( getURLParameter('fasta') !== undefined ){
  var url = msa.utils.proxy.corsURL(getURLParameter('fasta'), m.g);
  biojs.io.fasta.parse.read(url, renderMSA);
} else  if( getURLParameter('clustal') !== undefined ){
  var url = msa.utils.proxy.corsURL(getURLParameter('clustal'), m.g);
  biojs.io.clustal(getURLParameter('clustal'), renderMSA)
}else{
  opts.seqs = msa.utils.seqgen.getDummySequences(18,110);

  // display features
  var Feature = msa.model.feature;
  var f1 = new Feature({xStart:7 ,xEnd: 20,text: "foo1", fillColor: "red"});
  var f2 = new Feature({xStart:21,xEnd: 40,text: "foo2", fillColor: "blue"});
  var f3 = new Feature({xStart:10,xEnd: 30,text: "foo3", fillColor: "green"});
  m.seqs.at(1).set("features", new msa.model.featurecol([f1,f2,f3]));

  m.render();
}
function renderMSA(seqs){
  // hide some UI elements for large alignments
  if(seqs.length > 1000){
    m.g.vis.set("conserv", false);
    m.g.vis.set("metacell", false);
    m.g.vis.set("overviewbox", false);
  }
  m.seqs.reset(seqs);
  m.g.zoomer.set("alignmentWidth", "auto");
  m.render();
}

// listen to all events on the global event bus
m.g.onAll(function(eventName, data){
  log(eventName,data);
});

// BEGIN: Simple event logging system

var logger = document.getElementById("msa_menu_console");
function log(eventName,data){
  if(data !== undefined){
    text = eventName  + " triggered with " + removeCircularRefs(data);
  }
  message = document.createElement("div");
  message.textContent = text;

  // insert the div always at the top
  if(logger.childNodes.length > 0){
    logger.insertBefore(message,logger.firstChild);
  }else{
    logger.appendChild(message);
  }

  // cleanup
  if(logger.childNodes.length > 10){
    logger.removeChild(logger.lastChild);
  }
}

// prevent circular refs
function removeCircularRefs(obj){
  return JSON.stringify(obj, function( key, value) {
    if( key == 'parent') { return value.id;}
    else {return value;}
  })
}
<commit_msg>check the url for null (not undefined)<commit_after>var opts = {};

opts.el = document.getElementById('msa_menu');
//opts.zoomer = { textVisible: false};
opts.vis = {metacell: true, overviewbox: true};
opts.columns = {hidden: [1,2,3]};
var m = new msa.msa(opts);

// the menu is independent to the MSA container
var menuOpts = {};
menuOpts.el = document.getElementById("msa_menubar");
menuOpts.msa = m;
var defMenu = new msa.menu.defaultmenu(menuOpts);

m.addView("menu", defMenu);

//var overviewbox = m.getView("stage").getView("overviewbox");
//overviewbox.el.style.marginTop = "30px";

// search in URL for fasta or clustal
function getURLParameter(name) {return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null}

if( getURLParameter('fasta') !== null ){
  var url = msa.utils.proxy.corsURL(getURLParameter('fasta'), m.g);
  biojs.io.fasta.parse.read(url, renderMSA);
} else  if( getURLParameter('clustal') !== null ){
  var url = msa.utils.proxy.corsURL(getURLParameter('clustal'), m.g);
  biojs.io.clustal(getURLParameter('clustal'), renderMSA)
}else{
  opts.seqs = msa.utils.seqgen.getDummySequences(18,110);

  // display features
  var Feature = msa.model.feature;
  var f1 = new Feature({xStart:7 ,xEnd: 20,text: "foo1", fillColor: "red"});
  var f2 = new Feature({xStart:21,xEnd: 40,text: "foo2", fillColor: "blue"});
  var f3 = new Feature({xStart:10,xEnd: 30,text: "foo3", fillColor: "green"});
  m.seqs.at(1).set("features", new msa.model.featurecol([f1,f2,f3]));

  m.render();
}
function renderMSA(seqs){
  // hide some UI elements for large alignments
  if(seqs.length > 1000){
    m.g.vis.set("conserv", false);
    m.g.vis.set("metacell", false);
    m.g.vis.set("overviewbox", false);
  }
  m.seqs.reset(seqs);
  m.g.zoomer.set("alignmentWidth", "auto");
  m.render();
}

// listen to all events on the global event bus
m.g.onAll(function(eventName, data){
  log(eventName,data);
});

// BEGIN: Simple event logging system

var logger = document.getElementById("msa_menu_console");
function log(eventName,data){
  if(data !== undefined){
    text = eventName  + " triggered with " + removeCircularRefs(data);
  }
  message = document.createElement("div");
  message.textContent = text;

  // insert the div always at the top
  if(logger.childNodes.length > 0){
    logger.insertBefore(message,logger.firstChild);
  }else{
    logger.appendChild(message);
  }

  // cleanup
  if(logger.childNodes.length > 10){
    logger.removeChild(logger.lastChild);
  }
}

// prevent circular refs
function removeCircularRefs(obj){
  return JSON.stringify(obj, function( key, value) {
    if( key == 'parent') { return value.id;}
    else {return value;}
  })
}

{'fraction_non_alphanumeric': 0.18366975813784325, 'fraction_numerical': 0.0149118021458447, 'mean_word_length': 4.583756345177665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1429742', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1963, 'n_words': 412}