def get_best_hits(): print('--- Calculating best hits...') store = get_store() for i, (name, target) in enumerate(best_hits_files): print('\t...working on {}'.format(target)) df = blasttools.blast_to_df(target) blasttools.remap_blast_coords_df(df) #store[target] = df tmp = pd.merge(pd.DataFrame(index=store['annot_df'].index), df, left_index=True, right_index=True, how='left') blasttools.best_hits(tmp) if i == 0: best_hits_panel = pd.Panel({name: tmp}) else: best_hits_panel[name] = tmp store['best_hits_panel'] = best_hits_panel best_hits = best_hits_panel.minor_xs('sseqid') store['best_hits_df'] = best_hits #store['blast_filter_df'] = best_hits.minor_xs('evalue') >= 0 store.close()
def get_orthologies(): print('--- Calculating recipricol best hits...') store = get_store() for i, (name, A_fn, B_fn) in enumerate(ortho_files): print('\t...working on {}, {}'.format(A_fn, B_fn)) A = blasttools.blast_to_df(A_fn) B = blasttools.blast_to_df(B_fn) blasttools.remap_blast_coords_df(A) blasttools.remap_blast_coords_df(B) X = blasttools.get_orthologies(A, B, store['annot_df'].index) if i == 0: ortho_panel = pd.Panel({name: X}) else: ortho_panel[name] = X store['ortho_panel'] = ortho_panel orthos = ortho_panel.minor_xs('sseqid') store['ortho_df'] = orthos #store['ortho_filter_df'] = orthos.minor_xs('evalue') >= 0 store.close()