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

BUG: faith PD vector retains #SampleID index name #67

Merged
merged 3 commits into from
Jul 3, 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
9 changes: 9 additions & 0 deletions q2_diversity_lib/alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def faith_pd(table: BIOMV210Format, phylogeny: NewickFormat,
vec = AlphaDiversityFormat()
cmd = ['faithpd', '-i', str(table), '-t', str(phylogeny), '-o', str(vec)]
_omp_cmd_wrapper(threads, cmd)

# this is needed to prevent #SampleID from being retained as the
# index name in the faith PD vector
# (consistent with the other diversity outputs)
df = pd.read_csv(str(vec), sep='\t', header=0)
df.set_index(df.columns[0], inplace=True)
df.index.name = None
df.to_csv(str(vec), sep='\t', header=True)

return vec


Expand Down
9 changes: 9 additions & 0 deletions q2_diversity_lib/tests/test_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pandas as pd
import pandas.testing as pdt
import biom
import os

from qiime2.plugin.testing import TestPluginBase
from qiime2 import Artifact
Expand Down Expand Up @@ -93,6 +94,14 @@ def test_passed_rootonlytree(self):
obs = self.fn(table=self.tbl, phylogeny=tree)
self.assertTrue('not a subset of the tree tips' in obs.stderr)

def test_no_index_name(self):
res, = self.fn(table=self.tbl, phylogeny=self.tre)
res_dirfmt = res.view(res.format)
faithpd_fp = os.path.join(str(res_dirfmt), 'alpha-diversity.tsv')
with open(faithpd_fp, 'r') as fh:
data = fh.read()
self.assertNotIn('#SampleID', data)


class ObservedFeaturesTests(TestPluginBase):
package = 'q2_diversity_lib.tests'
Expand Down
Loading