Skip to content

Commit

Permalink
Support #25
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Feb 13, 2024
1 parent 7a0c54c commit 2c3670e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/edrn.rdf/edrn/rdf/dmccprotocolrdfgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
from .utils import parseTokens, validateAccessibleURL, DEFAULT_VERIFICATION_NUM, splitDMCCRows
from rdflib.term import URIRef, Literal
from zope import schema
import rdflib
import rdflib, logging


_logger = logging.getLogger(__name__)

_siteRoles = {
'1': 'Funding Source',
Expand All @@ -24,7 +27,7 @@
'7': 'Analysis Lab',
'8': 'Statistical Services',
'9': 'Consultant',
'97': 'Other, Specify',
'97': 'Other',
}

_reportingStages = {
Expand All @@ -40,7 +43,7 @@
'10': 'Publication Stage',
'11': 'Statistical Analysis Stage',
'12': 'Completed',
'97': 'Other, specify',
'97': 'Other',
}

_fieldsOfResearch = {
Expand All @@ -51,7 +54,7 @@
'5': 'Nanotechnology',
'6': 'Metabolomics',
'7': 'Hypermethylation',
'9': 'Other, Specify',
'9': 'Other',
}


Expand Down Expand Up @@ -400,6 +403,7 @@ def addToGraph(self, graph, context):
predicateURI = URIRef(getattr(context, attrName))
graph.add((subjectURI, predicateURI, Literal(value)))


_specificsPredicates = {
'animalTraining': 'animalSubjectTrainingReceivedURI',
'humanTraining': 'humanSubjectTrainingReceivedURI',
Expand Down Expand Up @@ -431,7 +435,6 @@ def addToGraph(self, graph, context):
'Protocol_or_Project_Flag': 'projectFlagURI',
'Protocol_Results_Outcome': 'outcomeURI',
'Protocol_Results_Outcome_Secure_Site': 'secureOutcomeURI',
'Protocol_Type': 'protocolTypeURI',
'Sample_Size_Final': 'finalSampleSizeURI',
'Sample_Size_Planned': 'plannedSampleSizeURI',
}
Expand Down Expand Up @@ -496,7 +499,14 @@ def _addCancerTypes(self, graph, context):
value = value.strip()
if value:
graph.add((subjectURI, predicateURI, URIRef(context.cancerTypeURIPrefix + value)))
def _addProtocolType(self, graph, context):
subjectURI = self.getSubjectURI(context)
kind = self.slots.get('Protocol_Type')
if not kind: return
kind = 'Other' if kind == 'Other specify' else kind
graph.add((subjectURI, URIRef(context.protocolTypeURI), Literal(kind)))
def addToGraph(self, graph, specifics, context):
self._addProtocolType(graph, context)
self._addInvolvedInvestigatorSites(graph, specifics, context)
self._addOtherSites(graph, context)
self._addPublications(graph, context)
Expand Down Expand Up @@ -538,7 +548,7 @@ def __getattr__(self, key):
'is a pilot for': 'isAPilotForURI',
'obtains data from': 'obtainsDataFromURI',
'obtains specimens from': 'obtainsSpecimensFromURI',
'Other, specify': 'hasOtherRelationshipURI',
'Other': 'hasOtherRelationshipURI',
'provides data to': 'providesDataToURI',
}

Expand Down Expand Up @@ -586,6 +596,7 @@ def getSlottedItems(self, operation, kind):
objects[value] = obj
elif key == 'slot':
lastSlot = value
_logger.warning('Slot = %s', lastSlot)
elif key == 'value':
if lastSlot is None:
raise ValueError('Value with no preceding slot in row "%r"' % row)
Expand Down

0 comments on commit 2c3670e

Please sign in to comment.