<commit_before>#
# = bio/appl/tmhmm/report.rb - TMHMM report class
# 
# Copyright::  Copyright (C) 2003 
#              <NAME> <<EMAIL>>
# License::    The Ruby License
#
#  $Id: report.rb,v 1.8 2007/04/05 23:35:40 trevor Exp $
#
# == Description
#
#
# == Example
# == References
#

module Bio

  # = TMHMM class for http://www.cbs.dtu.dk/services/TMHMM/
  class TMHMM

    # Splits multiple reports into a report entry.
    def TMHMM.reports(data)
      entry     = []
      ent_state = ''
      data.each_line do |line|
        if /^\#/ =~ line
          if ent_state == 'next'
            ent_state = 'entry'
          elsif ent_state == 'tmh'
            ent_state = 'next'
          end
        else
          ent_state = 'tmh'
        end

        if ent_state != 'next'
          entry << line
        else
          if block_given?
            yield Bio::TMHMM::Report.new(entry)
          else
            Bio::TMHMM::Report.new(entry)
          end
          entry = [line]
        end
      end

      if block_given?
        yield Bio::TMHMM::Report.new(entry)
      else
        Bio::TMHMM::Report.new(entry)
      end
    end

    # = TMHMM report parser class.
    class Report

      # Returns an Array of Bio::TMHMM::TMH.
      attr_reader :tmhs

      # Returns
      attr_reader :entry_id

      # Returns
      attr_reader :query_len

      # Returns
      attr_reader :predicted_tmhs

      # Returns
      attr_reader :exp_aas_in_tmhs

      # Returns
      attr_reader :exp_first_60aa

      # Returns
      attr_reader :total_prob_of_N_in

      alias length query_len

      #
      def initialize(entry = nil)
        parse_header(entry)
        @tmhs = parse_tmhs(entry)<commit_msg>Ruby 1.9 support: using enumerator if the entry is a string<commit_after>#
# = bio/appl/tmhmm/report.rb - TMHMM report class
# 
# Copyright::  Copyright (C) 2003 
#              <NAME> <<EMAIL>>
# License::    The Ruby License
#
#  $Id:$
#
# == Description
#
#
# == Example
# == References
#

require 'enumerator'

module Bio

  # = TMHMM class for http://www.cbs.dtu.dk/services/TMHMM/
  class TMHMM

    # Splits multiple reports into a report entry.
    def TMHMM.reports(data)
      entry     = []
      ent_state = ''
      data.each_line do |line|
        if /^\#/ =~ line
          if ent_state == 'next'
            ent_state = 'entry'
          elsif ent_state == 'tmh'
            ent_state = 'next'
          end
        else
          ent_state = 'tmh'
        end

        if ent_state != 'next'
          entry << line
        else
          if block_given?
            yield Bio::TMHMM::Report.new(entry)
          else
            Bio::TMHMM::Report.new(entry)
          end
          entry = [line]
        end
      end

      if block_given?
        yield Bio::TMHMM::Report.new(entry)
      else
        Bio::TMHMM::Report.new(entry)
      end
    end

    # = TMHMM report parser class.
    class Report

      # Returns an Array of Bio::TMHMM::TMH.
      attr_reader :tmhs

      # Returns
      attr_reader :entry_id

      # Returns
      attr_reader :query_len

      # Returns
      attr_reader :predicted_tmhs

      # Returns
      attr_reader :exp_aas_in_tmhs

      # Returns
      attr_reader :exp_first_60aa

      # Returns
      attr_reader :total_prob_of_N_in

      alias length query_len

      #
      def initialize(entry = nil)
        begin
          str = entry.to_str
        rescue NoMethodError
        end
        if str then
          entry = str.enum_for(:each_line)
        end
        parse_header(entry)
        @tmhs = parse_tmhs(entry)
{'fraction_non_alphanumeric': 0.09674728940783987, 'fraction_numerical': 0.008340283569641367, 'mean_word_length': 1.6810730253353203, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7363503', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1155, 'n_words': 275}