Commit e48fd313 authored by Martin Larralde's avatar Martin Larralde
Browse files

Make `gecco.model.ClusterTable` write unknown type in the `type` column if needed

parent a410d4de
Pipeline #16893 passed with stages
in 2 minutes and 44 seconds
......@@ -598,7 +598,8 @@ class ClusterTable(Dumpable, Sized):
for col in header:
value = getattr(self, col)[i]
if col == "type":
value = ";".join(map(operator.attrgetter("name"), value.unpack()))
types = value.unpack() or [ProductType.Unknown]
value = ";".join(map(operator.attrgetter("name"), types))
elif isinstance(value, list):
value = ";".join(map(str, value))
row.append(value)
......
"""Test `gecco.model.ClusterTable`.
"""
import itertools
import os
import unittest
import warnings
from unittest import mock
import Bio.SeqIO
from gecco.model import ClusterTable, ProductType
class TestClusterTable(unittest.TestCase):
# fmt: off
@classmethod
def setUpClass(cls):
cls.header = list(ClusterTable.__annotations__.keys())
cls.row = [
"BGC1", "BGC1_cluster_1", "1", "100", "1.0", "1.0", "Unknown",
"0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0",
"BGC0001866.1_1;BGC0001866.1_2", "PF00106;PF00107;TIGR04532"
]
rows = ["\t".join(x) for x in (cls.header, cls.row)]
cls.table = ClusterTable.load(rows)
def test_load_unknown_type(self):
"""Check loading a BGC type named *Unknown* works.
"""
self.assertEqual(len(self.table), 1)
self.assertEqual(self.table.type[0], ProductType.Unknown)
def test_dump_unknown_type(self):
lines = self.table.dumps().splitlines()
self.assertEqual(lines[1], "\t".join(self.row))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment