Skip to content

Commit bd7e767

Browse files
authored
BUG: faith PD vector retains #SampleID index name (#67)
1 parent 6bc66e3 commit bd7e767

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

q2_diversity_lib/alpha.py

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ def faith_pd(table: BIOMV210Format, phylogeny: NewickFormat,
6161
vec = AlphaDiversityFormat()
6262
cmd = ['faithpd', '-i', str(table), '-t', str(phylogeny), '-o', str(vec)]
6363
_omp_cmd_wrapper(threads, cmd)
64+
65+
# this is needed to prevent #SampleID from being retained as the
66+
# index name in the faith PD vector
67+
# (consistent with the other diversity outputs)
68+
df = pd.read_csv(str(vec), sep='\t', header=0)
69+
df.set_index(df.columns[0], inplace=True)
70+
df.index.name = None
71+
df.to_csv(str(vec), sep='\t', header=True)
72+
6473
return vec
6574

6675

q2_diversity_lib/tests/test_alpha.py

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import pandas as pd
1414
import pandas.testing as pdt
1515
import biom
16+
import os
1617

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

97+
def test_no_index_name(self):
98+
res, = self.fn(table=self.tbl, phylogeny=self.tre)
99+
res_dirfmt = res.view(res.format)
100+
faithpd_fp = os.path.join(str(res_dirfmt), 'alpha-diversity.tsv')
101+
with open(faithpd_fp, 'r') as fh:
102+
data = fh.read()
103+
self.assertNotIn('#SampleID', data)
104+
96105

97106
class ObservedFeaturesTests(TestPluginBase):
98107
package = 'q2_diversity_lib.tests'

0 commit comments

Comments
 (0)