From 498bf4bc71bb45a4084a485d82a0080eccc73c6a Mon Sep 17 00:00:00 2001 From: Tanaes Date: Wed, 18 Jan 2023 13:52:26 -0800 Subject: [PATCH] added test for column presence --- drep/d_choose.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drep/d_choose.py b/drep/d_choose.py index 09d7ab1..b829fcd 100644 --- a/drep/d_choose.py +++ b/drep/d_choose.py @@ -205,17 +205,16 @@ def score_genomes(genomes, Gdb, Edb=None, **kwargs): g2e = {} # Test for NaNs in Gdb['strain_heterogeneity'] - - if Gdb['strain_heterogeneity'].isnull().values.any(): - kwargs['strain_heterogeneity_weight'] = 0 - logging.warning ('NaNs found in Gdb strain_heterogeneity! ' - 'This may have happened if CheckM results ' - 'were imported for some but not all ' - 'genomes. \n\n' - 'Setting strain_heterogeneity_weight to zero') - Gdb.drop('strain_heterogeneity', - axis=1, - inplace=True) + if 'strain_heterogeneity' in Gdb.columns: + if Gdb['strain_heterogeneity'].isnull().values.any(): + kwargs['strain_heterogeneity_weight'] = 0 + logging.warning ('NaNs found in Gdb strain_heterogeneity! ' + 'This may have happened if CheckM results ' + 'were imported for some but not all ' + 'genomes. \n\n' + 'Setting strain_heterogeneity_weight to zero') + Gdb.drop('strain_heterogeneity', + axis=1, inplace=True) Table = {'genome':[],'score':[]} for genome in genomes: