<commit_before>FastaReader = require("biojs-io-fasta").parse
ClustalReader = require "biojs-io-clustal"
GffReader = require "biojs-io-gff"

module.exports = FileHelper =
  guessFileType: (name) ->
    name = name.split(".")
    fileName = name[name.length -1]
    switch fileName
      when "aln", "clustal" then return ClustalReader
      when "fasta" then return FastaReader
      else
        return FastaReader

  guessFileFromText: (text) ->
    unless text?
      console.warn "invalid file format"
      return [, "error"]
    if text.substring(0,7) is "CLUSTAL"
      reader = ClustalReader
      type = "seqs"
    else if text.substring(0,1) is ">"
      reader = FastaReader
      type = "seqs"
    else
      reader = GffReader
      type = "features"
      #console.warn "Unknown format. Contact greenify"
    [reader,type]

  parseText: (text) -><commit_msg>tiny coffee return type mistake<commit_after>FastaReader = require("biojs-io-fasta").parse
ClustalReader = require "biojs-io-clustal"
GffReader = require "biojs-io-gff"

module.exports = FileHelper =
  guessFileType: (name) ->
    name = name.split(".")
    fileName = name[name.length -1]
    switch fileName
      when "aln", "clustal" then return ClustalReader
      when "fasta" then return FastaReader
      else
        return FastaReader

  guessFileFromText: (text) ->
    unless text?
      console.warn "invalid file format"
      return ["", "error"]
    if text.substring(0,7) is "CLUSTAL"
      reader = ClustalReader
      type = "seqs"
    else if text.substring(0,1) is ">"
      reader = FastaReader
      type = "seqs"
    else
      reader = GffReader
      type = "features"
      #console.warn "Unknown format. Contact greenify"
    [reader,type]

  parseText: (text) ->
{'fraction_non_alphanumeric': 0.11464245175936436, 'fraction_numerical': 0.0056753688989784334, 'mean_word_length': 2.7913978494623657, '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': '315969', 'n_tokens_mistral': 573, 'n_tokens_neox': 574, 'n_words': 148}