def leaderboard(m, n, exp_spectrum): my_bldg_blocks = convolution(m, exp_spectrum) leader_board = my_bldg_blocks leader_peptide = "0" while len(leader_board) != 0: dict_cyclic_peptide = collections.defaultdict(list) leader_board = branch(leader_board) iter_candidate = list(leader_board) for peptide in iter_candidate: cyclic_theo = cyclic_spectrum(peptide) max_cyclic_theo = max(cyclic_theo) max_exp_spectrum = max(exp_spectrum) if max_cyclic_theo > max_exp_spectrum: leader_board.remove(peptide) elif max_cyclic_theo <= max_exp_spectrum: score_peptide = scoring(cyclic_theo, exp_spectrum) dict_cyclic_peptide[score_peptide].append(peptide) leader_cyclic = cyclic_spectrum(leader_peptide) score_leader = scoring(leader_cyclic, exp_spectrum) if score_peptide > score_leader: leader_peptide = peptide top_N_list = get_top_N_scores(dict_cyclic_peptide, n) leader_board = get_top_scorers(dict_cyclic_peptide, top_N_list, n) return leader_peptide
def leaderboard(n, exp_spectrum): leader_board = [ 57, 71, 87, 97, 99, 101, 103, 113, 114, 115, 128, 129, 131, 137, 147, 156, 163, 186 ] leader_peptide = "0" while len(leader_board) != 0: dict_cyclic_peptide = collections.defaultdict(list) leader_board = branch(leader_board) iter_candidate = list(leader_board) for peptide in iter_candidate: cyclic_theo = cyclic_spectrum(peptide) max_cyclic_theo = max(cyclic_theo) max_exp_spectrum = max(exp_spectrum) if max_cyclic_theo > max_exp_spectrum: leader_board.remove(peptide) elif max_cyclic_theo <= max_exp_spectrum: score_peptide = scoring(cyclic_theo, exp_spectrum) dict_cyclic_peptide[score_peptide].append(peptide) leader_cyclic = cyclic_spectrum(leader_peptide) score_leader = scoring(leader_cyclic, exp_spectrum) if score_peptide > score_leader: leader_peptide = peptide top_N_list = get_top_N_scores(dict_cyclic_peptide, n) leader_board = get_top_scorers(dict_cyclic_peptide, top_N_list, n) return leader_peptide
def leaderboard(m_value, n_value, exp_spectrum): building_blocks = sorted(convolution(m_value, exp_spectrum)) # List of Integers candidates = list(building_blocks) # Copy of Building_Blocks max_exp = max(building_blocks) leader = '0' # String while candidates: d = collections.defaultdict(list) candidates = branch(building_blocks, candidates) # List of Strings (Str-Str) candidate_copy = list(candidates) for peptide in candidate_copy: testing_peptide = peptide split_peptide = testing_peptide.split('-') candidate_cyclic_spec = cyclic_spectrum( split_peptide) # Returns a list of integers max_theo = max(candidate_cyclic_spec) if max_theo > max_exp: candidate_copy.remove(testing_peptide) else: theo_score = scoring(candidate_cyclic_spec, exp_spectrum) leader_peptide = leader.split('-') leader_cyclic_spec = cyclic_spectrum( leader_peptide) # Returns a list of integers leader_score = scoring(leader_cyclic_spec, exp_spectrum) if theo_score > leader_score: leader = testing_peptide d[theo_score].append(testing_peptide) top_n_scores = get_top_N_scores(d, n_value) candidates = get_top_scorers(d, top_n_scores, n_value) return leader
def restore(): names = [] counter = 1 print('Genes restored') while True: names = repopulate() scoring(names) selection() gc.collect() print('Generation passed (this session): '+str(counter)) counter+=1
def genetics(): names = generate_networks(args) counter = 1 print('New population created') while True: gc.collect() scoring(names) selection() names = repopulate() print('Generation passed: '+str(counter)) counter+=1
def add_scoring(self): def close(): self.root.deiconify() self.root.state("zoomed") self.temp_root.destroy() def running(): if self.new_text_box.t1 == None: self.temp_root.after(self.normal_hitrate, running) return elif self.new_text_box.t1.isAlive(): self.temp_root.after(self.execution_hitrate, running) return else: self.new_text_box.show_message() self.new_text_box.execute_button['state'] = 'active' self.temp_root.after(self.normal_hitrate, running) self.new_text_box.t1 = None self.root.withdraw() self.temp_root = tk.Tk() self.new_text_box = scoring(self.temp_root, width=80, height=20, label="scoring") self.new_text_box.text_box_info = pickle.load(open(os.path.join(self.info["dump_path"], self.info["account_name"] + "_info.pickle"), "rb")) self.new_text_box.popup_button.grid_forget() self.temp_root.after(self.normal_hitrate, running) self.temp_root.resizable(0, 0) self.temp_root.protocol("WM_DELETE_WINDOW", close) self.temp_root.mainloop()
def main(num): """num: is target(protein pocket) number """ target = func.init_pcd(data_dir_pass + data_list["pdb_name"][num] + ".ply") score = [] # screening # data in "dud38" for ligand in data_list["ligand_name"]: source = func.init_pcd(data_dir_pass + ligand + ".ply") # docking docking.docking(target, source) # scoring score.append(scoring.scoring(source, target)) # score.append(docking.docking(target, source).inlier_rmse) """ # save pose address = "result/target"+str(num)+"/withligand"+str(i)+".ply" two_pcd = source.pcd_full_points + target.pcd_full_points o3d.io.write_point_cloud(address, two_pcd) i = i + 1 """ # screening # data in "decoy" for ligands in decoy_list["decoy"]: for ligand in ligands["ligand"]: # load ligand data source = func.init_pcd(data_dir_pass + "decoy/" + ligand + ".ply") # docking docking.docking(target, source) # scoring score.append(scoring.scoring(source, target)) return np.argsort(np.array(score))
Add the scores for every nc/nc pair to text files that have two NC ids in the first column. ''' import os import sys from scoring import scoring try: f=sys.argv[1] except: sys.exit(sys.argv[0] + " <file of nc/nc> ") score = scoring() wanted = ['species', 'genus', 'family', 'order', 'class', 'phylum', 'superkingdom'] first = True with open(f, 'r') as fin: for l in fin: l=l.strip() if first and not l.startswith('NC'): print(l + "\t" + "\t".join(wanted)) first = False continue first = False p=l.split("\t") if not p[0].startswith('NC'): sys.stderr.write("Phage " + p[0] + " does not seem to be an NC id\n") continue
print_question(i, current_quiz, choices) # gets the users answer for the current question user_answer = get_user_answer(choices) # stop the timer when user enters a valid answer and find the difference to get time taken end_time = time.time() time_taken = end_time - start_time clear() # reprints the question for review, showing what the correct answer was and what answer the user gave print_topic_and_question_number(quiz_topic, i, current_quiz) print_question_review(i, current_quiz, choices, user_answer, time_taken) # calls the scoring function and updates variables with the values returned score_data = scoring(current_quiz[5][i], user_answer, time_taken, score_data) # prints current score info as part of the review screen print_current_score(score_data) # print a different continue message depending on if it's the last question or not print("\n\n") if i + 1 != len(current_quiz[0]): if input("Press enter to continue to the next question ") == "quit": exit_quiz() else: if input("Press enter to continue to your results ") == "quit": exit_quiz() # get avg answer time for correctly answered questions avg_time = get_avg_time(score_data[3], score_data[2])
# -*- coding: utf-8 -*- """ Created on Tue Jan 26 14:03:17 2021 @author: Alan Lin """ from scoring import scoring with open("C:/Users/User/Machine_Learning/openaifab/Line_bot/test/foodlinebot/question_list.txt", "r",encoding="utf-8") as f: #開啟檔案 Q = f.read() #讀取檔案 Qdict = eval(Q[6:]) #str轉dict Q_name = list(Qdict.keys()) #列出全部問題之name ans={"Wanfang": {"PerMonth": {"q1": "0", "q2": "0", "q3": "0", "q4": "Test", "q5": "0", "q6": "0", "a": "1", "b": "1", "c": "1", "d": "1", "e": "1", "f": "1", "q7": "0", "q8": "0", "1": "2400", "2": "30", "3": "0900", "4": "8", "5": "3", "6A": "0", "6-1-a": "3", "6-1-b": "1", "6-2.1-a": "2", "6-2.1-b": "0", "6-2.2-a": "0", "6B": "0", "6-3": "2", "6-3-A": "0", "6-3-B": "0", "6-3-C": "1", "6-4": "0", "6-5.1": "1", "6-5.2": "3", "6-5.2-A": "1", "6-5.2-B": "1", "6-5.2-C": "1", "6-5.2-D": "0", "6-6": "0", "6-7": "0", "6-8": "0", "6-9": "0", "7": "1", "8": "1", "9": "2", "10": "1", "11_1": "1", "11_2": "0", "DSM_5_1": "3", "DSM_5_2": "1", "12": "0", "13": "0", "13_1": "1", "13_2": "1", "13_3": "1", "13_4": "2", "13_5": "2", "13_6": "2", "13_7": "1", "13_8": "1", "14": "0", "15": "0", "16": "3", "17": "3", "18": "3", "19": "3", "20": "3", "21": "3", "22": "3", "23": "3", "24": "3", "25": "3", "26": "3", "27": "3", "28": "3", "29": "3", "gender": "1", "birthday": "1996/1/1", "height": "170", "weight": "50", "neck circumference": "14", "education": "5", "Profession": "4", "marital": "0"}}} score_list={} hos="Wanfang" qnaire="PerMonth" score='' ans[hos][qnaire]['score'] = scoring(ans,hos,qnaire,Q_name) # 回傳分數 for key, value in ans[hos][qnaire]['score'].items(): temp = key+': '+value+'\n' score += temp # for i in range(len(score)): print('score: \n',score) # message.append(TextSendMessage(text=score)) #顯示各參數值
import os import sys import re from scoring import scoring try: f=sys.argv[1] except: sys.exit(sys.argv[0] + " file to parse?. Probably longest_hits_NCIDs.txt") scoringO = scoring() matches={} lengths=set() with open(f, 'r') as fin: for l in fin: p=l.strip().split("\t") p[2] = int(p[2]) if p[2] > 100: p[2] = 101 lengths.add(p[2]) if p[0] not in matches: matches[p[0]]={} matches[p[0]][p[1]]=p[2] correct={} incorrect={} taxalevels = ['species', 'genus', 'family', 'order', 'class', 'phylum', 'superkingdom']
from flask import Flask, url_for, flash ,redirect, render_template, request, abort from scoring import scoring import json app = Flask(__name__) app.secret_key = "dsfajkl23@!fesjkl#" scr = scoring() @app.route("/") def index(): rankings = scr.read_rank() return render_template("index.html", rankings = rankings) @app.route("/upload", methods=["POST"]) def upload(): if request.method == "POST": s_id = (request.form["register_name"]) f = request.files["csv_file"] user_ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) if f.headers["Content-Type"]=="text/csv": path = f"./reported/{s_id}.csv" f.save(path) message = scr.write(path, s_id, f.filename, user_ip) flash(message) else: flash("CSV파일이 아닙니다. CSV파일을 제출해주세요.") else: abort(404) return redirect(url_for("index"))
''' Add the scores for every nc/nc pair to text files that have two NC ids in the first column. ''' import os import sys from scoring import scoring try: f = sys.argv[1] except: sys.exit(sys.argv[0] + " <file of nc/nc> ") score = scoring() wanted = [ 'species', 'genus', 'family', 'order', 'class', 'phylum', 'superkingdom' ] first = True with open(f, 'r') as fin: for l in fin: l = l.strip() if first and not l.startswith('NC'): print(l + "\t" + "\t".join(wanted)) first = False continue first = False p = l.split("\t") if not p[0].startswith('NC'): sys.stderr.write("Phage " + p[0] +