<commit_before>import unittest
from unittest import mock
from io import StringIO
from cref.sequence.alignment import Blast


class AlignmentTestCase(unittest.TestCase):

    def test_blast_local(self):
        blast = Blast('data/blastdb/pdbseqres')
        results = blast.align('AASSF')
        pdbs = {result.pdb_code for result in results}
        self.assertIn('1o61', pdbs)

    def test_blast_local_error(self):
        blast = Blast('db')
        with self.assertRaises(Exception) as cm:
            blast.align('AASSF')
        self.assertIn('Database error', cm.exception.args[-1])

    def test_blast_web(self):
        blast = Blast()
        with mock.patch('cref.sequence.alignment.NCBIWWW.qblast') as qblast:
            with open('tests/samples/web_blast.xml') as qblast_results:
                qblast.return_value = StringIO(qblast_results.read())
            results = blast.align('AASSF')
            self.assertIn('1o61', str(results))
            self.assertEqual(len(results), 493)
            pdbs = {result.pdb_code for result in results}
            self.assertIn('1o61', pdbs)<commit_msg>Fix broken test after blast web removal<commit_after>import unittest
from unittest import mock
from io import StringIO
from cref.sequence.alignment import Blast


class AlignmentTestCase(unittest.TestCase):

    def test_blast_local(self):
        blast = Blast('data/blastdb/pdbseqres')
        results = blast.align('AASSF')
        pdbs = {result.pdb_code for result in results}
        self.assertIn('1o61', pdbs)

    def test_blast_local_error(self):
        blast = Blast('db')
        with self.assertRaises(Exception) as cm:
            blast.align('AASSF')
        self.assertIn('Database error', cm.exception.args[-1])
{'fraction_non_alphanumeric': 0.10722477064220183, 'fraction_numerical': 0.00974770642201835, 'mean_word_length': 2.9569160997732427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '6866382', 'n_tokens_mistral': 551, 'n_tokens_neox': 519, 'n_words': 117}