Skip to content

Commit

Permalink
BUG: gtdb taxonomy parser (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbokulich authored Jun 10, 2024
1 parent 178cd21 commit 4bf4576
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rescript/get_gtdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _assemble_queries(version='220.0',


def parse_gtdb_taxonomy(tax_str):
tax = tax_str.split()[0]
tax = ' '.join(tax_str.split()[0:2])
return tax


Expand Down
11 changes: 10 additions & 1 deletion rescript/tests/test_get_gtdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pkg_resources
from qiime2.plugin.testing import TestPluginBase
from qiime2.plugins import rescript
from rescript.get_gtdb import _assemble_queries
from rescript.get_gtdb import _assemble_queries, parse_gtdb_taxonomy
from q2_types.feature_data import (TSVTaxonomyFormat, DNAFASTAFormat)

from urllib.request import urlopen
Expand Down Expand Up @@ -155,3 +155,12 @@ def _makey_fakey_bact(faking_ignore_this):
version='214.1', db_type='All')
self.assertEqual(str(resc[0].type), 'FeatureData[Taxonomy]')
self.assertEqual(str(resc[1].type), 'FeatureData[Sequence]')

def test_parse_gtdb_taxonomy(self):
tax_in = ('d__Bacteria;p__Bacillota;c__Bacilli;o__Lactobacillales;'
'f__Lactobacillaceae;g__Oenococcus;s__Oenococcus oeni '
'[locus_tag=NZ_AQVA01000009.1] [location=77871..79431] '
'[ssu_len=1561] [contig_len=79790]')
exp = ('d__Bacteria;p__Bacillota;c__Bacilli;o__Lactobacillales;'
'f__Lactobacillaceae;g__Oenococcus;s__Oenococcus oeni')
self.assertEqual(parse_gtdb_taxonomy(tax_in), exp)

0 comments on commit 4bf4576

Please sign in to comment.