'''
Makes sure the predictor gets the same values as we expect from the original predictor. 
'''
from TADA_T2.TADA import predict


def is_close(a, b, tolerance=0.000001):
    '''
    Function to check if two numbers are close. 
    '''
    return abs(a-b) <= tolerance


def test_predictor_is_correct():
    '''
    Function to make sure this version of TADA gets the same TAD predictions as 
    the original version of TADA. This tests 100 sequences. 
    '''
    original_TADA_scores={'QFNENSNIMQQQPLQGSFNPLLEYDFANHGGQWLSDYIDL': 0.637078643, 'EFSPENSSSSSWSSQESFLWEESFLHQSFDQSFLLSSPTD': 0.645964801, 'VLPPLSESFDLDSLMSTPMSSPRQNSIEAETNSSTFFDFG': 0.662755132, 'SWLLPNSGKNSGNNNGFSIGDEFLNLVDYSSSDKQFTDQS': 0.577608645, 'QAFGNSPQNSSSNGSLSSSLDEENNFFFSLTSEEHNKSNN': 0.4973737, 'ELFKNHNEDYIQTQYGTNDADEYMSKFLDSFLDIPYEPEQ': 0.602484941, 'IVQQEDLSEWEGFNADTFFSDNNNNYNLNVHHQLTPYGDG': 0.576722324, 'NATSDLNMDQDYDFSQFFEKFGGDNHNEENSMNDLLMSDV': 0.676980257, 'KNSINVFGGEHGYEDFGFCYDDKFSSFLNSLINDVGDPFG': 0.646433651, 'IMEDGVIDEIHKQSDLPLWYDDLITTDEDPLMSSILGDLL': 0.670372307, 'ELRFEYIEEAYSEFNDIIIQEVDKPDLLEIPFDSDPDIWS': 0.691135406, 'PTEEQNPFFLPDLFRSGDYFWDSEITPDPLFLDEFHQSLL': 0.671409309, 'LKKNNVCENSITCNKDDEKDDFVNNLMNGDNMWLENLLGE': 0.575095773, 'ANSSSSSQQVFEFEYLDDSVLDELLEYGENYNKTHNINMG': 0.630013287, 'DYGWPNDVDQSHLDSSDMFDVDELLRDLNGDDVFAGLNQD': 0.641659141, 'CFIPEMDMIIPETDSFFFQSQPQLEFHQPLFQEEAPSQTH': 0.641651869, 'SDLDFLLDDENGDFADFDFSFDNSDDFFDFDLSEPAVVIP': 0.688971817, 'DGLMNPNDAFCLCNGTFTWQLYGEEDVGFRFEEPFNWQND': 0.662678242, 'DQIFCENDDIFNDMLFLGGETMNIEDELTSSSIKDMGSTF': 0.650848985, 'NQLNNIMDPSTTLNQITSDIWFEDDQAILFDQQQSFSGAF': 0.630743623, 'KEEDMFSGSDDYLIQMEHDDGWLHEAMSNLIPFPCEFDAP': 0.694395065, 'ILPIQEDLPLVWSLEDLDSLLSGTELHKLVKEDHVLIYED': 0.533637226, 'EQVEEETKKLKASGCFDRSLHDFDEIQHMDDMFLSSILED': 0.612104237, 'ESSSTVTDQNSSMDNENHLIDNIYDDDELFSYLWSDETTK': 0.625922024, 'MCALVPPLYPNFGWPCGDHSFYETDDVSNTFLDFPLPDLT': 0.660090864, 'CKVDYLSYQGDDLSSILYRIDESDFTFEGLRMDGHDQLGE': 0.577952623, 'FSDDLLDGIDYYDDLFIGFDGDDVLPDLEIDSEILGEYSG': 0.718448281, 'RDENLNGGDLLSFEFDGSHFFNFSIFDHETTCKRLKRSSE': 0.552880168, 'MHTKPELHEVNGLNEIQFLLDHDDFDDITSEFLQDNDILF': 0.669813037, 'EKPGQENFFGMSVDDLGTPKNEQEDFSLWDVLDPDMLFSD': 0.678077281, 'QQQQDSLSVADYGWPNDVDQSHLDSSDMFDVDELLRDLNG': 0.633327305, 'FEFQGLLDDKEIQEILECSFSEEPDQLVSQGSFMINGDNW': 0.610447705, 'MNSIFSIDDFSDPFWETPPIPLNPDSSKPVTADEVSQSQP': 0.528875291, 'WDYEFDYDDEIENGTEVEPVEIGDGVDWWKIDTEDGVGSS': 0.600601971, 'YNYSLNSIPDAENDLSFFDNGDKEKNDLFYGWGDIGNFED': 0.669441521, 'PPRQPRHVGDGVAFGQFLDLGSSGQIDFDAAAAAFFPNLP': 0.587494075, 'ENQEADAIVPEATTAEHGATLAFDVEQLWSLFDGETVELD': 0.605891705, 'AENDLSFFDNGDKEKNDLFYGWGDIGNFEDVDNMLRSCDS': 0.660498917, 'ASILWAEEEDMCNEKSHVLTYADKEGDWMMVGDVPWEMFL': 0.63095367, 'CHSPPPWNEQEETGSPFRTENFSWDTLIEMPRSETTTMQF': 0.483799428, 'QFQMEEFDPFYQSSEHIIDHMKEDISINNSEYDFSQFLEQ': 0.674408555, 'FANVQGESQIDDATTPIEEEWKTWLNNDGDEQRNIMFMQD': 0.550652266, 'DQTPIGELMSDLGFPDGEFELTFDGMDDLYFPAENESFLI': 0.702092111, 'AEDTRDYHNQDGNWLDYLWFERLHDLNFSDQGFEDQTSTV': 0.647073627, 'GVDYWFRSEVGEVSITDMWPDESGPDWNQMITFDQDHAGP': 0.613302588, 'EGNGGFSPNSSFGAFADTAMDLDFMDELLFDGCWLETTDS': 0.671220005, 'SMDELDFNKDFDLPPSSNQTLGLANGFYLDDLDFSSLDPP': 0.697582006, 'TSLNHPSTAQHSSGSDFLEDWEKFLDDETSDSCWKSFLDL': 0.640011549, 'AGATFDYPFLEALQEIIDSSSSSPPLILQNGQEENFNNPM': 0.584760666, 'TSVNTPRDRLCTVDDLQLHIGDWFYTDGAGQEQGPLSFSE': 0.604496717, 'MEMESFMDDLLNFSVPEEEEDDDEHTQPPRNITRRKTGLR': 0.361037374, 'EVSKQGENETEDFEFGLIDDFESSPWDVDHFFDHHHHSFD': 0.654456675, 'GSSDSEGKFGFQTGPDFTLEEFQKYDEYFKECYFQSEDHP': 0.610997081, 'QEPLEFGVDETFDINELLGILNDNNVSGQETMQYQVDRHP': 0.577261984, 'DAEIDAGFQFLAPDLFSTCELESGLKWFDQQDHEDFPYCS': 0.697733223, 'MEGRVNALSNINDLELHNFLVDPNFDQFINLIRGDHQTID': 0.568151653, 'TMVDEIPMSVPSLMTGLSQDDDFVPWLNHHPSLDGYCSDF': 0.61768049, 'PEMSIFDQPMDQIFCENDDIFNDMLFLGGETMNIEDELTS': 0.702756763, 'FSQSYEYMIDNKEDLGTSIDLNIPEYDFPQFLEQLINDDD': 0.682582974, 'SCESNNVKNSEPYGGMSVGHKNIETMADDFVDWDFVWREG': 0.56252414, 'SDGAREERPLYLFDPKFAEKVPVLDSEYDVPVYFREDLFG': 0.546336293, 'SWSSQESFLWEESFLHQSFDQSFLLSSPTDNYCDDFFAFE': 0.718793273, 'DQHYYHLAFFTTRDIEAMEELAWDYGIDFNDNDSLMKPFD': 0.611177921, 'MIGTSFPEDLDCGNFFDNMDDLMDFPGGDIDVGFGIGDSD': 0.687168658, 'RTMVSSKEVLSKCEWPDWADQLISDDSLEPNWSELLGDPN': 0.631952882, 'FNLDSILASENGSLMDGSFNAESYHQLQQWPFDGYHQPEW': 0.584000826, 'EVTKSQSFDHPQPDIPCGFEDTNEESDLRRQLVESTTPNN': 0.205637708, 'VGGASLSGGGDTPKTTSSQIFNEDTLDQFLELMGRSCKEE': 0.479624182, 'QEQQQQQLQPDLLTVADYGWPWSNDIVNDQTSWDPNECFD': 0.660169959, 'DYNDVSEFGFAAETTSDGLPDVCWEQFAAGITETGFNWPT': 0.64871031, 'QRDEDPLYVFDDKFGEAAPELLKDYSVPHLFQEDWFEILD': 0.689492226, 'EDYFRRLDFPDLETLSDLASLRSLSSRNCFSIPSVEYDSI': 0.452268034, 'NLSWFENINGAASSSDSLWNIGETDEEFWFLQQQQQFNNN': 0.645190895, 'AESSLVISGDSHSDACDEATTAELVDFKWYPELESLDFTL': 0.623853266, 'ETNDLSCAQQDDFNFEDYLSFFDDEGLTFDDSLLMGPEDF': 0.708377421, 'DLGFPDGEFELTFDGMDDLYFPAENESFLIPINTSNQEQF': 0.680244625, 'APLVTKAKGRKLTAEELWSELDASAADDFWGFYSTSKLHP': 0.542910457, 'SPIFSSEKKTAVSGADDVAVFFPMGEEDESLFADLGELPE': 0.592305183, 'KESNEETVFDLPDLFTDGLMNPNDAFCLCNGTFTWQLYGE': 0.63344568, 'CYNDFPVESNYLIGEAFLDPNSNLLENDGLYLETNDLSST': 0.686418056, 'ETEESLNCCVPVFDPFSDMLIDDINGFCLVPDEVNNTTTN': 0.656974971, 'DAVQELWKKKDVVDKELIASLRAAAGLPTEEEIFSIFPFS': 0.446763277, 'LPDFDFADVEDLQLADSSFGFLDQLAPINISCPLKSFAAS': 0.598931491, 'MERNNRNEGTHEEEQCSLSDIIYSFCSENHSELNPLQEIF': 0.550824165, 'GDDIASSSSRRKTPFQFDLNFPPLDGVDLFAGGIDDLHCT': 0.591349363, 'MDHSSVPENSSMAKELGVCEDDFNGNLISDEVDLALENYE': 0.570704162, 'VSDENTLHRSNDFSTADFHTSGLSVPMDDIAELEWLSNFV': 0.631526768, 'EPKWGELEDALEAFDTSMFGSSMELLQPDAFVPQFLYQSD': 0.65042305, 'LLVCDGFMGDFDFDASFVSGLWCIEPHVPKQEPDSPVLDP': 0.594468057, 'VTVVEQEANHNGDVFLDRFNEALHYYSSLFDSLEDGVVIP': 0.596358716, 'IENVLMNTFDGAEAAVLDLKQYNPEEDLILTELIDELARD': 0.596449316, 'EEEEEDHLLSSTFESINGHSRDQHNHSIDDFESIFDITID': 0.621232986, 'ENENIVGPEQDLLMSDFPSTFVDEDDILGDITSWSTYLLD': 0.678622127, 'NFGWPCGDHSFYETDDVSNTFLDFPLPDLTVTHENVSSEN': 0.635302722, 'VRDVLEGASDLTFEFPDFEECMNLIRGRKSLSDDIVLKSI': 0.470604807, 'SMIDEGHLWGSLWNLDEDDPHSFGGGSGQGTAADIDEKFP': 0.551305234, 'SFIDQNHLYPLPNISTVEDISFLEYNVDKTENSGSEKLAN': 0.497447371, 'FMQSSSSPEIHQFEDLFKSYKLSDEMNNLVEASEYDFGEE': 0.579854369, 'SKAFYGASSLHDFEGIEQMDDMFLSSILEDVPEDDGDVHR': 0.615141034, 'YRFHPTDEELVDYYLKNKVAFPGMQVDVIKDVDLYKIEPW': 0.256095409}
    sequences=list(original_TADA_scores.keys())
    TADA_scores=predict(sequences)
    # assert each score is equivalent. 
    for seq in sequences:
        assert is_close(original_TADA_scores[seq], TADA_scores[seq][0][1])
