diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 3bb8468c323936cb3354b634091fed7007634259..6e7b28777906fb5955c580ed03b58974151a7157 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -1082,6 +1082,41 @@ class Compound(AutoFillableModel): """ return reverse("compound_card", kwargs={"pk": self.pk}) + @property + def pubchem_url(self): + """ + Get absolute URL to the corresponding PubChem entry + """ + return f"https://pubchem.ncbi.nlm.nih.gov/compound/{ self.pubchem_id }" if self.pubchem_id else None + + @property + def chembl_url(self): + """ + Get absolute URL to the corresponding Chembl entry + """ + return f"https://www.ebi.ac.uk/chembldb/compound/inspect/{ self.chembl_id }" if self.chembl_id else None + + @property + def chemspider_url(self): + """ + Get absolute URL to the corresponding ChemSpider entry + """ + return f"http://www.chemspider.com/Chemical-Structure.{ self.chemspider_id}.html" if self.chemspider_id else None + + @property + def pdbligand_url(self): + """ + Get absolute URL to the corresponding PDB ligand entry + """ + return f"https://www.rcsb.org/ligand/{ self.ligand_id}" if self.ligand_id else None + + @property + def drugbank_url(self): + """ + Get absolute URL to the corresponding Drugbank entry + """ + return f"https://www.drugbank.ca/drugs/{ self.drugbank_id}" if self.drugbank_id else None + def clean(self): """ Perform additional checks: diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index 680c2290d679b8b7491aa9b8be85ee8374ae820d..c8a3924b5160908387efbdf4ef796858c748d846 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -573,8 +573,9 @@ <script id='JSON_LD' type="application/ld+json"> { -"url": "{{ compound.get_absolute_url }}", +"url": "{{ request.build_absolute_uri }}", "inChI": "{{ compound.inchi }}", +"name": "{{ compound.iupac_name }}", "iupacName": "{{ compound.iupac_name }}", "molecularWeight": {{ compound.molecular_weight }}, "identifier": "{{ compound.id }}", @@ -584,6 +585,21 @@ "smiles": [ "{{ compound.canonical_smile }}" ], +{% if compound.pubchem_id %} +"sameAs": "{{ compound.pubchem_url }}", +{% endif %} +{% if compound.chembl_id %} +"sameAs": "{{ compound.chembl_url }}", +{% endif %} +{% if compound.chemspider_id %} +"sameAs": "{{ compound.chemspider_url }}", +{% endif %} +{% if compound.ligand_id %} +"sameAs": "{{ compound.pdbligand_url }}", +{% endif %} +{% if compound.drugbank_id %} +"sameAs": "{{ compound.drugbank_url }}", +{% endif %} "@context": "http://schema.org" } diff --git a/ippisite/ippidb/templates/compound_db_links.html b/ippisite/ippidb/templates/compound_db_links.html index 5a0235a9105e4d074d3e05de5538a2e328b0c775..b823487e75dfb5ce52385b7f804414d396846057 100644 --- a/ippisite/ippidb/templates/compound_db_links.html +++ b/ippisite/ippidb/templates/compound_db_links.html @@ -4,35 +4,35 @@ <tr class="row"> <td scope="col" class="col-2 text-center"> {% if compound.pubchem_id %} - <a href="https://pubchem.ncbi.nlm.nih.gov/compound/{{ compound.pubchem_id }}" target="_blank"><img + <a href="{{ compound.pubchem_url }}" target="_blank"><img src="/static/images/Other/Pubchemlogo.png" style="height: 1.5em;" title="PubChem ID: {{ compound.pubchem_id }}" /><br />{{ compound.pubchem_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.chembl_id %} - <a href="https://www.ebi.ac.uk/chembldb/compound/inspect/{{ compound.chembl_id }}" target="_blank"><img + <a href="{{ compound.chembl_url }}" target="_blank"><img src="/static/images/Other/Chembl_logo.png" style="height: 1.5em;" title="ChEMBL ID: {{ compound.chembl_id }}" /><br />{{ compound.chembl_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.chemspider_id %} - <a href="http://www.chemspider.com/Chemical-Structure.{{ compound.chemspider_id}}.html" target="_blank"><img + <a href="{{ compound.chemspider_url }}.html" target="_blank"><img src="/static/images/Other/ChemSpider_Logo.png" style="height: 1.5em;" title="ChemSpider ID: {{ compound.chemspider_id }}" /><br />{{ compound.chemspider_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.ligand_id %} - <a href="https://www.rcsb.org/ligand/{{ compound.ligand_id}}" target="_blank"><img + <a href="{{ compound.pdbligand_url }}" target="_blank"><img src="/static/images/Other/PDBLogo.ico" style="height: 1.5em;" title="PDB Ligand ID: {{ compound.ligand_id }}" /><br />{{ compound.ligand_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.drugbank_id %} - <a href="https://www.drugbank.ca/drugs/{{ compound.drugbank_id}}" target="_blank"><img + <a href="{{ compound.drugbank_url }}" target="_blank"><img src="/static/images/Other/DrugBankLogo.ico" style="height: 1.5em;" title="DrugBank ID: {{ compound.drugbank_id }}" /><br />{{ compound.drugbank_id }}</a> {% endif %}