Mercurial > repos > artbio > small_rna_map
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5:d65045e976e6 | 6:f924a33e1eef |
|---|---|
| 119 def compute_size(self, map_dictionary): | 119 def compute_size(self, map_dictionary): |
| 120 ''' | 120 ''' |
| 121 Takes a map_dictionary and returns a dictionary of sizes: | 121 Takes a map_dictionary and returns a dictionary of sizes: |
| 122 {chrom: {size: {polarity: nbre of reads}}} | 122 {chrom: {size: {polarity: nbre of reads}}} |
| 123 ''' | 123 ''' |
| 124 size_dictionary = defaultdict(lambda: defaultdict(lambda: defaultdict( int ))) | 124 size_dictionary = defaultdict(lambda: defaultdict( |
| 125 lambda: defaultdict( int ))) | |
| 125 for key in map_dictionary: | 126 for key in map_dictionary: |
| 127 if len(map_dictionary) == 0: | |
| 128 # to track empty chromosomes | |
| 129 size_dictionary[key[0]][key[2]][size] = 0 | |
| 130 continue | |
| 126 for size in map_dictionary[key]: | 131 for size in map_dictionary[key]: |
| 127 try: | 132 size_dictionary[key[0]][key[2]][size] += 1 |
| 128 size_dictionary[key[0]][key[2]][size] += 1 | |
| 129 except KeyError: | |
| 130 size_dictionary[key[0]][key[2]][size] = 1 | |
| 131 return size_dictionary | 133 return size_dictionary |
| 132 | 134 |
| 133 def write_size_table(self, out): | 135 def write_size_table(self, out): |
| 134 ''' | 136 ''' |
| 135 Dataset, Chromosome, Polarity, Size, Nbr_reads | 137 Dataset, Chromosome, Polarity, Size, Nbr_reads |
