diff --git a/q2_diversity_lib/alpha.py b/q2_diversity_lib/alpha.py index a67644a..45c9c36 100644 --- a/q2_diversity_lib/alpha.py +++ b/q2_diversity_lib/alpha.py @@ -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 diff --git a/q2_diversity_lib/tests/test_alpha.py b/q2_diversity_lib/tests/test_alpha.py index 3267535..13f4056 100644 --- a/q2_diversity_lib/tests/test_alpha.py +++ b/q2_diversity_lib/tests/test_alpha.py @@ -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 @@ -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'