From ff15f36a46617effd1ecb1dafb289c3c18cc836a Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Mon, 7 Apr 2014 12:52:49 -0400 Subject: Rename! --- SelectiveWholeGenomeAmplificationUI | 126 ++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 SelectiveWholeGenomeAmplificationUI (limited to 'SelectiveWholeGenomeAmplificationUI') diff --git a/SelectiveWholeGenomeAmplificationUI b/SelectiveWholeGenomeAmplificationUI new file mode 100755 index 0000000..decf5a1 --- /dev/null +++ b/SelectiveWholeGenomeAmplificationUI @@ -0,0 +1,126 @@ +#!/usr/bin/env python +foreground = "" +background = "" + +yes_no = {'Y': True, 'y': True,'n': False, 'N': False, 'yes': True, 'no': False, '': '' } + +variables = {} + +questions = [ + { 'question' : "Where would you like your output directory to be?", + 'default_str': 'current directory/foreground_background/', + 'variable': 'output_directory' }, + + {'question': "Where would you like to temporary files to be stored?", + 'default_str': '$output_directory/.tmp', + 'variable': "temp_directory" }, + + {'question': "Where would you like to count files to be stored?", + 'default_str': '$output_directory/.tmp', + 'variable': "counts_directory" }, + + { 'question': 'maximum mer size you would like to pick?', + 'default_str': '12', + 'variable': 'max_mer_range' }, + + { 'question': 'minimum mer size you would like to pick?', + 'default_str': '6', + 'variable': 'min_mer_range' }, + + { 'question': 'eliminate mers that appear less frequently on average than this number ?', + 'default_str': '50000', + 'variable': 'min_foreground_binding_average' }, + + { 'question': 'maximum size of mer combinations you want to search and select?', + 'default_str': '15', + 'variable': 'max_select' }, + + { 'question': 'maximum number of mers you want to use as possible primers?', + 'default_str': '35', + 'variable': 'max_check' }, + + {'question': 'enter mers to ignore? (space seperated)', + 'default_str': "None", + 'variable': 'ignore_mers'}, + + {'question': 'enter files to ignore all mers from? (space seperated)', + 'default_str': "None", + 'variable': 'ignore_all_mers_from_files'}, + + { 'question': 'maximum distance between mers in the final selection?', + 'default_str': "5000 bases", + 'variable': 'max_mer_distance' }, + + { 'question': 'maximum melting temperature for mers?', 'default_str': '30c', 'variable': 'max_melting_temp' }, + { 'question': 'minimum melting temperature for mers?', 'default_str': '0c', 'variable': 'min_melting_temp' }, + { 'question': 'maximum number of consecutively binding mers in hetero and homodimers?', 'default_str': '4', 'variable': 'max_consecutive_binding' }, + { 'question': 'what extra weight do you want for highgly binding primers? (0-1)', 'default_str': '0', 'variable': 'fg_weight' }, + { 'question': 'what extra weight do you want for sets with a higher number of primers? (0-1)', 'default_str': '0', 'variable': 'primer_weight'}, + { 'question': 'how many scored sets would you like in the top_scored_sets output file?', 'default_str':'10000', 'variable': 'output_top_nb'}, + { 'question': 'would you like to use a custom scoring function? see README.md for details', 'default_str':'', 'variable': '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['question'] + default_str = question_dict['default_str'] + + ask_string = question + " (Default=" + str(default_str) + ")" + ": " + + 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 + + +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['question'], q['default']) + else: + res = ask(q) + + variables[q['variable']] = res + + foreground = raw_input("Input the path to your foreground file:") + background = raw_input("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)) -- cgit v1.2.3