<commit_before>
import os
import re
from subprocess import call
import sys
import unittest

# Setting this up as a direct translation of the original runtest.py script
# that will be run as part of 'python setup.py test'. This takes on the
# order of 10s to run.

class SystemTest(unittest.TestCase):
    """
    Run the program and compare against reference results.
    """
    def test_pka_calc(self):
        pdbs = ['1FTJ-Chain-A',
                '1HPX',
                '4DFR']

        test_dir = os.path.dirname(__file__)
        base_dir = os.path.dirname(test_dir)

        executable = os.path.join(base_dir, "scripts", "propka31.py")

        env = { "PYTHONPATH" : base_dir }

        for pdb in pdbs:
            input_filename = os.path.join(test_dir, "pdb", pdb + ".pdb")
            output_filename = os.path.join(test_dir, pdb + ".out")

            output_file = open(output_filename, "w")
            call([sys.executable, executable, input_filename],
                    stdout=output_file, env=env)
            output_file.close()

            # Check pka predictions.
            ref = open(os.path.join(test_dir, "results", pdb + ".dat"))
            output = open(output_filename)

            atpka = False
            errors = []
            for line in output:
                if not atpka:
                    # Start testing pka values.
                    if "model-pKa" in line:
                        atpka = True
                    continue

                m = re.search('([0-9]+\.[0-9]+)', line)
                if not m:
                    break

                expected_value = float(ref.readline())
                value = float(m.group(0))

                if(value != expected_value):
                    identity = line[:m.start()].strip()
                    errors.append("%12s  %8.2f    %8.2f" %
                            (identity, expected_value, value))

            ref.close()
            output.close()

            if errors:
                error_header = "       Group  Expected  Calculated\n"
                self.Fail("Unexpected pKa values:\n" + error_header +
                          "\n".join(errors))<commit_msg>Fix typo in PROPKA test.<commit_after>
import os
import re
from subprocess import call
import sys
import unittest

# Setting this up as a direct translation of the original runtest.py script
# that will be run as part of 'python setup.py test'. This takes on the
# order of 10s to run.

class SystemTest(unittest.TestCase):
    """
    Run the program and compare against reference results.
    """
    def test_pka_calc(self):
        pdbs = ['1FTJ-Chain-A',
                '1HPX',
                '4DFR']

        test_dir = os.path.dirname(__file__)
        base_dir = os.path.dirname(test_dir)

        executable = os.path.join(base_dir, "scripts", "propka31.py")

        env = { "PYTHONPATH" : base_dir }

        for pdb in pdbs:
            input_filename = os.path.join(test_dir, "pdb", pdb + ".pdb")
            output_filename = os.path.join(test_dir, pdb + ".out")

            output_file = open(output_filename, "w")
            call([sys.executable, executable, input_filename],
                    stdout=output_file, env=env)
            output_file.close()

            # Check pka predictions.
            ref = open(os.path.join(test_dir, "results", pdb + ".dat"))
            output = open(output_filename)

            atpka = False
            errors = []
            for line in output:
                if not atpka:
                    # Start testing pka values.
                    if "model-pKa" in line:
                        atpka = True
                    continue

                m = re.search('([0-9]+\.[0-9]+)', line)
                if not m:
                    break

                expected_value = float(ref.readline())
                value = float(m.group(0))

                if(value != expected_value):
                    identity = line[:m.start()].strip()
                    errors.append("%12s  %8.2f    %8.2f" %
                            (identity, expected_value, value))

            ref.close()
            output.close()

            if errors:
                error_header = "       Group  Expected  Calculated\n"
                self.fail("Unexpected pKa values:\n" + error_header +
                          "\n".join(errors))
{'fraction_non_alphanumeric': 0.10633432426252001, 'fraction_numerical': 0.008232334781614453, 'mean_word_length': 1.4824063564131669, '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': '6397961', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1202, 'n_words': 319}