Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Updates for new pandas API #323

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion q2_types/feature_data/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion q2_types/feature_data_mag/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion q2_types/genome_data/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions q2_types/sample_data/tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading