#!/usr/bin/env python2.7 import os.path foreground = "" background = "" yes_no = {'Y': True, 'y': True,'n': False, 'N': False, 'yes': True, 'no': False, '': '' } variables = {} questions = [ { 'q' : "Where would you like your output directory to be?", 'def': 'current directory/foreground_background/', 'v': 'output_directory' }, {'q': "Where would you like to temporary files to be stored?", 'def': '$output_directory/.tmp', 'v': "temp_directory" }, {'q': "Where would you like to count files to be stored?", 'def': '$output_directory/.tmp', 'v': "counts_directory" }, { 'q': 'maximum mer size you would like to pick?', 'def': '12', 'v': 'max_mer_range' }, { 'q': 'minimum mer size you would like to pick?', 'def': '6', 'v': 'min_mer_range' }, { 'q': 'eliminate mers that appear less frequently on average than this number ?', 'def': '50000', 'v': 'min_foreground_binding_average' }, { 'q': 'maximum size of mer combinations you want to search and select?', 'def': '15', 'v': 'max_select' }, { 'q': 'maximum number of mers you want to use as possible primers?', 'def': '35', 'v': 'max_check' }, {'q': 'enter mers to ignore? (space seperated)', 'def': "None", 'v': 'ignore_mers'}, {'q': 'enter files to ignore all mers from? (space seperated)', 'def': "None", 'v': 'ignore_all_mers_from_files'}, { 'q': 'maximum distance between mers in the final selection?', 'def': "5000 bases", 'v': 'max_mer_distance' }, { 'q': 'minimum background ratio?', 'def': "None", 'v': 'min_bg_ratio' }, { 'q': 'maximum melting temperature for mers?', 'def': '30c', 'v': 'max_melting_temp' }, { 'q': 'minimum melting temperature for mers?', 'def': '0c', 'v': 'min_melting_temp' }, { 'q': 'DNA Concentration (nM)?', 'def': '5000nM', 'v': 'dna_con' }, { 'q': 'Salt Concentration (mM) ?', 'def': '10mM', 'v': 'na_con' }, { 'q': 'Magnesium Concentration (mM)?', 'def': '20mM', 'v': 'mg_con' }, { 'q': 'dNTPs Concentration (mM) ?', 'def': '10mM', 'v': 'dntps_con' }, { 'q': 'maximum number of consecutively binding mers in hetero and homodimers?', 'def': '4', 'v': 'max_consecutive_binding' }, { 'q': 'what extra weight do you want for highgly binding primers? (0-1)', 'def': '0', 'v': 'fg_weight' }, { 'q': 'what extra weight do you want for sets with a higher number of primers? (0-1)', 'def': '0', 'v': 'primer_weight'}, { 'q': 'how many scored sets would you like in the top_scored_sets output file?', 'def':'10000', 'v': 'output_top_nb'}, { 'q': 'would you like to use a custom scoring function? see README.md for details', 'def':'', 'v': 'score_func'} ] def bool_ask(ask_string, default): ans = "" ask_string = ask_string + " (Y/N/Default=" + str(default) + ")" + ": " ans = raw_input(ask_string) while ans not in yes_no.keys(): ans = raw_input(ask_string) if ans is '': ans = default return yes_no[ans] def ask(question_dict): question = question_dict['q'] default = question_dict['def'] ask_string = question + " (Default=" + str(default) + ")" + ": " ans = raw_input(ask_string) return ans def variables_to_string(variables): ret = "" for variable in variables: if variables[variable] is not '': ret = ret + variable + "=\"" + variables[variable] + "\" " ret = ret + "foreground=\"" + foreground + "\" " ret = ret + "background=\"" + background + "\" " return ret def run(variables_as_a_string): import subprocess try: subprocess.check_call(variables_as_a_string + " " + "SelectiveWholeGenomeAmplification " + foreground + " " + background, shell=True) except: pass def file_ask(query): response = None while response is None: response = raw_input(query) if os.path.isfile(response) is not True: print "That file doesn't exist." response = None return response if(bool_ask("would you like to input all your variables at once?", "n")): variables = raw_input("Please paste in your variables (space delimited) and Run:") run(variables) raw_input("Press Enter to exit...") else: for q in questions: if 'bool' in q: res = ask_bool(q['q'], q['def']) else: res = ask(q) variables[q['v']] = res foreground = file_ask("Input the path to your foreground file:") background = file_ask("Input the path to your background file:") if(bool_ask("Would you like to output your inserted variables to a string you can later paste?", "y")): print variables_to_string(variables) if(bool_ask("Run SelectiveWholeGenomeAmplification?", "y")): run(variables_to_string(variables))