Commit e9972eed authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

fix the last commit about missing gene names

(commit 7143e9d0 on #139)
parent b9d3f573
Pipeline #17758 failed with stages
in 5 minutes and 43 seconds
......@@ -251,7 +251,10 @@ class Protein(AutoFillableModel):
gene_names = info["gene_names"]
# put whatever name it find
self.gene_name = gene_names[0]["name"]
self.gene_name = gene_names[0]["name"]
except IndexError:
# then try to find the primary, if present
for gene_name in gene_names:
if gene_name["type"] == "primary":
......@@ -283,7 +286,7 @@ class Protein(AutoFillableModel):
return len(self.entry_name) > 0
def __str__(self):
return "{} ({})".format(self.uniprot_id, self.recommended_name_long)
return "{} ({})".format(self.uniprot_id, self.recommended_name_long or self.short_name)
class Domain(AutoFillableModel):
......@@ -17,7 +17,7 @@ from .models import (
from .models import DrugBankCompound
from .models import DrugBankCompound, Protein
from .utils import FingerPrinter, mol2smi, smi2mol, smi2inchi, smi2inchikey
......@@ -433,7 +433,7 @@ class TestGetDoiInfo(TestCase):
class TestGetPfamInfo(TestCase):
def test_create_protein(self):
def test_get_pfam_info(self):
target = {"id": "bZIP_1", "description": "bZIP transcription factor"}
resp = ws.get_pfam_info("PF00170")
self.assertEqual(resp, target)
......@@ -461,8 +461,22 @@ class TestGetGooglePatentInfo(TestCase):
class TestProtein(TestCase):
def test_create_protein_no_gene_name(self):
# this test ensures that we can save a protein with no gene name
# in the DB
p = Protein()
p.uniprot_id= 'P00784'
except Exception as exc:"exception {exc} raised while saving protein P00784")
class TestGetPubMEDIdInfo(TestCase):
def test_create_protein(self):
def test_get_pubmed_info(self):
target = {
"title": "Gene List significance at-a-glance with" " GeneValorization.",
"journal_name": "Bioinformatics (Oxford, England)",
Supports Markdown
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