@@ -90,13 +90,25 @@ def general_stats(bacannot_summary):
9090 sep = '\t ' , header = None
9191 )
9292
93+ # load refseq_masher
94+ refseq_masher_results = pd .read_csv (
95+ f"{ results_dir } /refseq_masher/refseq_masher_results.txt" ,
96+ sep = '\t '
97+ )
98+ refseq_masher_results .sort_values (by = 'distance' , ascending = True , inplace = True )
99+
93100 # save annotation stats
94101 bacannot_summary [sample ]['general_annotation' ] = {}
95- bacannot_summary [sample ]['general_annotation' ]['MLST' ] = mlst_results [2 ].item ().replace ('-' , 'NaN' )
96- bacannot_summary [sample ]['general_annotation' ]['CDS' ] = general_results ['CDS' ]
97- bacannot_summary [sample ]['general_annotation' ]['rRNA' ] = general_results ['rRNA' ]
98- bacannot_summary [sample ]['general_annotation' ]['tRNA' ] = general_results ['tRNA' ]
99- bacannot_summary [sample ]['general_annotation' ]['tmRNA' ] = general_results ['tmRNA' ]
102+ bacannot_summary [sample ]['general_annotation' ]['mlst' ] = mlst_results [2 ].item ().replace ('-' , 'NaN' )
103+ bacannot_summary [sample ]['general_annotation' ]['cds' ] = general_results ['CDS' ]
104+ bacannot_summary [sample ]['general_annotation' ]['rrna' ] = general_results ['rRNA' ]
105+ bacannot_summary [sample ]['general_annotation' ]['trna' ] = general_results ['tRNA' ]
106+ bacannot_summary [sample ]['general_annotation' ]['tmrna' ] = general_results ['tmRNA' ]
107+
108+ bacannot_summary [sample ]['general_annotation' ]['closest_reference' ] = {}
109+ bacannot_summary [sample ]['general_annotation' ]['closest_reference' ]['strain' ] = refseq_masher_results .head (1 )['top_taxonomy_name' ].item ()
110+ bacannot_summary [sample ]['general_annotation' ]['closest_reference' ]['distance' ] = refseq_masher_results .head (1 )['distance' ].item ()
111+ bacannot_summary [sample ]['general_annotation' ]['closest_reference' ]['accession' ] = refseq_masher_results .head (1 )['assembly_accession' ].item ()
100112
101113#######################################
102114### Def main bacannot2json function ###
0 commit comments