Best Python code snippet using tempest_python
refrna_copy_delete.py
Source:refrna_copy_delete.py
1# -*- coding: utf-8 -*-2from biocluster.config import Config3from biocluster.api.database.base import Base4from pymongo import MongoClient5class RefrnaCopyDelete(Base):6 def __init__(self):7 super(RefrnaCopyDelete, self).__init__()8 self._project_type = 'ref_rna'9 def remove_collection(self, task_id, main_coll, detatil_coll=[], change_option=''):10 """11 å é¤ä¸»è¡¨å对åºç详ç»è¡¨12 task_id:task_idï¼detatil_coll:主表对åºç详ç»è¡¨, change_option:详ç»è¡¨ä¸ä¸»è¡¨å段13 """14 results = self.db[main_coll].find({"task_id": task_id})15 if results:16 for result in results:17 main_id = result["_id"]18 for coll in detatil_coll:19 items = self.db[coll].remove({change_option: main_id})20 print "æåå é¤task_id为{}çç»è表{}".format(task_id, coll)21 self.db[main_coll].remove({"_id": result["_id"]})22 print "æåå é¤task_id为{}ç主表{}".format(task_id, main_coll)23 else:24 print "没ææ¾å°task_id为{}ç主表{}".format(task_id, main_coll)25 def remove(self, task_id):26 self.remove_collection(task_id=task_id, main_coll="sg_task", detatil_coll=[], change_option="")27 self.remove_collection(task_id=task_id, main_coll="sg_specimen", detatil_coll=[], change_option="")28 self.remove_collection(task_id=task_id, main_coll="sg_specimen_graphic", detatil_coll=[], change_option="")29 self.remove_collection(task_id=task_id, main_coll="sg_specimen_group", detatil_coll=[], change_option="")30 self.remove_collection(task_id=task_id, main_coll="sg_specimen_group_compare", detatil_coll=[], change_option="")31 self.remove_collection(task_id=task_id, main_coll="sg_specimen_info", detatil_coll=[], change_option="")32 self.remove_collection(task_id=task_id, main_coll="sg_specimen_mapping", detatil_coll=[], change_option="")33 self.remove_collection(task_id=task_id, main_coll="sg_annotation_stat", detatil_coll=["sg_annotation_stat_detail"], change_option="stat_id")34 self.remove_collection(task_id=task_id, main_coll="sg_express", detatil_coll=["sg_express_detail", "sg_express_gragh", "sg_express_box"], change_option="express_id")35 self.remove_collection(task_id=task_id, main_coll="sg_geneset", detatil_coll=["sg_geneset_detail"], change_option="geneset_id")36 self.remove_collection(task_id=task_id, main_coll="sg_software_para", detatil_coll=[], change_option="")37 self.remove_collection(task_id=task_id, main_coll="sg_annotation_blast", detatil_coll=["sg_annotation_blast_detail"], change_option="blast_id")38 self.remove_collection(task_id=task_id, main_coll="sg_annotation_nr", detatil_coll=["sg_annotation_nr_pie"], change_option="nr_id")39 self.remove_collection(task_id=task_id, main_coll="sg_annotation_swissprot", detatil_coll=["sg_annotation_swissprot_pie"], change_option="swissprot_id")40 self.remove_collection(task_id=task_id, main_coll="sg_annotation_pfam", detatil_coll=["sg_annotation_pfam_bar", "sg_annotation_pfam_detail"], change_option="pfam_id")41 self.remove_collection(task_id=task_id, main_coll="sg_annotation_cog", detatil_coll=["sg_annotation_cog_detail"], change_option="cog_id")42 self.remove_collection(task_id=task_id, main_coll="sg_annotation_go", detatil_coll=["sg_annotation_go_detail", "sg_annotation_go_graph", "sg_annotation_go_level", "sg_annotation_go_list"], change_option="go_id")43 self.remove_collection(task_id=task_id, main_coll="sg_annotation_kegg", detatil_coll=["sg_annotation_kegg_categories", "sg_annotation_kegg_level", "sg_annotation_kegg_table"], change_option="kegg_id")44 self.remove_collection(task_id=task_id, main_coll="sg_annotation_query", detatil_coll=["sg_annotation_query_detail"], change_option="query_id")45 self.remove_collection(task_id=task_id, main_coll="sg_assessment_chrom_distribution", detatil_coll=["sg_assessment_chrom_distribution_detail"], change_option="chrom_distribution_id")46 self.remove_collection(task_id=task_id, main_coll="sg_assessment_coverage", detatil_coll=["sg_assessment_coverage_detail"], change_option="coverage_id")47 self.remove_collection(task_id=task_id, main_coll="sg_assessment_distribution", detatil_coll=["sg_assessment_distribution_detail"], change_option="distribution_id")48 self.remove_collection(task_id=task_id, main_coll="sg_assessment_duplicate", detatil_coll=["sg_assessment_duplicate_detail"], change_option="dup_id")49 self.remove_collection(task_id=task_id, main_coll="sg_assessment_saturation", detatil_coll=["sg_assessment_saturation_curve"], change_option="saturation_id")50 self.remove_collection(task_id=task_id, main_coll="sg_express_diff", detatil_coll=["sg_express_diff_detail", "sg_express_diff_summary"], change_option="express_diff_id")51 self.remove_collection(task_id=task_id, main_coll="sg_express_correlation", detatil_coll=["sg_express_correlation_detail"], change_option="correlation_id")52 self.remove_collection(task_id=task_id, main_coll="sg_express_pca", detatil_coll=["sg_express_pca_rotation"], change_option="pca_id")53 self.remove_collection(task_id=task_id, main_coll="sg_express_venn", detatil_coll=["sg_express_venn_detail", "sg_express_venn_graph"], change_option="venn_id")54 self.remove_collection(task_id=task_id, main_coll="sg_express_class_code", detatil_coll=["sg_express_class_code_detail"], change_option="class_code_id")55 self.remove_collection(task_id=task_id, main_coll="sg_geneset_venn", detatil_coll=["sg_geneset_venn_detail", "sg_geneset_venn_graph"], change_option="venn_id")56 self.remove_collection(task_id=task_id, main_coll="sg_geneset_cluster", detatil_coll=["sg_geneset_cluster_detail"], change_option="cluster_id")57 self.remove_collection(task_id=task_id, main_coll="sg_geneset_cog_class", detatil_coll=["sg_geneset_cog_class_detail"], change_option="geneset_cog_id")58 self.remove_collection(task_id=task_id, main_coll="sg_geneset_go_class", detatil_coll=["sg_geneset_go_class_detail"], change_option="go_regulate_id")59 self.remove_collection(task_id=task_id, main_coll="sg_geneset_go_enrich", detatil_coll=["sg_geneset_go_enrich_detail"], change_option="go_enrich_id")60 self.remove_collection(task_id=task_id, main_coll="sg_geneset_kegg_class", detatil_coll=["sg_geneset_kegg_class_detail", "sg_geneset_kegg_class_pathway"], change_option="kegg_id")61 self.remove_collection(task_id=task_id, main_coll="sg_geneset_kegg_enrich", detatil_coll=["sg_geneset_kegg_enrich_detail"], change_option="kegg_enrich_id")62 self.remove_collection(task_id=task_id, main_coll="sg_ppinetwork", detatil_coll=["sg_ppinetwork_centrality_node", "sg_ppinetwork_distribution_node", "sg_ppinetwork_node_table", "sg_ppinetwork_structure_attributes", "sg_ppinetwork_structure_link", "sg_ppinetwork_structure_node"], change_option="ppi_id")63 self.remove_collection(task_id=task_id, main_coll="sg_snp", detatil_coll=["sg_snp_detail", "sg_snp_stat"], change_option="snp_id")64 self.remove_collection(task_id=task_id, main_coll="sg_species_information", detatil_coll=["sg_species_information_detail"], change_option="species_id")65 self.remove_collection(task_id=task_id, main_coll="sg_splicing_rmats", detatil_coll=["sg_splicing_rmats_detail", "sg_splicing_rmats_graph", "sg_splicing_rmats_psi", "sg_splicing_rmats_stats"], change_option="splicing_id")66 self.remove_collection(task_id=task_id, main_coll="sg_transcripts", detatil_coll=["sg_transcripts_seq_type", "sg_transcripts_step", "sg_transcripts_relations"], change_option="transcripts_id")67 def find_task_id(self, task_id):68 results = self.db["sg_task"].find({"task_id": {"$regex": task_id + "_.*_.*"}})69 if results:70 for result in results:71 target_task_id = result["task_id"]72 self.remove(target_task_id)73 else:74 print "没ææ¾å°ä»¥task_id为{}å¤ä»½çdemo,请æ£æ¥!".format(task_id)75if __name__ == "__main__":76 test = RefrnaCopyDelete()...
delete_demo.py
Source:delete_demo.py
1# -*- coding: utf-8 -*-2from biocluster.config import Config3from pymongo import MongoClient4from biocluster.api.database.base import Base5class DeleteDemo(Base):6 def __init__(self):7 super(DeleteDemo, self).__init__()8 self._project_type = 'metagenomic'9 def remove_collection(self, task_id, main_coll, detail_coll=[], change_option=''):10 """11 å é¤ä¸»è¡¨å对åºç详ç»è¡¨12 task_id:task_idï¼detail_coll:主表对åºç详ç»è¡¨, change_option:详ç»è¡¨ä¸ä¸»è¡¨å段13 """14 results = self.db[main_coll].find({"task_id": task_id})15 if results:16 for result in results:17 main_id = result["_id"]18 for coll in detail_coll:19 try:20 items = self.db[coll].remove({change_option: main_id})21 print "æåå é¤task_id为 {} çç»è表 {}".format(task_id, coll)22 except:23 print "å é¤task_id为 {} çç»è表 {} 失败".format(task_id, coll)24 self.db[main_coll].remove({"_id": result["_id"]})25 print "æåå é¤task_id为 {} ç主表 {}".format(task_id, main_coll)26 else:27 print "没ææ¾å°task_id为 {} ç主表 {}".format(task_id, main_coll)28 def remove(self, task_id):29 self.remove_collection(task_id=task_id, main_coll="sg_task", detail_coll=[], change_option="")30 self.remove_collection(task_id=task_id, main_coll="data_stat", detail_coll=["data_stat_detail"], change_option="data_stat_id")31 self.remove_collection(task_id=task_id, main_coll="specimen_group", detail_coll=[], change_option="")32 self.remove_collection(task_id=task_id, main_coll="specimen_graphic", detail_coll=[], change_option="")33 self.remove_collection(task_id=task_id, main_coll="env", detail_coll=["env_detail"], change_option="env_id")34 self.remove_collection(task_id=task_id, main_coll="assemble_stat", detail_coll=["assemble_stat_bar", "assemble_stat_detail"], change_option="assem_id")35 self.remove_collection(task_id=task_id, main_coll="predict_gene", detail_coll=["predict_gene_bar", "predict_gene_detail"], change_option="predict_gene_id")36 self.remove_collection(task_id=task_id, main_coll="predict_gene_total", detail_coll=[], change_option="")37 self.remove_collection(task_id=task_id, main_coll="geneset", detail_coll=["geneset_bar", "geneset_readsn", "geneset_readsr"], change_option="geneset_id")38 anno_list = ["ardb", "card", "cazy", "cog", "kegg", "nr", "vfdb", "overview"]39 anno_detail = {40 "ardb": ["ardb_arg", "ardb_class", "ardb_type"],41 "card": ["card_aro", "card_class"],42 "cazy": ["cazy_class", "cazy_family"],43 "cog": ["cog_category", "cog_function", "cog_nog"],44 "kegg": ["kegg_enzyme", "kegg_gene", "kegg_module", "kegg_orthology", "kegg_pathway"],45 "nr": ["nr_detail"],46 "vfdb": ["vfdb_pie", "vfdb_vfs"],47 "overview": [],48 }49 for anno in anno_list:50 collection = "anno_" + anno51 position = "" if anno == "overview" else anno + "_id"52 self.remove_collection(task_id=task_id, main_coll=collection, detail_coll=anno_detail[anno], change_option=position)53 self.remove_collection(task_id=task_id, main_coll="hcluster_tree", detail_coll=[], change_option="")54 self.remove_collection(task_id=task_id, main_coll="anosim", detail_coll=["anosim_detail"], change_option="anosim_id")55 self.remove_collection(task_id=task_id, main_coll="beta_diversity", detail_coll=["beta_diversity_detail"], change_option="beta_diversity_id")56 self.remove_collection(task_id=task_id, main_coll="composition", detail_coll=["composition_detail"], change_option="composition_id")57 self.remove_collection(task_id=task_id, main_coll="enterotype", detail_coll=['enterotype_detail','enterotype_detail_cluster'], change_option="enterotype_id")58 self.remove_collection(task_id=task_id, main_coll="env_vif", detail_coll=["env_vif_detail"], change_option="vif_id")59 self.remove_collection(task_id=task_id, main_coll="heatmap_cor", detail_coll=["heatmap_cor_detail"], change_option="heatmap_cor_id")60 self.remove_collection(task_id=task_id, main_coll="lefse", detail_coll=["lefse_detail"], change_option="species_lefse_id")61 self.remove_collection(task_id=task_id, main_coll="mantel_test", detail_coll=['mantel_test_detail'], change_option="mantel_id")62 self.remove_collection(task_id=task_id, main_coll="metastat", detail_coll=['metastat_detail', 'metastat_plot'], change_option="metastat_id")63 self.remove_collection(task_id=task_id, main_coll="network", detail_coll=['network_degree', 'network_link', 'network_node'], change_option="network_id")64 self.remove_collection(task_id=task_id, main_coll="network_cor", detail_coll=['network_cor_degree', 'network_cor_link', 'network_cor_node'], change_option="network_cor_id")65 self.remove_collection(task_id=task_id, main_coll="permanova", detail_coll=["permanova_detail"], change_option="permanova_id")66 self.remove_collection(task_id=task_id, main_coll="regression", detail_coll=["regression_curve", "regression_line"], change_option="regression_id")67 self.remove_collection(task_id=task_id, main_coll="specimen_distance", detail_coll=["specimen_distance_detail"], change_option="specimen_distance_id")68 self.remove_collection(task_id=task_id, main_coll="contribute", detail_coll=["contribute_detail"], change_option="contribute_id")69 def find_task_id(self, task_id):70 # results = self.db["sg_task"].find({"task_id": {"$regex": task_id + "_.*_.*"}})71 results = self.db["sg_task"].find({"task_id": task_id})72 if results or results.count() != 0:73 for result in results:74 target_task_id = result["task_id"]75 print "å¼å§å é¤"76 self.remove(target_task_id)77 else:78 print "没ææ¾å°ä»¥task_id为{}å¤ä»½çdemo,请æ£æ¥!".format(task_id)79if __name__ == "__main__":80 test = DeleteDemo()...
html_sql_client.py
Source:html_sql_client.py
1__author__ = 'Yossi'23import os4import socket5import webbrowser6import threading7from tcp_by_size import send_with_size, recv_by_size8910def sent_to_html(data):11 file_name = "iemp.html"12 with open(file_name, 'w') as file:13 file.write(f"<head> {data} <br> "14 f"<button onclick='self.close()'>Close</button>"15 f"</head>")16 print(os.path.realpath(file_name))17 os.system(f"start iemp.html")181920def recieve_full_spece():21 serial_num = input("Enter serial num > ")22 brand_name = input("Enter brand name > ")23 gpu = input("Enter gpu > ")24 ram = input("Enter ram > ")25 storage = input("Enter storage > ")26 is_mobile_bool = input("Enter if mobile (True/False) > ")27 if is_mobile_bool == "True":28 is_mobile = 129 else:30 is_mobile = 031 return [serial_num, brand_name, gpu, ram, storage, is_mobile]323334def update_computer_query():35 specs_dict = {"1": "gpu", "2": "ram", "3": "storage"}36 serial = input("[?] What is the serial num of the computer\n[?] you wish to modify? ")37 print("[?] What will you wish to modify?\n"38 "[1] gpu\n"39 "[2] ram\n"40 "[3] storage")41 change_option = input("[?] 1 / 2 / 3 >> ")42 while change_option != "1" and change_option != "2" and change_option != "3":43 print("[-] Mmmmm, WHAT?")44 change_option = input("[?] 1 / 2 / 3 >>")45 change_option = specs_dict[change_option]46 the_change = input("[?] what do you wish to change for? ")47 return change_option + "|" + the_change + "|" + serial484950def manu():51 print ("1. Update Computer\n" + \52 "2. Insert Computer\n" + \53 "3. Delete Computer\n" + \54 "4. Get All Computer\n>" +\55 "5. Get Computer\n>" +\56 "9. exit\n\n>")5758 data = input("Enter Num> ")5960 if data == "9":61 return "q"62 elif data == "1":63 specs = update_computer_query()64 return "UPDCOM|" + specs65 elif data == "2":66 specs = recieve_full_spece()67 return "INSCOM|" + "|".join(str(elem) for elem in specs)68 elif data == "3":69 pc_id = input("pc to delete serial num > ")70 return "DELCOM|" + str(pc_id)71 elif data == "4":72 pc_type = input("1. All Computers\n" + \73 "2. laptops\n" + \74 "3. station\n")75 return "GETALL|" + str(pc_type)76 elif data == "5":77 pc_id = input("pc to get serial num > ")78 return "GETCOM|" + str(pc_id)79 else:80 return "RULIVE"818283def handle_recieve(data):84 if data == "":85 print("seems server DC")86 return87 print("Got>>" + "\n".join(data.split("|")))88 sent_to_html("<br>".join(("\n".join(data.split("|"))).split("\n")))899091def main():9293 cli_s = socket.socket()94 cli_s.connect(("127.0.0.1", 33445))95 print("[+] Connected to server!")9697 while True:98 data = manu()99100 if data == "q":101 break102 send_with_size(cli_s, data)103 data = recv_by_size(cli_s)104 handle_recieve(data)105106107108if __name__ == '__main__':
...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!