[schema] First implementation of the schema
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 11 Dec 2012 13:50:25 +0100
changeset 2 8bc3c375b9e2
parent 1 f24bd8fd6032
child 3 3a04664a1b83
[schema] First implementation of the schema
schema.py
--- a/schema.py	Tue Dec 11 18:13:20 2012 +0100
+++ b/schema.py	Tue Dec 11 13:50:25 2012 +0100
@@ -16,3 +16,52 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 
 """cubicweb-brainomics schema"""
+from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation, String, RichString,
+                            Int, Float, Boolean)
+
+from cubes.questionnaire.schema import QuestionnaireRun, Questionnaire, Question
+from cubes.neuroimaging.schema import Scan, AnatomicalRegion
+from cubes.genomics.schema import GenomicMeasure, ColumnRef
+from cubes.medicalexp.schema  import Assessment, ProcessingRun, ScoreDef, ScoreValue
+
+
+ALL_MEASURES = ('GenericTestRun', 'QuestionnaireRun', 'Scan', 'GenomicMeasure')
+
+ProcessingRun.add_relation(SubjectRelation('QuestionnaireRun', cardinality='**'), name='inputs')
+ProcessingRun.add_relation(SubjectRelation('Scan', cardinality='**'), name='inputs')
+ProcessingRun.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='inputs')
+
+ProcessingRun.add_relation(SubjectRelation('QuestionnaireRun', cardinality='**'), name='outputs')
+ProcessingRun.add_relation(SubjectRelation('Scan', cardinality='**'), name='outputs')
+ProcessingRun.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='outputs')
+
+
+QuestionnaireRun.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
+Scan.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
+GenomicMeasure.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
+
+Assessment.add_relation(SubjectRelation('QuestionnaireRun', cardinality='**'), name='uses')
+Assessment.add_relation(SubjectRelation('Scan', cardinality='**'), name='uses')
+Assessment.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='uses')
+
+Assessment.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*'), name='generates')
+Assessment.add_relation(SubjectRelation('Scan', cardinality='?*'), name='generates')
+Assessment.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*'), name='generates')
+
+ScoreValue.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*'), name='measure')
+ScoreValue.add_relation(SubjectRelation('Scan', cardinality='?*'), name='measure')
+ScoreValue.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*'), name='measure')
+
+
+QuestionnaireRun.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
+Scan.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
+GenomicMeasure.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
+
+Questionnaire.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
+Scan.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
+GenomicMeasure.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
+
+Questionnaire.add_relation(SubjectRelation('ScoreDef', cardinality='*?'), name='definitions')
+ScoreDef.add_relation(SubjectRelation('Question', cardinality='**'), name='used_by')
+AnatomicalRegion.add_relation(SubjectRelation('ScoreValue', cardinality='**'), name='concerned_by')
+ColumnRef.add_relation(SubjectRelation('Assessment', cardinality='1*', inlined=True), name='assessment')