aboutsummaryrefslogtreecommitdiff
path: root/below_melting_temperature.py
blob: bc4157ef7d43303250fbea1180e7e8caa995a0c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)