<commit_before>require_relative 'test_helper'

# TODO: Remove aliases after major refactoring
class Base      < RnaSec::Tree::Base; end
class BasePair  < RnaSec::Tree::BasePair; end
class MultiNode < RnaSec::Tree::MultiNode; end

class TestMultiNode < MiniTest::Unit::TestCase

  def setup
    @bases = [
      BasePair.new(Base.new(2, :g), Base.new(3, :c)),
      BasePair.new(Base.new(4, :g), Base.new(5, :c)),
    ]
    @ends = BasePair.new(Base.new(1, :g), Base.new(6, :c))
    @m    = MultiNode.new(@ends, @bases) 
  end

  def test_new_fails_with_nils
    assert_raises ArgumentError do
      MultiNode.new(nil, nil)
    end

    assert_raises ArgumentError do
      MultiNode.new(@ends, nil)
    end
  end

  def test_five_idx
    assert_equal @ends.five_idx, @m.five_idx
  end

  def test_five_nuc
    assert_equal @ends.five_nuc, @m.five_nuc
  end

  def test_idx
    assert_equal @m.five_idx, @m.idx
  end

  def test_three_idx
    assert_equal @ends.three_idx, @m.three_idx
  end

  def test_three_nuc
    assert_equal @ends.three_nuc, @m.three_nuc
  end

  def test_to_vienna
    assert_equal 'MultiNode<G1-C6>(BasePair<G2-C3>BasePair<G4-C5>)', @m.to_vienna
  end

  def test_get_bounds_on_multinode<commit_msg>Alias Base, BasePair, and MultiNode in test_multinode.<commit_after>require_relative 'test_helper'

# TODO: Remove aliases after major refactoring
Base      = RnaSec::Tree::Base
BasePair  = RnaSec::Tree::BasePair
MultiNode = RnaSec::Tree::MultiNode

class TestMultiNode < MiniTest::Unit::TestCase

  def setup
    @bases = [
      BasePair.new(Base.new(2, :g), Base.new(3, :c)),
      BasePair.new(Base.new(4, :g), Base.new(5, :c)),
    ]
    @ends = BasePair.new(Base.new(1, :g), Base.new(6, :c))
    @m    = MultiNode.new(@ends, @bases)
  end

  def test_new_fails_with_nils
    assert_raises ArgumentError do
      MultiNode.new(nil, nil)
    end

    assert_raises ArgumentError do
      MultiNode.new(@ends, nil)
    end
  end

  def test_five_idx
    assert_equal @ends.five_idx, @m.five_idx
  end

  def test_five_nuc
    assert_equal @ends.five_nuc, @m.five_nuc
  end

  def test_idx
    assert_equal @m.five_idx, @m.idx
  end

  def test_three_idx
    assert_equal @ends.three_idx, @m.three_idx
  end

  def test_three_nuc
    assert_equal @ends.three_nuc, @m.three_nuc
  end

  def test_to_vienna
    exp = %w[
    RnaSec::Tree::MultiNode<G1-C6>(
        RnaSec::Tree::BasePair<G2-C3>
        RnaSec::Tree::BasePair<G4-C5>
    )
    ].join()
    assert_equal exp, @m.to_vienna
  end

  def test_get_bounds_on_multinode
{'fraction_non_alphanumeric': 0.11485691885535085, 'fraction_numerical': 0.009408075264602116, 'mean_word_length': 3.4305555555555554, 'pattern_counts': {'":': 0, '<': 14, '<?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': '2984301', 'n_tokens_mistral': 1019, 'n_tokens_neox': 993, 'n_words': 197}