require 'yaml' require File.expand_path( File.dirname(__FILE__) + '/../spec_helper' ) require 'validator/background' describe Validator::Background do before(:all) do @expected = YAML.load("badAA: 45 tpred-1: 36 tpred-1-0.8: 36 tpred-2: 36 tpred-2-0.8: 36 phob-1: 38 phob-2: 37 phob-1-0.8: 38 phob-2-0.8: 37 bias-mrna: 29 bias-prot: 37 ") @data = { 'badAA' => [0.158873276514528, 0.15968405463222, 0.159870678279229, 0.159635650410558, 0.156543159883917, 0.152783096042051, 0.150294985250737, 0.145335608646189, 0.134808758575322, 0.125552050473186, 0.112790697674419, 0.0960860693748841, 0.076310861423221, 0.0560216123986919, 0.0388044914134742, 0.0250922509225092, 0.0187774670395525, 0.0111182381868719, 0.00934787447139996, 0.00583022388059702, 0.00460382844681367, 0.00348518795120737, 0.00284164298630845, 0.0021488047273704, 0.00167177486765116, 0.00175080245112343, 0.00182926829268293, 0.00191570881226054, 0.0016767270288397, 0.00177116542685087, 0.00186219739292365, 0.00198491464867011, 0.00211864406779661, 0.00136986301369863, 0.00146412884333821, 0.00107642626480086, 0.00120336943441637, 0.000672494956287828, 0.000764525993883792, 0.000887311446317658, 0.00103734439834025, 0.00123609394313968, 0.00151975683890578, 0.00179856115107914, 0.00215982721382289, 0.00266666666666667, 0.0, 0.0, 0.0, 0.0, 0.0/0.0], 'tpred-1-0.8' => [0.432087342709104, 0.430464886251236, 0.432952622673435, 0.430709911544568, 0.431700713758307, 0.426344086021505, 0.42326139088729, 0.412998624484182, 0.405773857257418, 0.395963479096588, 0.379389752446747, 0.375838926174497, 0.371165644171779, 0.366496598639456, 0.351903435468895, 0.337611056268509, 0.334031413612565, 0.332236842105263, 0.335585585585586, 0.334894613583138, 0.33133971291866, 0.334558823529412, 0.331658291457286, 0.328998699609883, 0.330175913396482, 0.334745762711864, 0.332844574780059, 0.327188940092166, 0.317152103559871, 0.320689655172414, 0.323583180987203, 0.324271844660194, 0.322245322245322, 0.317180616740088, 0.324644549763033, 0.323834196891192, 0.32183908045977, 0.327044025157233, 0.316363636363636, 0.311203319502075, 0.314553990610329, 0.318918918918919, 0.306122448979592, 0.307086614173228, 0.295238095238095, 0.255555555555556, 0.246753246753247, 0.254237288135593, 0.290322580645161, 0.3, 0.0/0.0], 'tpred-2-0.8' => [0.193930421909697, 0.194460929772502, 0.193104906937394, 0.188931730551145, 0.187792271720404, 0.181989247311828, 0.176558752997602, 0.172627235213205, 0.168003207698476, 0.157135992311389, 0.145653425446172, 0.136241610738255, 0.125766871165644, 0.122448979591837, 0.115134633240483, 0.107601184600197, 0.103664921465969, 0.103070175438596, 0.102477477477477, 0.101873536299766, 0.101674641148325, 0.10171568627451, 0.101758793969849, 0.0988296488946684, 0.0987821380243572, 0.100282485875706, 0.095307917888563, 0.0921658986175115, 0.0809061488673139, 0.0793103448275862, 0.0822669104204753, 0.0757281553398058, 0.079002079002079, 0.0814977973568282, 0.0853080568720379, 0.0803108808290155, 0.0718390804597701, 0.0786163522012579, 0.0836363636363636, 0.0746887966804979, 0.07981220657277, 0.0756756756756757, 0.0748299319727891, 0.062992125984252, 0.0666666666666667, 0.0555555555555556, 0.025974025974026, 0.0338983050847458, 0.032258064516129, 0.0, 0.0/0.0], 'tpred-1' => [0.43492586490939, 0.434656516222585, 0.437751004016064, 0.439366015481017, 0.435423665546846, 0.432272813869308, 0.432531593966572, 0.422057502246181, 0.419948186528497, 0.413091136861885, 0.395751376868607, 0.39067055393586, 0.379793061472915, 0.378066378066378, 0.366721854304636, 0.348222424794895, 0.34251968503937, 0.339958158995816, 0.343073593073593, 0.343502824858757, 0.337587006960557, 0.33969010727056, 0.336196319018405, 0.332909783989835, 0.334656084656085, 0.339779005524862, 0.339055793991416, 0.331831831831832, 0.323343848580442, 0.326050420168067, 0.329181494661922, 0.330170777988615, 0.325865580448065, 0.321814254859611, 0.326340326340326, 0.322250639386189, 0.320113314447592, 0.325077399380805, 0.314285714285714, 0.308943089430894, 0.311926605504587, 0.317460317460317, 0.304635761589404, 0.305343511450382, 0.293577981651376, 0.258064516129032, 0.253164556962025, 0.262295081967213, 0.303030303030303, 0.333333333333333, 0.0/0.0], 'tpred-2' => [0.197144426139484, 0.197571143737539, 0.197699890470975, 0.195355694802801, 0.192422545726017, 0.191465040960183, 0.188544639217285, 0.185085354896676, 0.184974093264249, 0.176636392107736, 0.164044059795437, 0.154518950437318, 0.143639683505782, 0.137085137085137, 0.129966887417219, 0.113035551504102, 0.108267716535433, 0.105648535564854, 0.103896103896104, 0.105084745762712, 0.103248259860789, 0.103694874851013, 0.101840490797546, 0.0991105463786531, 0.0992063492063492, 0.100828729281768, 0.0958512160228898, 0.0930930930930931, 0.082018927444795, 0.0789915966386555, 0.0818505338078292, 0.0759013282732448, 0.0794297352342159, 0.08207343412527, 0.0839160839160839, 0.0792838874680307, 0.0708215297450425, 0.0773993808049536, 0.0821428571428571, 0.0731707317073171, 0.0779816513761468, 0.0740740740740741, 0.0728476821192053, 0.0610687022900763, 0.0642201834862385, 0.0537634408602151, 0.0253164556962025, 0.0327868852459016, 0.0303030303030303, 0.0, 0.0/0.0], 'phob-1-0.8' => [0.185672175669857, 0.18433572392246, 0.181897765767137, 0.178760843645932, 0.176211849192101, 0.17261698440208, 0.168649249583102, 0.164665082525207, 0.158626390141268, 0.149688712442479, 0.140255798829395, 0.127386902473408, 0.116115516983391, 0.106017191977077, 0.0974025974025974, 0.0923076923076923, 0.0875342754693103, 0.0849369608493696, 0.0839240795792362, 0.0830359267190102, 0.0802955665024631, 0.0777188998233661, 0.0760188087774295, 0.0748373101952278, 0.0739595050618673, 0.0732568402471315, 0.0716041794714198, 0.070096463022508, 0.0682432432432432, 0.0678329168154231, 0.0672174239579422, 0.0656262505002001, 0.0652173913043478, 0.0629306384933395, 0.0637567435017165, 0.0637837837837838, 0.0609903381642512, 0.0594193112761648, 0.0598618572524942, 0.0587711487088157, 0.059375, 0.0619578686493185, 0.0609756097560976, 0.0576576576576577, 0.0497835497835498, 0.0427807486631016, 0.043010752688172, 0.0396039603960396, 0.0504201680672269, 0.075, 0.0/0.0], 'phob-2-0.8' => [0.10336833040771, 0.10306752822552, 0.102234232862635, 0.099946552645644, 0.0978007181328546, 0.0957662787818767, 0.0927181767648694, 0.0913878363624687, 0.0879921851517884, 0.0834611567265181, 0.0773899848254932, 0.0688196847366398, 0.0604518928624869, 0.0551154559244901, 0.050834879406308, 0.0477522477522478, 0.0438726007171483, 0.0433532404335324, 0.042305053738852, 0.0418748512966928, 0.0399014778325123, 0.0386071158213475, 0.0378787878787879, 0.0366052060737527, 0.0357142857142857, 0.0344218887908208, 0.0331899200983405, 0.0327974276527331, 0.0307432432432432, 0.0307033202427704, 0.0311678558017274, 0.0300120048019208, 0.0294117647058824, 0.0257234726688103, 0.0264835703776361, 0.0264864864864865, 0.0241545893719807, 0.0229574611748818, 0.0230237912509593, 0.0231522707034728, 0.025, 0.0285006195786865, 0.0274390243902439, 0.0234234234234234, 0.0238095238095238, 0.018716577540107, 0.021505376344086, 0.0247524752475248, 0.0336134453781513, 0.05, 0.0/0.0], 'phob-1' => [0.189416875082269, 0.188798733425688, 0.187119003445534, 0.186618069952518, 0.184998809969059, 0.183175272216368, 0.18173689504862, 0.178471651602301, 0.173068705189687, 0.166212849776954, 0.156364435330306, 0.146373298526944, 0.134995296331138, 0.119743406985032, 0.107213765718068, 0.0987060998151571, 0.0901459124525285, 0.0851336898395722, 0.0844097995545657, 0.083527764815679, 0.0809500727096461, 0.077191235059761, 0.0762076982691811, 0.075208165457964, 0.0743939816104765, 0.0735337029471841, 0.0719512195121951, 0.070242656449553, 0.06841046277666, 0.0680127523910733, 0.0674115456238361, 0.0658991663358476, 0.0656779661016949, 0.0634703196347032, 0.063933626159102, 0.0640473627556512, 0.0613718411552347, 0.0598520511096167, 0.0603975535168196, 0.059449866903283, 0.0601659751037344, 0.0618046971569839, 0.060790273556231, 0.0575539568345324, 0.0496760259179266, 0.0426666666666667, 0.0428571428571429, 0.0396039603960396, 0.0504201680672269, 0.075, 0.0/0.0], 'phob-2' => [0.106884296432802, 0.106174549772412, 0.105618870924993, 0.10492877683408, 0.103770698038149, 0.102774850720056, 0.101225736746023, 0.0991783073130649, 0.0961967617871896, 0.0911882277967673, 0.0851765050534642, 0.0778482192802536, 0.0702022577610536, 0.06143977191732, 0.0559232296492389, 0.0495378927911275, 0.0439736158305017, 0.0434224598930481, 0.0427616926503341, 0.042230517965469, 0.0399903053805138, 0.0383466135458167, 0.0379746835443038, 0.0367982809562181, 0.0359431596544999, 0.0347242486139481, 0.0335365853658537, 0.0328863346104725, 0.0308517773306506, 0.0308182784272051, 0.0312849162011173, 0.0301707026597856, 0.0296610169491525, 0.026027397260274, 0.0263543191800878, 0.0263724434876211, 0.0240673886883273, 0.0228648285137861, 0.0229357798165138, 0.0230700976042591, 0.024896265560166, 0.0284301606922126, 0.027355623100304, 0.0233812949640288, 0.0237580993520518, 0.0186666666666667, 0.0214285714285714, 0.0247524752475248, 0.0336134453781513, 0.05, 0.0/0.0], 'bias-mrna' => [0.433808285892922, 0.433569195326641, 0.433953549749274, 0.43349622685416, 0.433556050482554, 0.434016778640304, 0.42787610619469, 0.416422883146433, 0.400291326003195, 0.376082592486378, 0.340843023255814, 0.300129846039696, 0.250117041198502, 0.202474050902886, 0.159676354029062, 0.122878228782288, 0.0966839792249301, 0.077613855035279, 0.069441353216114, 0.0608675373134328, 0.0576690089653501, 0.0560119492158327, 0.0539912167398605, 0.0523771152296535, 0.0512677626079688, 0.0507732710825795, 0.0509146341463415, 0.0507662835249042, 0.0489604292421194, 0.0474672334396033, 0.0491620111731844, 0.0504168320762207, 0.0508474576271186, 0.0506849315068493, 0.0502684236212787, 0.0522066738428418, 0.0523465703971119, 0.0537995965030262, 0.0512232415902141, 0.0488021295474712, 0.0508298755186722, 0.0531520395550062, 0.0547112462006079, 0.0593525179856115, 0.060475161987041, 0.064, 0.0678571428571429, 0.0693069306930693, 0.0756302521008403, 0.05, 0.0/0.0], 'bias-prot' => [0.689591628549804, 0.689122922494652, 0.688836104513064, 0.68950500315814, 0.688229736113923, 0.685348278622898, 0.680862831858407, 0.669226393629124, 0.652805187482379, 0.628563234872383, 0.591351744186047, 0.547857540345019, 0.497542134831461, 0.441916678515569, 0.394319682959049, 0.359409594095941, 0.333799440671195, 0.316655976053025, 0.308479857556199, 0.297574626865672, 0.290041192149261, 0.284789644012945, 0.282097649186257, 0.279881815739995, 0.277514628030092, 0.278085789320105, 0.277743902439024, 0.278416347381865, 0.276659959758551, 0.275593340417995, 0.274115456238361, 0.268757443429933, 0.26864406779661, 0.265753424657534, 0.267935578330893, 0.263724434876211, 0.260529482551143, 0.255548083389375, 0.258409785932722, 0.266193433895297, 0.266597510373444, 0.279357231149567, 0.276595744680851, 0.26978417266187, 0.285097192224622, 0.272, 0.271428571428571, 0.262376237623762, 0.252100840336134, 0.3, 0.0/0.0], } end it 'finds the minimum of the plateu region of a stringency plot' do #data = [10,11,12,10,9,8,7,6,5,4.5,4,3.4, 3.2, 3.3, 3.1, 3.0,2.9,2.8,2.8, 2.8, 2.9, 3.4, 2.2, 1.1,0.0,0.0/0.0] #data = [10,11,12,10,9,8,7,6,5,4.5,4,3.4, 3.2, 3.3, 3.1, 3.0,2.9,2.8,2.8, 2.8, 2.9, 3.4, 2.2, 1.1,0.0] @data.each do |k,v| exp = @expected[k] bkg = Validator::Background.new(v) start_i = 25 stop_i = 38 ans = bkg.min_mesa(start_i, stop_i) ans.should be_close(v[exp], 0.01) # expecting were my best judgement (erring on the min side) end end # This is where I'd like to go finding the plateau region! #it 'finds the minimum of the plateu region of a stringency plot' do # @data.each do |k,v| # exp = @expected[k] # bkg = Validator::Background.new(v) # ans = bkg.quartile_deriv_finder # ans.should be_close(v[exp], 0.01) # # expecting were my best judgement (erring on the min side) # end #end end