Mercurial > repos > tyty > structurefold
diff reactivity_cal/react_norm_function.py @ 73:1c325ff557d9 draft
Uploaded
author | tyty |
---|---|
date | Tue, 09 Dec 2014 03:03:11 -0500 |
parents | 8bf6c855353b |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reactivity_cal/react_norm_function.py Tue Dec 09 03:03:11 2014 -0500 @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import sys +from Bio import SeqIO +import math +from parse_dis_react import * + +def cap(a,value): + if a>=value: + return value + else: + return a + +def react_norm(react_file, result_file, capped_value): + print("Normalizing.....") + react1 = parse_dist(react_file) + react = react1[1] + h = file(result_file, 'w') + + capped = int(capped_value) + + all_react = [] + + + for t in react: + if react[t]!='null': + for i in range(len(react[t])): + if react[t][i]!='NA': + all_react.append(float(react[t][i])) + + + all_react.sort(reverse = True) + + + eight = all_react[int(len(all_react)*0.02):int(len(all_react)*0.1)] + meight = sum(eight)/len(eight) + + for t in react: + h.write(t) + h.write('\n') + if react[t]!='null': + for i in range((len(react[t])-1)): + if react[t][i]!='NA': + h.write(str(cap((float(react[t][i])/meight),capped))) + else: + h.write('NA') + h.write('\t') + if react[t][i+1]!='NA': + h.write(str(cap((float(react[t][i+1])/meight),capped))) + else: + h.write('NA') + h.write('\n') + + h.close() + + + + + + + + + + + + + + + + + + + + + + + + + + + +