<commit_before># Copyright (c) 2014, <NAME>, OMRF
# Distributed under a BSD 3-Clause
# Full license available in LICENSE.txt distributed with this software

require 'erb'
require 'pathname'

class Optical::IgvSession
  NamedPath = Struct.new(:name, :path)

  def initialize(conf)
    @conf = conf
    @base_wd = Pathname.new(@conf.output_base)
  end


  def write(file)
    xml = render()
    File.open("#{file}.xml","w") do |out|
      out.puts xml
    end
    return true
  end

  private

  def beds()
    @conf.peak_callers.map do |p|
      NamedPath.new(File.basename(p.peak_bed_path,".bed"),p.peak_bed_path)
    end
  end

  def tdfs()
    samples = @conf.peak_callers.map {|pc| pc.treatments + pc.controls}.flatten.compact.uniq
    samples.map do |s|
      NamedPath.new(File.basename(s.bam_visual.tdf_wig_path,".tdf"), s.bam_visual.tdf_wig_path)
    end
  end

  def genome_name()
    File.basename(@conf.igv_reference,".genome")<commit_msg>Add peak beds & bam tdf to igv<commit_after># Copyright (c) 2014, <NAME>, OMRF
# Distributed under a BSD 3-Clause
# Full license available in LICENSE.txt distributed with this software

require 'erb'
require 'pathname'

class Optical::IgvSession
  NamedPath = Struct.new(:name, :path)

  def initialize(conf)
    @conf = conf
    @base_wd = Pathname.new(@conf.output_base)
  end


  def write(file)
    xml = render()
    File.open("#{file}.xml","w") do |out|
      out.puts xml
    end
    return true
  end

  private

  def beds()
    @conf.peak_callers.map do |p|
      p.peak_bed_path.map do |b|
        NamedPath.new(File.basename(b,".bed"),b)
      end
    end.flatten
  end

  def tdfs()
    samples = @conf.peak_callers.map {|pc| pc.treatments + pc.controls}.flatten.compact.uniq
    samples.map do |s|
      if s && s.bam_visual
        NamedPath.new(File.basename(s.bam_visual.tdf_wig_path,".tdf"), s.bam_visual.tdf_wig_path)
      end
    end.compact
  end

  def genome_name()
    File.basename(@conf.igv_reference,".genome")
{'fraction_non_alphanumeric': 0.12783090085556115, 'fraction_numerical': 0.0050327126321087065, 'mean_word_length': 3.211864406779661, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6407345', 'n_tokens_mistral': 775, 'n_tokens_neox': 719, 'n_words': 163}