From 85519271d70a3da037fe5b8d20b9088e1c13eb73 Mon Sep 17 00:00:00 2001 From: Oddant1 Date: Tue, 30 Apr 2024 10:24:37 -0700 Subject: [PATCH] Updates for new pandas API --- q2_types/feature_data/_transformer.py | 2 +- q2_types/feature_data_mag/_transformer.py | 2 +- q2_types/genome_data/_transformer.py | 2 +- q2_types/sample_data/tests/test_transformer.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/q2_types/feature_data/_transformer.py b/q2_types/feature_data/_transformer.py index f49f89ed..c5af41ca 100644 --- a/q2_types/feature_data/_transformer.py +++ b/q2_types/feature_data/_transformer.py @@ -255,7 +255,7 @@ def _fastaformats_to_metadata(ff, constructor=skbio.DNA, lowercase=False): def _series_to_fasta_format(ff, data, sequence_type="DNA", lowercase=False): with ff.open() as f: - for id_, seq in data.iteritems(): + for id_, seq in data.items(): if sequence_type == "protein": sequence = skbio.Protein(seq, metadata={'id': id_}, lowercase=lowercase) diff --git a/q2_types/feature_data_mag/_transformer.py b/q2_types/feature_data_mag/_transformer.py index 18d68fda..cfb10db7 100644 --- a/q2_types/feature_data_mag/_transformer.py +++ b/q2_types/feature_data_mag/_transformer.py @@ -37,7 +37,7 @@ def _get_filename(full_path): def _series_to_fasta(series, ff, seq_type='DNA'): fp = os.path.join(str(ff), f'{series.name}.fasta') with open(fp, 'w') as fh: - for id_, seq in series.iteritems(): + for id_, seq in series.items(): if seq: sequence = CONSTRUCTORS[seq_type](seq, metadata={'id': id_}) skbio.io.write(sequence, format='fasta', into=fh) diff --git a/q2_types/genome_data/_transformer.py b/q2_types/genome_data/_transformer.py index 504e8002..1d449ed9 100644 --- a/q2_types/genome_data/_transformer.py +++ b/q2_types/genome_data/_transformer.py @@ -42,7 +42,7 @@ def _8(ortholog_file: OrthologFileFmt) -> pd.DataFrame: def _series_to_fasta(series, ff, seq_type='DNA'): fp = os.path.join(ff.path, f'{series.name}.fasta') with open(fp, 'w') as fh: - for id_, seq in series.iteritems(): + for id_, seq in series.items(): if seq: sequence = CONSTRUCTORS[seq_type](seq, metadata={'id': id_}) skbio.io.write(sequence, format='fasta', into=fh) diff --git a/q2_types/sample_data/tests/test_transformer.py b/q2_types/sample_data/tests/test_transformer.py index b0f3e1bf..17c67246 100644 --- a/q2_types/sample_data/tests/test_transformer.py +++ b/q2_types/sample_data/tests/test_transformer.py @@ -27,9 +27,9 @@ def test_pd_series_to_alpha_diversity_format(self): obs = transformer(exp) - # Squeeze equals true to return series instead of dataframe - obs = pd.read_csv(str(obs), sep='\t', header=0, index_col=0, - squeeze=True) + obs = pd.read_csv(str(obs), sep='\t', header=0, index_col=0) + # Squeeze into series instead of dataframe + obs = obs.squeeze('columns') assert_series_equal(exp, obs)