<commit_before>import hashlib
import pytest
import random
import json

from src.ecprediction import *
from src.ecvalidatingfiles import *

SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) + "/"
REL_DIR = SCRIPT_DIRECTORY + '../temp/'

with open(SCRIPT_DIRECTORY + '../Data/Test_dictionaries/ecprediction_dict.json') as f:
    expected_dict = json.load(f)


def test_filterPredictions():

     test_prediction = parseResults([REL_DIR + 'xml/NC_011749.1.xml',REL_DIR + 'xml/AAJT02.1.xml'])
     i = 0

     while i<4:
        id_num = random.random() * 100
        length_num = random.random() * 100
        exp_dict = {}
        length_exp_dict = 0

        for expected_genome, expected_value in expected_dict.iteritems():
            if isinstance(expected_value, dict):
                expected_temp = {}
                for expected_title, expected_list in expected_value.iteritems():
                    expected_id_num = expected_list[2] * 100
                    expected_length_num = expected_list[1] * 100
                    if expected_length_num >= length_num:
                        if expected_id_num >=id_num:
                            expected_temp[expected_title] = [expected_list[0], expected_list[3]]
                            exp_dict[expected_genome]= expected_temp
                            length_exp_dict +=1
                        else:
                            expected_temp[expected_title] = [expected_list[0], 'NA']<commit_msg>Added initalizeDB() and runBlastQUery() to test_ecprediction.py<commit_after>import hashlib
import pytest
import random
import json

from src.ecprediction import *
from src.ecvalidatingfiles import *

SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) + "/"
REL_DIR = SCRIPT_DIRECTORY + '../temp/'

with open(SCRIPT_DIRECTORY + '../Data/Test_dictionaries/ecprediction_dict.json') as f:
    expected_dict = json.load(f)


initializeDB()

runBlastQuery(sorted([
    SCRIPT_DIRECTORY + '../Data/Testing_Data/Reference_Genomes/NC_011749.1.fasta'
    , SCRIPT_DIRECTORY + '../Data/Testing_Data/Reference_Genomes/AAJT02.1.fsa_nt']), 'ECTyperDB')

def test_filterPredictions():

     test_prediction = parseResults([REL_DIR + 'xml/NC_011749.1.xml',REL_DIR + 'xml/AAJT02.1.xml'])
     i = 0

     while i<4:
        id_num = random.random() * 100
        length_num = random.random() * 100
        exp_dict = {}
        length_exp_dict = 0

        for expected_genome, expected_value in expected_dict.iteritems():
            if isinstance(expected_value, dict):
                expected_temp = {}
                for expected_title, expected_list in expected_value.iteritems():
                    expected_id_num = expected_list[2] * 100
                    expected_length_num = expected_list[1] * 100
                    if expected_length_num >= length_num:
                        if expected_id_num >=id_num:
                            expected_temp[expected_title] = [expected_list[0], expected_list[3]]
                            exp_dict[expected_genome]= expected_temp
                            length_exp_dict +=1
                        else:
                            expected_temp[expected_title] = [expected_list[0], 'NA']
{'fraction_non_alphanumeric': 0.09826410415375078, 'fraction_numerical': 0.022318660880347178, 'mean_word_length': 2.2895005096839958, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '1046016', 'n_tokens_mistral': 1017, 'n_tokens_neox': 940, 'n_words': 175}