Commit 5b1c7218 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add compound links in model, fix compound bioschemas

and reuse that in the links template
bioschemas for compound fixed for links and more
WIP on #245
parent b824d2ce
......@@ -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:
......
......@@ -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"
}
......
......@@ -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 %}
......
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