<commit_before>_ = require "underscore"

module.exports = treeHelper =  (msa) ->
  @msa = msa
  @

tf =

    loadTree: (cb) ->
      @msa.g.package.loadPackages ["msa-tnt", "biojs-io-newick"], cb

    showTree: (newickStr) ->
      newick = tf.require "biojs-io-newick"
      if typeof newickStr is "string"
        newickObj = newick.parse_newick newickStr
      else
        newickObj = newickStr

      mt = tf.require "msa-tnt"

      sel = new mt.selections()
      treeDiv = document.createElement "div"
      document.body.appendChild treeDiv

      console.log @msa.seqs.models
      console.log tree

      nodes = mt.app
        seqs: @msa.seqs.models
        tree: newickObj

      console.log "nodes", nodes

      t = new mt.adapters.tree
        model: nodes,
        el: treeDiv,
        sel: sel,

      treeDiv.style.width = "500px"

    # workaround against browserify's static analysis
    requireHelper: (pkg) ->
      require pkg

_.extend treeHelper:: , tf<commit_msg>fix: use a correct require workaround<commit_after>_ = require "underscore"

module.exports = treeHelper =  (msa) ->
  @msa = msa
  @

tf =

    loadTree: (cb) ->
      @msa.g.package.loadPackages ["msa-tnt", "biojs-io-newick"], cb

    showTree: (newickStr) ->
      newick = @require "biojs-io-newick"
      if typeof newickStr is "string"
        newickObj = newick.parse_newick newickStr
      else
        newickObj = newickStr

      mt = @require "msa-tnt"

      sel = new mt.selections()
      treeDiv = document.createElement "div"
      document.body.appendChild treeDiv

      console.log @msa.seqs.models
      console.log tree

      nodes = mt.app
        seqs: @msa.seqs.models
        tree: newickObj

      console.log "nodes", nodes

      t = new mt.adapters.tree
        model: nodes,
        el: treeDiv,
        sel: sel,

      treeDiv.style.width = "500px"

    # workaround against browserify's static analysis
    require: (pkg) ->
      require pkg

_.extend treeHelper:: , tf
{'fraction_non_alphanumeric': 0.10982948846539618, 'fraction_numerical': 0.003009027081243731, 'mean_word_length': 2.176751592356688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3180470', 'n_tokens_mistral': 689, 'n_tokens_neox': 653, 'n_words': 160}