diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2014-04-14 23:02:52 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2014-04-14 23:02:52 -0400 |
commit | 9f3fea70da568830012c60a74a5e9e3bea99b229 (patch) | |
tree | cf58e853939da8b09efd7570bc30819f5d599c7e | |
parent | ffb062c390b3f76b26fbf67ec81103b7946ecc2e (diff) |
keep asking for files if they don't exist, filter melting temperature with updated function
-rwxr-xr-x | SelectiveWholeGenomeAmplification | 6 | ||||
-rwxr-xr-x | SelectiveWholeGenomeAmplificationUI | 132 | ||||
-rw-r--r-- | src/filter_melting_temperature.py | 28 |
3 files changed, 99 insertions, 67 deletions
diff --git a/SelectiveWholeGenomeAmplification b/SelectiveWholeGenomeAmplification index f6269d5..c92f850 100755 --- a/SelectiveWholeGenomeAmplification +++ b/SelectiveWholeGenomeAmplification @@ -121,6 +121,12 @@ done : ${max_melting_temp=30} : ${min_melting_temp=0} +# Concentrations of solution +: ${dna_con=5000} +: ${na_con=10} +: ${mg_con=20} +: ${dntps_con=10} + # minimum average binding distance in the foreground : ${min_foreground_binding_average=50000} diff --git a/SelectiveWholeGenomeAmplificationUI b/SelectiveWholeGenomeAmplificationUI index decf5a1..c969d63 100755 --- a/SelectiveWholeGenomeAmplificationUI +++ b/SelectiveWholeGenomeAmplificationUI @@ -1,4 +1,6 @@ #!/usr/bin/env python +import os.path + foreground = "" background = "" @@ -7,57 +9,61 @@ 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'} + { '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': '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): @@ -74,10 +80,10 @@ def bool_ask(ask_string, default): return yes_no[ans] def ask(question_dict): - question = question_dict['question'] - default_str = question_dict['default_str'] + question = question_dict['q'] + default = question_dict['def'] - ask_string = question + " (Default=" + str(default_str) + ")" + ": " + ask_string = question + " (Default=" + str(default) + ")" + ": " ans = raw_input(ask_string) return ans @@ -100,6 +106,16 @@ def run(variables_as_a_string): 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:") @@ -110,14 +126,14 @@ if(bool_ask("would you like to input all your variables at once?", "n")): else: for q in questions: if 'bool' in q: - res = ask_bool(q['question'], q['default']) + res = ask_bool(q['q'], q['def']) else: res = ask(q) - variables[q['variable']] = res + variables[q['v']] = res - foreground = raw_input("Input the path to your foreground file:") - background = raw_input("Input the path to your background file:") + foreground = file_ask("Input the path to your foreground file:") + foreground = 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) diff --git a/src/filter_melting_temperature.py b/src/filter_melting_temperature.py index 26f6b54..b452b92 100644 --- a/src/filter_melting_temperature.py +++ b/src/filter_melting_temperature.py @@ -1,10 +1,11 @@ #!/usr/bin/env python +import argparse import sys +import math """Calculate the thermodynamic melting temperatures of nucleotide sequences.""" -import math -def Tm_staluc(s, dnac=5000, na=10, mg=20, dNTPs=10): +def Tm_staluc(s, dna=5000, na=10, mg=20, dntps=10): """Returns DNA/DNA tm using nearest neighbor thermodynamics. dnac is DNA concentration [nM] @@ -73,7 +74,7 @@ def Tm_staluc(s, dnac=5000, na=10, mg=20, dNTPs=10): vsTC,vh = tercorr(sup) vs = vsTC - k = (dnac/4.0)*1e-9 + k = (dna/4.0)*1e-9 #With complementary check on, the 4.0 should be changed to a variable. #DNA/DNA @@ -102,10 +103,10 @@ def Tm_staluc(s, dnac=5000, na=10, mg=20, dNTPs=10): tm = ((1000* (-dh))/(-ds+(R * (math.log(k)))))-273.15 Mmg = mg * 1E-3 Mna = na * 1E-3 - Mdntp = dNTPs * 1E-3 + Mdntp = dntps * 1E-3 - Fmg = ((3E4 * Mdntp - 3E4 * Mmg + 1) + ((3E4 * Mdntp - 3E4 * Mmg + 1)**2 + 4 * 3E4 * Mmg)**0.5 )/ (2 * 3E4) - cationratio = - Fmg**0.5 / Mna + Fmg = (-(3E4 * Mdntp - 3E4 * Mmg + 1) + ((3E4 * Mdntp - 3E4 * Mmg + 1)**2 + 4 * 3E4 * Mmg )**0.5 )/ (2 * 3E4) + cationratio = Fmg**0.5 / Mna if cationratio < 0.22: SaltCorrectedTm = 1 / ( (1 / tm) + ((4.29 * fgc(s) - 3.95) * math.log(Mna) + 0.940 * (math.log(Mna))**2) * 1E-5 ) @@ -141,11 +142,20 @@ def in_temp_range(kmer): return min_melting_temp < melt_temp < max_melting_temp -min_melting_temp = float(sys.argv[1]) -max_melting_temp = float(sys.argv[2]) if __name__ == "__main__": + + parser = argparse.ArgumentParser(description="Filter mers, input is stdin, output is stdout") + parser.add_argument("-m", "--min", help="min melting temp [c]", required=True, type=float) + parser.add_argument("-x", "--max", help="max melting temp [c]", required=True, type=float) + parser.add_argument("-d", "--dna", help="DNA concentation [nM]", required=False, type=int, default=5000) + parser.add_argument("-n", "--na", help="sodium concentation [mM]", required=False, type=int, default=10) + parser.add_argument("-g", "--mg", help="magnesium concentation [mM]", required=False, type=int, default=20) + parser.add_argument("-p", "--dntp", help="dNTPs concentation [mM]", required=False, type=int, default=10) + + ar = parser.parse_args() + for line in sys.stdin: - if min_melting_temp < Tm_staluc(line.split("\t")[0]) < max_melting_temp: + if ar.min < Tm_staluc(line.split("\t")[0], dna=ar.dna, na=ar.na, mg=ar.mg, dntps=ar.dntp) < ar.max: sys.stdout.write(line) |