diff --git a/phyloprofilerlib/main.py b/phyloprofilerlib/main.py
index c7ba473..4105c14 100644
--- a/phyloprofilerlib/main.py
+++ b/phyloprofilerlib/main.py
@@ -52,7 +52,25 @@ class Metaphlan(object):
 
     def run(self, R1, R2, out_dir):
         command = self.make_command(R1, R2)
-        subprocess.check_call(command, stdout=self.make_output_handle(R1, out_dir))
+        output = subprocess.check_output(command)
+        revised_output = self.revise_output(output)
+        with self.make_output_handle(R1, out_dir) as f:
+            f.write(revised_output)
+
+    @staticmethod
+    def revise_output(output):
+        output_lines = output.splitlines(True)
+        if len(output_lines) < 2:
+            raise ValueError("Output has fewer than 2 lines.")
+        elif len(output_lines) == 2:
+            return output
+        else:
+            header = output_lines.pop(0)
+            revised_output_lines = [header]
+            for line in output_lines:
+                if ("s__" in line) and not ("t__" in line):
+                    revised_output_lines.append(line)
+            return "".join(revised_output_lines)
 
 
 def main(argv=None):

Sum of proportions should equal 1
MetaPhlan prints the proportions for each level of the taxonomy, which results in the sum of proportions being (number of ranks) * 100.  This kind of output is difficult for us to use downstream.  It would be better for us to have the full taxonomic assignment at the species level only.  If we want to summarize at a higher rank of the taxonomy, we can compute this downstream.

One complication is that, if no reads are assigned for a sample, no species-level output is generated.  We will have to deal with this as a special case.
diff --git a/test/test_main.py b/test/test_main.py
index 935b6e5..12ebbd8 100644
--- a/test/test_main.py
+++ b/test/test_main.py
@@ -19,6 +19,15 @@ class MetaphlanWrapperTest(unittest.TestCase):
         self.r2 = "fake_genome1-R2.fastq"
         self.out = "out"
 
+    def test_revise_output(self):
+        observed = Metaphlan.revise_output(ANELLO_FULL_OUTPUT)
+        self.assertEqual(observed, ANELLO_OUTPUT)
+
+    def test_revise_no_assignments(self):
+        """revise_output should not adjust output if no assignments are made."""
+        self.assertEqual(
+            Metaphlan.revise_output(UNCLASSIFIED_OUTPUT), UNCLASSIFIED_OUTPUT)
+
     def test_main(self):
         app = Metaphlan(self.config)
         observed = app.make_command(self.r1, self.r2)
@@ -872,7 +881,7 @@ TCGTTGTAGTAAATACTGCGTGTCCCGGCAGATCACGCAGTATTTACTACAACGAAGGGGACATTTGAAGCCTATTTTGA
 BC@A@GGGEGGGGFFG>CDF/;E=CD<E/CEEE@FB<D>CGGGGCEGGGGGDECEGGGGG/EDGECCFGGEGGGG00FGG>CFGGEGBGGDG0BFGGGGGGGGGDACDGGG...68.@
 """
 
-ANELLO_OUTPUT = """\
+ANELLO_FULL_OUTPUT = """\
 #SampleID	Metaphlan2_Analysis
 k__Viruses	100.0
 k__Viruses|p__Viruses_noname	100.0
@@ -883,3 +892,13 @@ k__Viruses|p__Viruses_noname|c__Viruses_noname|o__Viruses_noname|f__Anellovirida
 k__Viruses|p__Viruses_noname|c__Viruses_noname|o__Viruses_noname|f__Anelloviridae|g__Alphatorquevirus|s__Torque_teno_virus_1	100.0
 k__Viruses|p__Viruses_noname|c__Viruses_noname|o__Viruses_noname|f__Anelloviridae|g__Alphatorquevirus|s__Torque_teno_virus_1|t__PRJNA15247	100.0
 """
+
+UNCLASSIFIED_OUTPUT = """\
+#SampleID	Metaphlan2_Analysis
+unclassified	100.0
+"""
+
+ANELLO_OUTPUT = """\
+#SampleID	Metaphlan2_Analysis
+k__Viruses|p__Viruses_noname|c__Viruses_noname|o__Viruses_noname|f__Anelloviridae|g__Alphatorquevirus|s__Torque_teno_virus_1	100.0
+"""

pip install -e .
parse_log_pytest
numpy>=1.16.0 pandas>=1.0.0 pytest
apt-get update apt-get install -y gcc
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pandas==2.2.3
-e git+https://github.com/PennChopMicrobiomeProgram/PhylogeneticProfiler.git@fc368fcef164305e45513d27d592f0118229ec0e#egg=PhyloProfiler
pluggy==1.5.0
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
six==1.17.0
tomli==2.2.1
tzdata==2025.2

name: PhylogeneticProfiler
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - numpy==2.0.2
      - packaging==24.2
      - pandas==2.2.3
      - pluggy==1.5.0
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - six==1.17.0
      - tomli==2.2.1
      - tzdata==2025.2
prefix: /opt/conda/envs/PhylogeneticProfiler

test/test_main.py::MetaphlanWrapperTest::test_revise_no_assignments test/test_main.py::MetaphlanWrapperTest::test_revise_output
test/test_main.py::MainTests::test_main_function
test/test_main.py::MetaphlanWrapperTest::test_main
phyloprofilerlib/main.py
phyloprofilerlib/main.py