Skip to content

Commit

Permalink
Support #284
Browse files Browse the repository at this point in the history
- Research interests ingested and shown on people pages
- Data sharing policy date shown on site pages
  • Loading branch information
nutjob4life committed Sep 6, 2023
1 parent b22e586 commit dd58f83
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.9 on 2023-09-01 14:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edrnsitecontent', '0030_alter_referencesetsnippet_reference_set_code_and_more'),
]

operations = [
migrations.AddField(
model_name='cdeexplorerobject',
name='stewardship',
field=models.TextField(blank=True, help_text="Who's responsible for this object"),
),
]
2 changes: 1 addition & 1 deletion src/eke.knowledge/src/eke/knowledge/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.db.models import Q
from django.db.models.functions import Lower
from django.http import HttpRequest
from django.http import HttpResponse, JsonResponse, HttpResponseBadRequest
from django.http import HttpResponse, JsonResponse
from django.http.request import QueryDict
from modelcluster.fields import ParentalKey
from wagtail.admin.panels import FieldPanel, InlinePanel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.9 on 2023-09-05 19:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ekeknowledge', '0008_site_publications'),
]

operations = [
migrations.AddField(
model_name='site',
name='dataSharingPolicy',
field=models.CharField(blank=True, help_text='When was the data sharing policy made', max_length=30),
),
]
29 changes: 29 additions & 0 deletions src/eke.knowledge/src/eke/knowledge/migrations/0010_interest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.1.9 on 2023-09-06 15:11

from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields


class Migration(migrations.Migration):

dependencies = [
('ekeknowledge', '0009_site_datasharingpolicy'),
]

operations = [
migrations.CreateModel(
name='Interest',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('name', models.CharField(default='Name', help_text='Name of the interest', max_length=500)),
('value', models.TextField(default='Description', help_text='Summary of the interest')),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='interests', to='ekeknowledge.person')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.9 on 2023-09-06 15:58

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('ekeknowledge', '0010_interest'),
]

operations = [
migrations.RenameField(
model_name='interest',
old_name='value',
new_name='description',
),
]
37 changes: 33 additions & 4 deletions src/eke.knowledge/src/eke/knowledge/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from wagtail.search import index
import dash_core_components as dcc
import dash_html_components as html
import pandas, logging, rdflib, tempfile, libgravatar
import pandas, logging, rdflib, tempfile, libgravatar, re


_logger = logging.getLogger(__name__)
Expand All @@ -43,6 +43,7 @@
_internalOrganPredicate = 'urn:internal:organ'
_surname_predicate_uri = rdflib.URIRef('http://xmlns.com/foaf/0.1/surname')
_default_person_icon = 'mp'
_data_sharing_splitter = re.compile(r'\s*(\S+)')


def get_predicate_value(uri: rdflib.URIRef, predicates: dict) -> str:
Expand Down Expand Up @@ -157,6 +158,9 @@ class Site(KnowledgeObject):
proposal = models.CharField(
blank=True, null=False, max_length=250, help_text='BDL-only proposal title that produced this site'
)
dataSharingPolicy = models.CharField(
max_length=30, blank=True, null=False, help_text='When was the data sharing policy made'
)
content_panels = KnowledgeObject.content_panels + [
FieldPanel('abbreviation'),
FieldPanel('fundingStartDate'),
Expand All @@ -166,6 +170,7 @@ class Site(KnowledgeObject):
FieldPanel('sponsor'),
FieldPanel('specialty'),
FieldPanel('proposal'),
FieldPanel('dataSharingPolicy'),
InlinePanel('organs', label='Organs'),
FieldPanel('pi'),
FieldPanel('coPIs'),
Expand All @@ -189,6 +194,9 @@ def get_context(self, request: HttpRequest, *args, **kwargs) -> dict:
context = super().get_context(request, *args, **kwargs)
context['showSponsor'] = self._shouldSponsorBeShown()

if match := _data_sharing_splitter.match(self.dataSharingPolicy):
context['dataSharingPolicy'] = match.group(1)

anointed = set()
if self.pi: anointed.add(self.pi.identifier)
for field in ('coPIs', 'coIs', 'investigators'):
Expand All @@ -200,7 +208,6 @@ def get_context(self, request: HttpRequest, *args, **kwargs) -> dict:
return context

class Meta:
# indexes = [models.Index(fields=['pubMedID']), models.Index(fields=['year'])]
pass

class RDFMeta:
Expand All @@ -213,10 +220,9 @@ class RDFMeta:
esu('url'): RDFAttribute('homePage', scalar=True),
esu('sponsor'): RelativeRDFAttribute('sponsor', scalar=True),
esu('program'): RDFAttribute('specialty', scalar=True),
esu('dataSharingPolicyDateTime'): RDFAttribute('dataSharingPolicy', scalar=True),
_interalProposalPredicate: RDFAttribute('proposal', scalar=True),
_internalOrganPredicate: RDFAttribute('organs', scalar=False),
# esu('year'): RDFAttribute('year', scalar=True, rel=False),
# str(rdflib.DCTERMS.creator): RDFAttribute('authors', scalar=False, rel=False),
**KnowledgeObject.RDFMeta.fields
}

Expand Down Expand Up @@ -308,6 +314,16 @@ def get_context(self, request: HttpRequest, *args, **kwargs) -> dict:
return context


class Interest(Orderable):
'''An interest of a person.'''
name = models.CharField(max_length=500, blank=False, null=False, default='Name', help_text='Name of the interest')
description = models.TextField(blank=False, null=False, default='Description', help_text='Summary of the interest')
page = ParentalKey(Person, on_delete=models.CASCADE, related_name='interests')
panels = [FieldPanel('value')]
def __str__(self):
return self.name


class OrganizationalGroup(Page):
'''An organizational group in EDRN consisting of a name and related sites.'''
content_panels = Page.content_panels + [InlinePanel('group_members', label='Group Members')]
Expand All @@ -333,7 +349,10 @@ class Ingestor(BaseIngestor):
_coPIPredicateURI = rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#copi')
_coIPredicateURI = rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#coi')
_iPredicateURI = rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#investigator')
_interestNamePredURI = rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#interestName')
_interestDescPredURI = rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#interestDescription')
_api_fetch_size = 20
_count_stripper = re.compile(r'^[0-9][0-9][0-9][0-9] (.*)')

def _get_dmcc_code(self, uri: rdflib.URIRef) -> str:
return urlparse(uri).path.split('/')[-1]
Expand Down Expand Up @@ -394,6 +413,15 @@ def assign_academic_degree(self, person: Person, predicates: dict):
if degrees:
person.degrees = degrees

def assign_interests(self, person: Person, predicates: dict):
names = predicates.get(self._interestNamePredURI, [])
descs = predicates.get(self._interestDescPredURI, [])
for name, desc in zip(names, descs):
name_match, desc_match = self._count_stripper.match(name), self._count_stripper.match(desc)
if name_match and desc_match:
name, desc = name_match.group(1), desc_match.group(1)
person.interests.add(Interest(name=name, description=desc))

def _compute_search_promotion_for_person(self, name: str, predicates: dict) -> str:
title = get_predicate_value(rdflib.URIRef(esu('edrnTitle')), predicates)
if not title:
Expand Down Expand Up @@ -446,6 +474,7 @@ def create_person(self, sites, uri: str, predicates: dict) -> Person:
modelField = person._meta.get_field(rdfAttribute.name)
rdfAttribute.modify_field(person, values, modelField, predicates)
self.assign_academic_degree(person, predicates)
self.assign_interests(person, predicates)
try:
site.add_child(instance=person)
person.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>Open Protocols</h3>
<small>This person has no open protocols at the present moment.</small>
{% endif %}

<h3>Closed Protocols</h3>
<h3 class='mt-3'>Closed Protocols</h3>
{% if closed %}
<table class='table'>
<thead><tr><th>Protocol Name</th><th>Biomarkers</th><th>Datasets</th></tr></thead>
Expand All @@ -42,7 +42,7 @@ <h3>Closed Protocols</h3>
<small>This person has no closed protocols at the present moment.</small>
{% endif %}

<h3>Publications</h3>
<h3 class='mt-3'>Publications</h3>
{% if publications %}
<table class='table'>
<thead><tr><th>Publication Name</th><th>PubMed ID</th><th>Journal</th></tr></thead>
Expand All @@ -60,6 +60,18 @@ <h3>Publications</h3>
<small>No publications found at the present moment.</small>
{% endif %}

<h3 class='mt-3'>Interests</h3>
{% if page.interests %}
<dl>
{% for interest in page.interests.all %}
<dt>{{interest.name}}</dt>
<dd>{{interest.description}}</dd>
{% endfor %}
</dl>
{% else %}
<small>No interests found at the present moment.</small>
{% endif %}

<small>
To update protocols, publications, biomarkers, or science data, please contact the
<a href='mailto:[email protected]'>Informatics Center</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<dt>Sponsor</dt>
<dd><a href='{{page.sponsor.url}}'>{{page.sponsor.title}}</a></dd>
{% endif %}
{% if page.dataSharingPolicy %}
<dt>Data Sharing Policy Date/Time</dt>
<dd>{{page.dataSharingPolicy}}</dd>
{% endif %}
</dl>
<h3>People</h3>
<dl class='row'>
Expand Down

0 comments on commit dd58f83

Please sign in to comment.