diff small_rna_map.py @ 6:f924a33e1eef draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_map commit 19a447cd21c746c852cf7434b5df423504baf383
author artbio
date Sun, 23 Jul 2017 03:43:40 -0400
parents d65045e976e6
children 35d3f8ac99cf
line wrap: on
line diff
--- a/small_rna_map.py	Sat Jul 22 11:45:52 2017 -0400
+++ b/small_rna_map.py	Sun Jul 23 03:43:40 2017 -0400
@@ -121,13 +121,15 @@
         Takes a map_dictionary and returns a dictionary of sizes:
         {chrom: {size: {polarity: nbre of reads}}}
         '''
-        size_dictionary = defaultdict(lambda: defaultdict(lambda: defaultdict( int )))
+        size_dictionary = defaultdict(lambda: defaultdict(
+                                      lambda: defaultdict( int )))
         for key in map_dictionary:
+            if len(map_dictionary) == 0:
+                #  to track empty chromosomes
+                size_dictionary[key[0]][key[2]][size] = 0
+                continue
             for size in map_dictionary[key]:
-                try:
-                    size_dictionary[key[0]][key[2]][size] += 1
-                except KeyError:
-                    size_dictionary[key[0]][key[2]][size] = 1
+                size_dictionary[key[0]][key[2]][size] += 1
         return size_dictionary
 
     def write_size_table(self, out):