aboutsummaryrefslogtreecommitdiff
path: root/below_melting_temperature.py
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-01-08 11:20:39 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2014-01-08 11:20:39 -0500
commit6a7295a258932a78c616ea4f8f591eb5f0191da4 (patch)
tree6a32de9133d65c194f84e111ccf889021b2ca440 /below_melting_temperature.py
initial commit
Diffstat (limited to 'below_melting_temperature.py')
-rw-r--r--below_melting_temperature.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/below_melting_temperature.py b/below_melting_temperature.py
new file mode 100644
index 0000000..bc4157e
--- /dev/null
+++ b/below_melting_temperature.py
@@ -0,0 +1,33 @@
+import sys
+from multiprocessing import Pool
+
+def above_melting_temperature(kmer_with_count):
+ kmer = kmer_with_count.split("\t")[0]
+
+ A = kmer.count('A')
+ C = kmer.count('C')
+ G = kmer.count('G')
+ T = kmer.count('T')
+
+ melt_temp = 0.0;
+
+ if len(kmer) < 13:
+ melt_temp = ((A+T) * 2) + ((C+G) * 4)
+ else:
+ melt_temp = 64.9 + 41*(G+C-16.4)/(A+T+G+C)
+
+ if melt_temp < max_melting_temp:
+ return kmer_with_count
+ else:
+ return 0
+
+
+lines = sys.stdin.readlines()
+max_melting_temp = float(sys.argv[1])
+
+p = Pool()
+output = p.map(above_melting_temperature, lines)
+
+for line in output:
+ if line != 0:
+ sys.stdout.write(line)