<commit_before>"""
Tests that FASTA files can be loaded.
"""
import os
import unittest

import deepchem as dc


class TestFASTALoader(unittest.TestCase):
  """
  Test FASTALoader
  """

  def setUp(self):
    super(TestFASTALoader, self).setUp()
    self.current_dir = os.path.dirname(os.path.abspath(__file__))

  def test_fasta_load(self):
    legacy = False # Whether to assume legacy one hot encoding shape from FASTA loader.

    input_file = os.path.join(self.current_dir,
                              "../../data/tests/example.fasta")
    loader = dc.data.FASTALoader()
    sequences = loader.create_dataset(input_file)

    # example.fasta contains 3 sequences each of length 58.
    # The one-hot encoding turns base-pairs into vectors of length 5 (ATCGN).
    # There is one "image channel".
    if (legacy == True):
      assert sequences.X.shape == (3, 5, 58, 1)
    else:
      assert sequences.X.shape == (3, 58, 6)<commit_msg>flake8<commit_after>"""
Tests that FASTA files can be loaded.
"""
import os
import unittest

import deepchem as dc


class TestFASTALoader(unittest.TestCase):
  """
  Test FASTALoader
  """

  def setUp(self):
    super(TestFASTALoader, self).setUp()
    self.current_dir = os.path.dirname(os.path.abspath(__file__))

  def test_fasta_load(self):
    legacy = False  # Whether to assume legacy one hot encoding shape from FASTA loader.

    input_file = os.path.join(self.current_dir,
                              "../../data/tests/example.fasta")
    loader = dc.data.FASTALoader()
    sequences = loader.create_dataset(input_file)

    # example.fasta contains 3 sequences each of length 58.
    # The one-hot encoding turns base-pairs into vectors of length 5 (ATCGN).
    # There is one "image channel".
    if legacy:
      assert sequences.X.shape == (3, 5, 58, 1)
    else:
      assert sequences.X.shape == (3, 58, 6)
{'fraction_non_alphanumeric': 0.11349036402569593, 'fraction_numerical': 0.014453961456102784, 'mean_word_length': 2.926470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1069999', 'n_tokens_mistral': 632, 'n_tokens_neox': 598, 'n_words': 172}