How to use context_aware method in autotest

Best Python code snippet using autotest_python

lv_utils.py

Source:lv_utils.py Github

copy

Full Screen

1"""2Utility for taking shapshots from existing logical volumes3or creates such.4:author: Plamen Dimitrov5:copyright: Intra2net AG 20126:license: GPL v27:param vg_name: Name of the volume group.8:param lv_name: Name of the logical volume.9:param lv_size: Size of the logical volume as string in the form "#G"10 (for example 30G).11:param lv_snapshot_name: Name of the snapshot with origin the logical12 volume.13:param lv_snapshot_size: Size of the snapshot with origin the logical14 volume also as "#G".15:param ramdisk_vg_size: Size of the ramdisk virtual group.16:param ramdisk_basedir: Base directory for the ramdisk sparse file.17:param ramdisk_sparse_filename: Name of the ramdisk sparse file.18Sample ramdisk params:19- ramdisk_vg_size = "40000"20- ramdisk_basedir = "/tmp"21- ramdisk_sparse_filename = "virtual_hdd"22Sample general params:23- vg_name='autotest_vg',24- lv_name='autotest_lv',25- lv_size='1G',26- lv_snapshot_name='autotest_sn',27- lv_snapshot_size='1G'28The ramdisk volume group size is in MB.29"""30import logging31import os32import re33import shutil34import time35from autotest.client import utils36from autotest.client.shared import error37@error.context_aware38def vg_ramdisk(vg_name, ramdisk_vg_size,39 ramdisk_basedir, ramdisk_sparse_filename,40 use_tmpfs=True):41 """42 Create vg on top of ram memory to speed up lv performance.43 """44 error.context("Creating virtual group on top of ram memory",45 logging.info)46 vg_size = ramdisk_vg_size47 vg_ramdisk_dir = os.path.join(ramdisk_basedir, vg_name)48 ramdisk_filename = os.path.join(vg_ramdisk_dir,49 ramdisk_sparse_filename)50 vg_ramdisk_cleanup(ramdisk_filename, vg_ramdisk_dir,51 vg_name, use_tmpfs)52 result = ""53 if not os.path.exists(vg_ramdisk_dir):54 os.makedirs(vg_ramdisk_dir)55 try:56 if use_tmpfs:57 logging.info("Mounting tmpfs")58 result = utils.run("mount -t tmpfs tmpfs %s" % vg_ramdisk_dir)59 logging.info("Converting and copying /dev/zero")60 cmd = ("dd if=/dev/zero of=%s bs=1M count=1 seek=%s" %61 (ramdisk_filename, vg_size))62 result = utils.run(cmd, verbose=True)63 logging.info("Finding free loop device")64 result = utils.run("losetup --find", verbose=True)65 except error.CmdError as ex:66 logging.error(ex)67 vg_ramdisk_cleanup(ramdisk_filename, vg_ramdisk_dir,68 vg_name, use_tmpfs)69 raise ex70 loop_device = result.stdout.rstrip()71 try:72 logging.info("Creating loop device")73 result = utils.run("losetup %s %s" % (loop_device, ramdisk_filename))74 logging.info("Creating physical volume %s", loop_device)75 result = utils.run("pvcreate %s" % loop_device)76 logging.info("Creating volume group %s", vg_name)77 result = utils.run("vgcreate %s %s" % (vg_name, loop_device))78 except error.CmdError as ex:79 logging.error(ex)80 vg_ramdisk_cleanup(ramdisk_filename, vg_ramdisk_dir,81 vg_name, loop_device, use_tmpfs)82 raise ex83 logging.info(result.stdout.rstrip())84@error.context_aware85def lv_ramdisk(vg_name, pool_name, pool_size):86 error.context("Creating thin pool for thinly provisioned volumes",87 logging.info)88 if not vg_check(vg_name):89 raise error.TestError("Volume group could not be found")90 if lv_check(vg_name, pool_name):91 raise error.TestError("Thin pool already exists")92 cmd = "lvcreate -L %s --thin %s/%s" % (pool_size, vg_name, pool_name)93 result = utils.run(cmd)94 logging.info(result.stdout.rstrip())95def vg_ramdisk_cleanup(ramdisk_filename=None, vg_ramdisk_dir=None,96 vg_name=None, loop_device=None, use_tmpfs=True):97 """98 Inline cleanup function in case of test error.99 """100 if vg_name is not None:101 loop_device = re.search("([/\w]+) %s lvm2" % vg_name,102 utils.run("pvs").stdout)103 if loop_device is not None:104 loop_device = loop_device.group(1)105 result = utils.run("vgremove -f %s" % vg_name, ignore_status=True)106 if result.exit_status == 0:107 logging.info(result.stdout.rstrip())108 else:109 logging.debug("%s -> %s", result.command, result.stderr)110 if loop_device is not None:111 result = utils.run("pvremove -f %s" % loop_device, ignore_status=True)112 if result.exit_status == 0:113 logging.info(result.stdout.rstrip())114 else:115 logging.debug("%s -> %s", result.command, result.stderr)116 if loop_device in utils.run("losetup --all").stdout:117 ramdisk_filename = re.search("%s: \[\d+\]:\d+ \(([/\w]+)\)" % loop_device,118 utils.run("losetup --all").stdout)119 if ramdisk_filename is not None:120 ramdisk_filename = ramdisk_filename.group(1)121 for _ in range(10):122 time.sleep(0.1)123 result = utils.run("losetup -d %s" % loop_device, ignore_status=True)124 if "resource busy" not in result.stderr:125 if result.exit_status == 0:126 logging.info("Loop device %s deleted", loop_device)127 else:128 logging.debug("%s -> %s", result.command, result.stderr)129 break130 if ramdisk_filename is not None:131 if os.path.exists(ramdisk_filename):132 os.unlink(ramdisk_filename)133 logging.info("Ramdisk filename %s deleted", ramdisk_filename)134 vg_ramdisk_dir = os.path.dirname(ramdisk_filename)135 if vg_ramdisk_dir is not None:136 if use_tmpfs:137 utils.run("umount %s" % vg_ramdisk_dir, ignore_status=True)138 if result.exit_status == 0:139 logging.info("Successfully unmounted tmpfs from %s", vg_ramdisk_dir)140 else:141 logging.debug("%s -> %s", result.command, result.stderr)142 if os.path.exists(vg_ramdisk_dir):143 try:144 shutil.rmtree(vg_ramdisk_dir)145 logging.info("Ramdisk directory %s deleted", vg_ramdisk_dir)146 except OSError:147 pass148def vg_check(vg_name):149 """150 Check whether provided volume group exists.151 """152 cmd = "vgdisplay %s" % vg_name153 try:154 utils.run(cmd)155 logging.debug("Provided volume group exists: %s", vg_name)156 return True157 except error.CmdError:158 return False159def vg_list():160 """161 List available volume groups.162 """163 cmd = "vgs --all"164 vgroups = {}165 result = utils.run(cmd)166 lines = result.stdout.strip().splitlines()167 if len(lines) > 1:168 columns = lines[0].split()169 lines = lines[1:]170 else:171 return vgroups172 for line in lines:173 details = line.split()174 details_dict = {}175 index = 0176 for column in columns:177 if re.search("VG", column):178 vg_name = details[index]179 else:180 details_dict[column] = details[index]181 index += 1182 vgroups[vg_name] = details_dict183 return vgroups184@error.context_aware185def vg_create(vg_name, pv_list, force=False):186 """187 Create a volume group by using the block special devices188 """189 error.context(190 "Creating volume group '%s' by using '%s'" %191 (vg_name, pv_list), logging.info)192 if vg_check(vg_name):193 raise error.TestError("Volume group '%s' already exist" % vg_name)194 if force:195 cmd = "vgcreate -f"196 else:197 cmd = "vgcreate"198 cmd += " %s %s" % (vg_name, pv_list)199 result = utils.run(cmd)200 logging.info(result.stdout.rstrip())201@error.context_aware202def vg_remove(vg_name):203 """204 Remove a volume group.205 """206 error.context("Removing volume '%s'" % vg_name, logging.info)207 if not vg_check(vg_name):208 raise error.TestError("Volume group '%s' could not be found" % vg_name)209 cmd = "vgremove -f %s" % vg_name210 result = utils.run(cmd)211 logging.info(result.stdout.rstrip())212def lv_list(vg_name):213 cmd = "lvs %s" % vg_name214 result = utils.run(cmd)215 logging.debug("Logical volumes in %s:\n%s", vg_name, result)216 lvpattern = r"(\w+)\s+%s" % vg_name217 return re.findall(lvpattern, result.stdout.rstrip())218def lv_check(vg_name, lv_name):219 """220 Check whether provided logical volume exists.221 """222 cmd = "lvdisplay %s" % vg_name223 result = utils.run(cmd, ignore_status=True)224 # unstable approach but currently works225 lvpattern = r"LV Name\s+%s\s+" % lv_name226 match = re.search(lvpattern, result.stdout.rstrip())227 if match:228 logging.debug("Provided logical volume %s exists in %s", lv_name, vg_name)229 return True230 else:231 return False232@error.context_aware233def lv_remove(vg_name, lv_name):234 """235 Remove a logical volume.236 """237 error.context("Removing volume /dev/%s/%s" %238 (vg_name, lv_name), logging.debug)239 if not vg_check(vg_name):240 raise error.TestError("Volume group could not be found")241 if not lv_check(vg_name, lv_name):242 raise error.TestError("Logical volume could not be found")243 cmd = "lvremove -f %s/%s" % (vg_name, lv_name)244 result = utils.run(cmd)245 logging.info(result.stdout.rstrip())246@error.context_aware247def lv_create(vg_name, lv_name, lv_size):248 """249 Create a logical volume in a volume group.250 The volume group must already exist.251 """252 error.context("Creating original lv to take a snapshot from",253 logging.debug)254 if not vg_check(vg_name):255 raise error.TestError("Volume group could not be found")256 if lv_check(vg_name, lv_name):257 raise error.TestError("Logical volume already exists")258 cmd = "lvcreate --size %s --name %s %s" % (lv_size, lv_name, vg_name)259 result = utils.run(cmd)260 logging.info(result.stdout.rstrip())261def lv_list_all():262 """263 List available group volumes.264 """265 cmd = "lvs --all"266 volumes = {}267 result = utils.run(cmd)268 lines = result.stdout.strip().splitlines()269 if len(lines) > 1:270 columns = lines[0].split()271 lines = lines[1:]272 else:273 return volumes274 for line in lines:275 details = line.split()276 length = len(details)277 details_dict = {}278 lv_name = details[0]279 details_dict["VG"] = details[1]280 details_dict["Attr"] = details[2]281 details_dict["LSize"] = details[3]282 if length == 5:283 details_dict["Origin_Data"] = details[4]284 elif length > 5:285 details_dict["Origin_Data"] = details[5]286 details_dict["Pool"] = details[4]287 volumes[lv_name] = details_dict288 return volumes289def thin_lv_create(vg_name, thinpool_name="lvthinpool", thinpool_size="1.5G",290 thinlv_name="lvthin", thinlv_size="1G"):291 """292 Create a thin volume from given volume group.293 :param vg_name: An exist volume group294 :param thinpool_name: The name of thin pool295 :param thinpool_size: The size of thin pool to be created296 :param thinlv_name: The name of thin volume297 :param thinlv_size: The size of thin volume298 """299 tp_cmd = "lvcreate --thinpool %s --size %s %s" % (thinpool_name,300 thinpool_size,301 vg_name)302 try:303 utils.run(tp_cmd)304 except error.CmdError as detail:305 logging.debug(detail)306 raise error.TestError("Create thin volume pool failed.")307 logging.debug("Created thin volume pool: %s", thinpool_name)308 lv_cmd = ("lvcreate --name %s --virtualsize %s "309 "--thin %s/%s" % (thinlv_name, thinlv_size,310 vg_name, thinpool_name))311 try:312 utils.run(lv_cmd)313 except error.CmdError as detail:314 logging.debug(detail)315 raise error.TestError("Create thin volume failed.")316 logging.debug("Created thin volume:%s", thinlv_name)317 return (thinpool_name, thinlv_name)318@error.context_aware319def lv_create_thin(vg_name, pool_name, lv_name, lv_size):320 """321 Create a thinly provisioned logical volume in a volume group.322 The volume group must already exist.323 """324 error.context("Creating original thin lv to take a snapshot from",325 logging.debug)326 if not vg_check(vg_name):327 raise error.TestError("The volume group could not be found")328 if not lv_check(vg_name, pool_name):329 raise error.TestError("The thin pool could not be found")330 if lv_check(vg_name, lv_name):331 raise error.TestError("The logical volume already exists")332 cmd = "lvcreate --virtualsize %s --thin %s/%s --name %s" % (lv_size, vg_name,333 pool_name, lv_name)334 result = utils.run(cmd)335 logging.info(result.stdout.rstrip())336@error.context_aware337def lv_take_snapshot(vg_name, lv_name,338 lv_snapshot_name, lv_snapshot_size):339 """340 Take a snapshot of the original logical volume.341 """342 error.context("Taking a snapshot from original logical volume",343 logging.debug)344 if not vg_check(vg_name):345 raise error.TestError("Volume group could not be found")346 if lv_check(vg_name, lv_snapshot_name):347 raise error.TestError("Snapshot already exists")348 if not lv_check(vg_name, lv_name):349 raise error.TestError("Snapshot's origin could not be found")350 cmd = ("lvcreate -s --name %s /dev/%s/%s --size %s" %351 (lv_snapshot_name, vg_name, lv_name, lv_snapshot_size))352 try:353 result = utils.run(cmd)354 except error.CmdError as ex:355 if ('Logical volume "%s" already exists in volume group "%s"' %356 (lv_snapshot_name, vg_name) in ex.result_obj.stderr and357 re.search(re.escape(lv_snapshot_name + " [active]"),358 utils.run("lvdisplay").stdout)):359 # the above conditions detect if merge of snapshot was postponed360 logging.warning(("Logical volume %s is still active! " +361 "Attempting to deactivate..."), lv_name)362 lv_reactivate(vg_name, lv_name)363 result = utils.run(cmd)364 else:365 raise ex366 logging.info(result.stdout.rstrip())367@error.context_aware368def lv_take_thin_snapshot(vg_name, lv_name, lv_snapshot_name):369 """370 Take a thinly provisioned snapshot of a thin logical volume.371 """372 error.context("Taking a thin snapshot from a thin logical volume",373 logging.debug)374 if not vg_check(vg_name):375 raise error.TestError("Volume group could not be found")376 if lv_check(vg_name, lv_snapshot_name):377 raise error.TestError("Snapshot already exists")378 if not lv_check(vg_name, lv_name):379 raise error.TestError("Snapshot's origin could not be found")380 cmd = ("lvcreate -s --name %s /dev/%s/%s --ignoreactivationskip" %381 (lv_snapshot_name, vg_name, lv_name))382 # lvcreate -s --thinpool vg001/pool origin_volume --name mythinsnap383 result = utils.run(cmd)384 logging.info(result.stdout.rstrip())385@error.context_aware386def lv_take_thin_snapshot_from_external(vg_name, pool_name, lv_name, lv_snapshot_name):387 """388 Take a thinly provisioned snapshot of external logical volume.389 """390 error.context("Taking a thin snapshot from an external logical volume",391 logging.debug)392 if not vg_check(vg_name):393 raise error.TestError("Volume group could not be found")394 if not lv_check(vg_name, pool_name):395 raise error.TestError("Snapshot's thin pool could not be found")396 if lv_check(vg_name, lv_snapshot_name):397 raise error.TestError("Snapshot already exists")398 if not lv_check(vg_name, lv_name):399 raise error.TestError("Snapshot's origin could not be found")400 cmd = ("lvcreate -s --thinpool %s/%s %s --name %s --ignoreactivationskip" %401 (vg_name, pool_name, lv_name, lv_snapshot_name))402 result = utils.run(cmd)403 logging.info(result.stdout.rstrip())404@error.context_aware405def lv_revert(vg_name, lv_name, lv_snapshot_name):406 """407 Revert the origin to a snapshot.408 """409 error.context("Reverting original logical volume to snapshot",410 logging.debug)411 try:412 if not vg_check(vg_name):413 raise error.TestError("Volume group could not be found")414 if not lv_check(vg_name, lv_snapshot_name):415 raise error.TestError("Snapshot could not be found")416 if (not lv_check(vg_name, lv_snapshot_name) and not lv_check(vg_name,417 lv_name)):418 raise error.TestError("Snapshot and its origin could not be found")419 if (lv_check(vg_name, lv_snapshot_name) and not lv_check(vg_name,420 lv_name)):421 raise error.TestError("Snapshot origin could not be found")422 cmd = ("lvconvert --merge --interval 1 /dev/%s/%s" % (vg_name, lv_snapshot_name))423 result = utils.run(cmd)424 if (("Merging of snapshot %s will start next activation." %425 lv_snapshot_name) in result.stdout):426 raise error.TestError("The logical volume %s is still active" %427 lv_name)428 result = result.stdout.rstrip()429 except error.TestError as ex:430 # detect if merge of snapshot was postponed431 # and attempt to reactivate the volume.432 active_lv_pattern = re.escape("%s [active]" % lv_snapshot_name)433 lvdisplay_output = utils.run("lvdisplay").stdout434 if ('Snapshot could not be found' in ex and435 re.search(active_lv_pattern, lvdisplay_output) or436 "The logical volume %s is still active" % lv_name in ex):437 logging.warning(("Logical volume %s is still active! " +438 "Attempting to deactivate..."), lv_name)439 lv_reactivate(vg_name, lv_name)440 result = "Continuing after reactivation"441 elif 'Snapshot could not be found' in ex:442 logging.error(ex)443 result = "Could not revert to snapshot"444 else:445 raise ex446 logging.info(result)447@error.context_aware448def lv_revert_with_snapshot(vg_name, lv_name,449 lv_snapshot_name, lv_snapshot_size):450 """451 Perform logical volume merge with snapshot and take a new snapshot.452 """453 error.context("Reverting to snapshot and taking a new one",454 logging.debug)455 lv_revert(vg_name, lv_name, lv_snapshot_name)456 lv_take_snapshot(vg_name, lv_name, lv_snapshot_name, lv_snapshot_size)457@error.context_aware458def lv_reactivate(vg_name, lv_name, timeout=10):459 """460 In case of unclean shutdowns some of the lvs is still active and merging461 is postponed. Use this function to attempt to deactivate and reactivate462 all of them to cause the merge to happen.463 """464 try:465 utils.run("lvchange -an /dev/%s/%s" % (vg_name, lv_name))466 time.sleep(timeout)467 utils.run("lvchange -ay /dev/%s/%s" % (vg_name, lv_name))468 time.sleep(timeout)469 except error.CmdError:470 logging.error(("Failed to reactivate %s - please, " +471 "nuke the process that uses it first."), lv_name)472 raise error.TestError("The logical volume %s is still active" % lv_name)473@error.context_aware474def lv_mount(vg_name, lv_name, mount_loc, create_filesystem=""):475 """476 Mount a logical volume to a mount location.477 The create_filesystem can be one of ext2, ext3, ext4, vfat or empty478 if the filesystem was already created and the mkfs process is skipped.479 """480 error.context("Mounting the logical volume",481 logging.debug)482 try:483 if create_filesystem:484 result = utils.run("mkfs.%s /dev/%s/%s" % (create_filesystem,485 vg_name, lv_name))486 logging.debug(result.stdout.rstrip())487 result = utils.run("mount /dev/%s/%s %s" % (vg_name, lv_name, mount_loc))488 except error.CmdError as ex:489 logging.warning(ex)490 return False491 return True492@error.context_aware493def lv_umount(vg_name, lv_name, mount_loc):494 """495 Unmount a logical volume from a mount location.496 """497 error.context("Unmounting the logical volume",498 logging.debug)499 try:500 utils.run("umount /dev/%s/%s" % (vg_name, lv_name))501 except error.CmdError as ex:502 logging.warning(ex)503 return False...

Full Screen

Full Screen

api.py

Source:api.py Github

copy

Full Screen

1################################################################2#api.py 15.02.09 -> 15.07.28 -> 19.07.16 Initiating PLAN:B3#scripted in python 3.4.24#5#Description : ver max6#7#8#cmd : python api.py -i [input] -c [context] -o [output]9################################################################10#input11#string1\n12#string2\n13#string3\n14#context15#string16#output17#string18#CHECKING OPTIONS19#checking whether input are correctly given20def Check_Options(input_file, context_aware, output_file):21 if input_file != None:22 print ('[Notice] Reading Input file')23 caff_gene_results = Text_to_List(input_file)24 if input_file == None:25 print ('[Error] Input file not given')26 print ('[Error] terminating program')27 quit()28 if context_aware == None:29 print ('[Notice] Context : No special interest')30 if context_aware != None:31 print ('[Notice] Context : ' + str(context_aware))32 context_aware = [str(context_aware)]33 34 if output_file == None:35 output_file = 'Triple_filter.final.result'36 return caff_gene_results, context_aware, output_file37#Without context consideraton 38def Boss_to_Dict(caff_gene_results, ko_gene):39 result_dict = {}40 print ('[Notice] Proceeding BEST')41 42 43 for gene in caff_gene_filter_results:44 query = [gene]45 bossQuery = boss.BOSSQuery({"keywordA":[ko_gene], "keywordB":query, "filterObjectName":"","topN":1})46 relevantEntities = boss.getRelevantBioEntities(bossQuery)47 try : 48 result_dict[gene] = relevantEntities['genes'][0]['score']49 except KeyError: 50 print ("[Notice] BEST cannot find " +str(gene) + ". It will be excluded from candidates.")51 #print (relevantEntities['genes'][0]['score']) #indicates rank. and dict inside dict52 return result_dict53 54#With context consideraton 55def Boss_to_Dict_with_Context(context, caff_gene_filter_results):56 result_dict = {}57 print ('[Notice] Proceeding BEST')58 59 for gene in caff_gene_filter_results:60 query = [gene]61 bossQuery = boss.BOSSQuery({"keywordA":context, "keywordB":query, "filterObjectName":"", "topN":1})62# bossQuery = boss.BOSSQuery({"keywordA":["cancer"], "keywordB":["BRCA1", "EGFR"], "topN":1})63 relevantEntities = boss.getRelevantBioEntities(bossQuery)64 try : 65 result_dict[gene] = relevantEntities['genes'][0]['score']66 except KeyError: 67 print ("[Notice] BEST cannot find " +str(gene) + ". It will be excluded from candidates.")68 #print (relevantEntities['genes'][0]['score']) #indicates rank. and dict inside dict69 return result_dict70 71#Text file should have a format of 1 column72#ex) gene1\ngene2\ngene3\ngene473def Text_to_List(input_file):74 list = []75 open_input_file = open(input_file,'r')76 input_file_readlines = open_input_file.readlines()77 78 for i in range(len(input_file_readlines)):79 read = input_file_readlines[i]80 read = read.replace('\n','')81 82 #check whether there are any duplicate genes83 if read in list:84 print ("[WARNING] Duplicate genes in Input file's entry. Caution is required")85 print ("[WARNING] Checking the whole process is adviced")86 if read not in list:87 list.append(read)88 return list89 90#Result making 91def Result_Making(output_file, sorted_result_dict, result_dict):92 result_text = open(str(output_file),'w')93 result_text.write('RANK\tGENE\tSCORE\n')94 for i in range(len(sorted_result_dict)):95 gene = sorted_result_dict[i][0]96 print (gene)97 score = result_dict[gene]98 result_text.write(str(i) + '\t' + str(gene) + '\t' + str(score) +'\n')99 100if __name__ == '__main__':101 import sys102 import argparse103 import subprocess104 import os105 #importing Korea univ. boss system106 program_dir = os.path.split(os.path.realpath(__file__))107 api_lib_path = os.path.abspath(str(program_dir[0])+'/BEST/dmis')108 sys.path.insert(0, str(api_lib_path))109# import boss110 import best111 parser = argparse.ArgumentParser()112 parser.add_argument('-i','--input', dest = 'input_file', help='List of genes resulted from "Triple_filter.py"')113 parser.add_argument('-c','--context', dest = 'context_aware', help='Context that you are interested"')114 parser.add_argument('-ko','--knockout', dest = 'knockout_gene', help='Knockout gene symbol"')115 parser.add_argument('-o','--output', dest = 'output_file', help='Define output file name')116 args= parser.parse_args()117 input_file = args.input_file118 output_file = args.output_file119 context_aware = args.context_aware120 ko_gene = args.knockout_gene121 print ('------------------------------------')122 print (': :: CAFF-GENE & BEST :: :')123 print (': :')124 print (': >> Result calling << :')125 print (': :')126 print (': 1.0.0 :')127 print ('------------------------------------')128 if ko_gene == None:129 print ("Please give KO gene symbol")130 quit()131 if context_aware == None:132 context_aware = 'null'133 print ('null')134 if '_' in context_aware:135 context_aware = context_aware.replace('_',' ')136 context_aware = '"' + str(context_aware) + '"'137 caff_gene_filter_results, context_aware, output_file = Check_Options(input_file, context_aware, output_file)138 result_dict = Boss_to_Dict(caff_gene_filter_results, ko_gene)139 if context_aware[0] != 'null':140 result_context_dict = Boss_to_Dict_with_Context(context_aware, caff_gene_filter_results)141 gene_list = []142 for gene in result_context_dict.keys():143 gene_list.append(gene)144 for gene in result_dict.keys():145 gene_list.append(gene)146 print ('Total genes', len(gene_list))147 uniq_gene_list = list(set(gene_list))148 print ('uniq genes', len(uniq_gene_list))149 final_dict = {}150 for gene in uniq_gene_list:151 if gene in result_context_dict.keys() and gene in result_dict.keys():152 153 if float(result_context_dict[gene]) >= float(result_dict[gene]):154 155 final_dict[gene] = result_context_dict[gene]156 print ('both',gene, result_dict[gene],result_context_dict[gene])157 if float(result_context_dict[gene]) <= float(result_dict[gene]):158 final_dict[gene] = result_dict[gene]159 print ('both',gene, result_context_dict[gene])160 if gene in result_context_dict.keys() and gene not in result_dict.keys():161 final_dict[gene] = result_context_dict[gene]162 print ('context',gene, result_context_dict[gene])163 if gene not in result_context_dict.keys() and gene in result_dict.keys():164 final_dict[gene] = result_dict[gene]165 print ('ko',gene, result_dict[gene])166 print ('Total KEY size : ',len(final_dict.keys()))167 168 sorted_final_dict = sorted(final_dict.items(), key=lambda x: x[1], reverse=True)169 Result_Making(str(output_file) +'.context', sorted_final_dict, final_dict)170 else:171 sorted_result_dict = sorted(result_dict.items(), key=lambda x: x[1], reverse=True)172 Result_Making(str(output_file)+'.noncontext', sorted_result_dict, result_dict)173 ...

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 autotest 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