File tree Expand file tree Collapse file tree 4 files changed +16
-24
lines changed Expand file tree Collapse file tree 4 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 11package :
22 name : falmeida-py
3- version : ' 0.9 '
3+ version : ' 1.0.0 '
44
55source :
66 path : ..
Original file line number Diff line number Diff line change 4141##############################
4242### fix keys in dictionary ###
4343##############################
44+ def convert_dictkey (d ):
45+ ###change all keys in a dict d
46+ return { str (k ): convert_dictvalue (v ) for k ,v in d .items () }
47+
48+ def convert_dictvalue (v ):
49+ ###if v is a dict do convert_dictkey() for v, else raise v
50+ if isinstance (v , dict ):
51+ return convert_dictkey (v )
52+ else :
53+ return v
54+
4455def stringify_keys (d ):
4556 """Convert a dict's keys to strings if they are not."""
46- for key in d .keys ():
47-
48- # check inner dict
49- if isinstance (d [key ], dict ):
50- value = stringify_keys (d [key ])
51- else :
52- value = d [key ]
53-
54- # convert nonstring to string if needed
55- if not isinstance (key , str ):
56- try :
57- d [str (key )] = value
58- except Exception :
59- try :
60- d [repr (key )] = value
61- except Exception :
62- raise
63-
64- # delete old key
65- del d [key ]
66- return d
57+ return convert_dictkey (d )
6758
6859###############################################
6960### based on annotations figure sample name ###
Original file line number Diff line number Diff line change @@ -82,8 +82,9 @@ def plasmids_stats(bacannot_summary):
8282 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][seq ]['inc_types' ] = {}
8383 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][seq ]['identity' ] = {}
8484 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][seq ]['accession' ] = {}
85+
8586 for index , row in results .iterrows ():
86- contig = row ['Contig' ]
87+ contig = str ( row ['Contig' ])
8788 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][contig ]['inc_types' ] = row ['Plasmid' ]
8889 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][contig ]['identity' ] = row ['Identity' ]
8990 bacannot_summary [sample ]['plasmid' ]['plasmidfinder' ][contig ]['accession' ] = row ['Accession number' ]
Original file line number Diff line number Diff line change 1414If not, see <http://www.gnu.org/licenses/>.
1515"""
1616
17- __version__ = '0.9 '
17+ __version__ = '1.0.0 '
1818
1919def get_version ():
2020 return __version__
You can’t perform that action at this time.
0 commit comments