How to use testCoverageDetection method in green

Best Python code snippet using green

test_coverage_detection.py

Source:test_coverage_detection.py Github

copy

Full Screen

1import sys2import math3import csv4import os5import unittest6from io import StringIO7sys.path.append(".")8import annogesiclib.coverage_detection as cover_detect9from mock_args_container import MockClass10class Mock_func(object):11 def mock_check_tex(self, template_texs, covers, target_datas, cutoff,12 tex_notex, poss, type_, notex, median,13 coverages, utr_type):14 for srna in Example().cover_datas:15 target_datas.append(srna)16 poss["start"] = 10017 poss["end"] = 20218 return 219class TestCoverageDetection(unittest.TestCase):20 def setUp(self):21 self.example = Example()22 self.mock_args = MockClass()23 def test_coverage_comparison_first(self):24 first = True25 cover_sets = {"high": -1, "low": -1}26 poss = {"high": -1, "low": -1}27 cover = 10028 cover_detect.coverage_comparison(29 cover, cover_sets, poss, first, "+", 50)30 self.assertDictEqual(cover_sets, {"high": 100, "low": 100})31 self.assertDictEqual(poss, {"high": 50, "low": 50})32 33 def test_coverage_comparison_forward(self):34 first = False35 cover_sets = {"high": 50, "low": 20}36 poss = {"high": 10, "low": 30}37 cover = 10038 cover_detect.coverage_comparison(39 cover, cover_sets, poss, first, "+", 50)40 self.assertDictEqual(cover_sets, {"high": 100, "low": 100})41 self.assertDictEqual(poss, {"high": 50, "low": 50})42 cover = 3043 cover_detect.coverage_comparison(44 cover, cover_sets, poss, first, "+", 51)45 self.assertDictEqual(cover_sets, {"high": 100, "low": 30})46 self.assertDictEqual(poss, {"high": 50, "low": 51})47 def test_coverage_comparison_reverse(self):48 first = False49 cover_sets = {"high": 50, "low": 20}50 poss = {"high": 30, "low": 10}51 cover = 10052 cover_detect.coverage_comparison(53 cover, cover_sets, poss, first, "-", 50)54 self.assertDictEqual(cover_sets, {"high": 100, "low": 100})55 self.assertDictEqual(poss, {"high": 50, "low": 50})56 cover = 3057 cover_detect.coverage_comparison(58 cover, cover_sets, poss, first, "-", 49)59 self.assertDictEqual(cover_sets, {"high": 100, "low": 30})60 self.assertDictEqual(poss, {"high": 50, "low": 49})61 def test_define_cutoff_median(self):62 coverages = {"3utr": "mean", "5utr": "median"}63 median = {"track_a": {"median": 100, "mean": 200},64 "track_b": {"median": 30, "mean": 80}}65 cutoff = cover_detect.define_cutoff(coverages, median, "5utr")66 self.assertDictEqual(cutoff, {'track_a': 100, 'track_b': 30})67 cutoff = cover_detect.define_cutoff(coverages, median, "3utr")68 self.assertDictEqual(cutoff, {'track_a': 200, 'track_b': 80})69 def test_check_tex(self):70 template_texs = self.example.texs71 covers = self.example.cover_datas72 coverages = {"3utr": 100, "5utr": 600}73 poss = {"high": 30, "low": 10}74 median = {"track1_tex": {"median": 100, "mean": 200},75 "track1_notex": {"median": 30, "mean": 80},76 "track2_tex": {"median": 150, "mean": 200},77 "track2_notex": {"median": 10, "mean": 20},78 "frag": {"median": 80, "mean": 100}}79 target_datas = []80 texs = {"track1_tex@AND@track1_notex": 0,81 "track2_tex@AND@track2_notex": 0}82 detect_num_lib = cover_detect.check_tex(83 template_texs, covers, target_datas, 20, None, poss, median,84 coverages, "3utr", 200, 2)85 self.assertEqual(detect_num_lib, 2)86 num_frag = 087 num_tex = 088 for target in target_datas:89 if target["type"] == "frag":90 num_frag += 191 else:92 num_tex += 193 self.assertEqual(num_frag, 1)94 self.assertEqual(num_tex, 2)95 detect_num_lib = cover_detect.check_tex(96 template_texs, covers, target_datas, 20, "sRNA_utr_derived",97 poss, median, coverages, "5utr", 200, 2)98 self.assertEqual(detect_num_lib, 2)99 self.assertDictEqual(poss, {100 'start': 100, 'high': 30, 'end': 202, 'low': 10})101 def test_replicate_comparison(self):102 cover_detect.check_tex = Mock_func().mock_check_tex103 template_texs = self.example.texs104 srna_covers = {"texnotex": self.example.cover_datas}105 coverages = {"3utr": 100, "5utr": 600}106 median = {"track1_tex": {"median": 100, "mean": 200},107 "track1_notex": {"median": 30, "mean": 80},108 "track2_tex": {"median": 150, "mean": 200},109 "track2_notex": {"median": 10, "mean": 20},110 "frag": {"median": 80, "mean": 100}}111 texs = {"track1_tex@AND@track1_notex": 0,112 "track2_tex@AND@track2_notex": 0}113 args = self.mock_args.mock()114 args.replicates = {"tex": ["all_2"], "frag": ["all_1"]}115 args.tex_notex = 2116 srna_datas = cover_detect.replicate_comparison(args, srna_covers, "+",117 "sRNA_utr_derived", median,118 coverages, "3utr", 100, 200, template_texs)119 self.assertEqual(srna_datas["best"], 500)120 self.assertEqual(srna_datas["track"], "frag")121 self.assertEqual(srna_datas["high"], 700)122 self.assertEqual(srna_datas["low"], 400)123 self.assertEqual(srna_datas["start"], 100)124 self.assertEqual(srna_datas["end"], 202)125class Example(object):126 cover_datas = [127 {"avg": 300, "type": "tex", "track": "track1_tex",128 "final_start": 100, "final_end": 200, "high": 500, "low": 100},129 {"avg": 300, "type": "notex", "track": "track1_notex",130 "final_start": 100, "final_end": 200, "high": 500, "low": 100},131 {"avg": 10, "type": "tex", "track": "track2_tex",132 "final_start": 101, "final_end": 200, "high": 50, "low": 0},133 {"avg": 10, "type": "notex", "track": "track2_notex",134 "final_start": 101, "final_end": 200, "high": 50, "low": 0},135 {"avg": 500, "type": "frag", "track": "frag",136 "final_start": 100, "final_end": 202, "high": 700, "low": 400}]137 texs = {"track1_tex_track1_notex": 0,138 "track2_tex_track2_notex": 0}139 cutoff = {"track1_tex": 200, "track1_notex": 200,140 "track2_tex": 200, "track2_notex": 200,141 "frag": 200}142if __name__ == "__main__":...

Full Screen

Full Screen

test_output.py

Source:test_output.py Github

copy

Full Screen

...150 gs = GreenStream(s)151 gs.write = MagicMock()152 gs.writelines(["one", "two", "three"])153 self.assertEqual(len(gs.write.mock_calls), 3)154 def testCoverageDetection(self):155 """156 write() detects a coverage percentage flying by157 """158 s = StringIO()159 gs = GreenStream(s)160 gs.write(161 "\n---------------------------------------------------\nTOTAL 896 367 59%\nRan"162 )163 self.assertEqual(gs.coverage_percent, 59)164 def testEncodingMirrors(self):165 """166 The encoding of a stream gets mirrored through167 """168 s = StringIO()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful