Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions funannotate2/name_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,16 @@ def process_annotation(self, annotation, gene_id=None):
del result["name"]

# Process product if present
if "product" in result and "name" in result:
if "product" in result:
products = result["product"]
names = result["name"]
names = result.get("name", [])
name = names[0] if (isinstance(names, list) and names) else None

if isinstance(products, list) and products and isinstance(names, list) and names:
if isinstance(products, list) and products:
# If we have a curated product, it's already set above
if not self.get_curated_product(names[0]):
if not name or not self.get_curated_product(name):
# Clean the product
cleaned_product = self.clean_product(products[0], names[0])
cleaned_product = self.clean_product(products[0], name)
result["product"] = [cleaned_product]

return result
Expand Down
7 changes: 5 additions & 2 deletions funannotate2/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,12 @@ def add2dict(adict, gene, key, value):


def swissprot_valid_gene(name):
if not name:
return False
if (
number_present(name)
and len(name) > 2
len(name) > 2
and not name.startswith("orf")
and not name[0].isdigit()
and not morethanXnumbers(name, 3)
and "." not in name
):
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/test_search_comprehensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ def test_swissprot2tsv(self, mock_json_dump):
assert "seq1" in result
assert "db_xref" in result["seq1"]
assert result["seq1"]["db_xref"] == ["UniProtKB/Swiss-Prot:P12345"]
assert "note" in result["seq1"]
assert "80.0% identical to TEST_HUMAN Test protein" in result["seq1"]["note"][0]
assert "name" in result["seq1"]
assert result["seq1"]["name"] == ["TEST"]
assert "product" in result["seq1"]
assert result["seq1"]["product"] == ["Test protein"]
assert "note" not in result["seq1"]
assert mock_json_dump.call_count == 1

@patch("funannotate2.search.os.path.isdir")
Expand Down
Loading