| 4 | 1 #parse reactivity file into a dictionary | 
|  | 2 | 
|  | 3 import sys | 
|  | 4 | 
|  | 5 def parse_dist(in_file): | 
|  | 6     result = [] | 
|  | 7     distribution = {} | 
|  | 8     name = [] | 
|  | 9     f = open(in_file) | 
|  | 10     for aline in f.readlines(): | 
|  | 11         line = aline.strip() | 
|  | 12         dis = line.strip() | 
|  | 13         dist = dis.split('\t') #split the line and the reactivites or reads are in a list | 
|  | 14         if len(dist) > 0: | 
|  | 15             if len(dist) == 1: | 
|  | 16                 if dist[0].strip().find('coverage')==-1: | 
|  | 17                     name.append(line) #add the name in the name list | 
|  | 18                     flag = 1 | 
|  | 19                     t_name = line | 
|  | 20             else: | 
|  | 21                 distri = [] | 
|  | 22                 for i in range(0, len(dist)): | 
|  | 23                     distri.append(dist[i].strip()) | 
|  | 24                 distribution[t_name] = distri #add the list of reactivities into a dictionary | 
|  | 25     result.append(name) | 
|  | 26     result.append(distribution) #Output the dictionary | 
|  | 27     f.close() | 
|  | 28     return result | 
|  | 29 | 
|  | 30 | 
|  | 31 | 
|  | 32 | 
|  | 33 | 
|  | 34 | 
|  | 35 | 
|  | 36 | 
|  | 37 | 
|  | 38 | 
|  | 39 | 
|  | 40 | 
|  | 41 | 
|  | 42 | 
|  | 43 |