[schema] Rename ScoreDef in ScoreDefinition, closes #2823726
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 16 Jul 2013 13:20:34 +0200
changeset 288 f0b9e4864e72
parent 287 8e4a9904d73f
child 289 41b25c4f7519
[schema] Rename ScoreDef in ScoreDefinition, closes #2823726
__init__.py
importers/abide.py
importers/imagen.py
importers/localizer.py
importers/random.py
schema.py
views/download.py
views/primary.py
--- a/__init__.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/__init__.py	Tue Jul 16 13:20:34 2013 +0200
@@ -6,4 +6,4 @@
 ALL_MEASURES = ('GenericMeasure', 'QuestionnaireRun', 'GenericTestRun', 'Scan', 'GenomicMeasure')
 COMMENTED_ENTITIES = ('Study', 'Subject', 'Center', 'Device', 'Scan', 'GenomicMeasure',
                       'QuestionnaireRun', 'Questionnaire', 'Question')
-WIKI_ENTITIES = ('Question', 'Questionnaire', 'Study', 'ScoreDef')
+WIKI_ENTITIES = ('Question', 'Questionnaire', 'Study', 'ScoreDefinition')
--- a/importers/abide.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/importers/abide.py	Tue Jul 16 13:20:34 2013 +0200
@@ -57,38 +57,38 @@
 def create_score_defs(store):
     score_defs = {}
     # Various scores
-    score_defs['dx_group'] = store.create_entity('ScoreDef', name=u'Diagnostic Group',
+    score_defs['dx_group'] = store.create_entity('ScoreDefinition', name=u'Diagnostic Group',
                                                   category=u'biological', type=u'numerical',
                                                   possible_values=u'1 = Autism; 2 = Control').eid
-    score_defs['dsm_iv_tr'] = store.create_entity('ScoreDef', name=u'DSM-IV-TR Diagnostic Category',
+    score_defs['dsm_iv_tr'] = store.create_entity('ScoreDefinition', name=u'DSM-IV-TR Diagnostic Category',
                                                   category=u'biological', type=u'numerical',
                                                   possible_values=u'0 = Control; 1 = Autism; 2 = Aspergers; 3 = PDD-NOS; 4 = Aspergers or PDD-NOS').eid
-    score_defs['handedness_score'] = store.create_entity('ScoreDef', name=u'Subject Handedness Score',
+    score_defs['handedness_score'] = store.create_entity('ScoreDefinition', name=u'Subject Handedness Score',
                                                          category=u'biological', type=u'numerical',
                                                          possible_values=u'Positive number = Right;\
                                                          Negative number = Left; 0 = Ambidextrous').eid
-    score_defs['scq_total'] = store.create_entity('ScoreDef', name=u'Social Communication Questionnaire Total',
+    score_defs['scq_total'] = store.create_entity('ScoreDefinition', name=u'Social Communication Questionnaire Total',
                                                   category=u'behavioral', type=u'numerical',
                                                   possible_values=u'0-39').eid
-    score_defs['aq_total'] = store.create_entity('ScoreDef', name=u'Total Raw Score of the Autism Quotient',
+    score_defs['aq_total'] = store.create_entity('ScoreDefinition', name=u'Total Raw Score of the Autism Quotient',
                                                   category=u'behavioral', type=u'numerical',
                                                   possible_values=u'0-50').eid
-    score_defs['comorbidity'] = store.create_entity('ScoreDef', name=u'Any other comorbidities ?',
+    score_defs['comorbidity'] = store.create_entity('ScoreDefinition', name=u'Any other comorbidities ?',
                                                     category=u'biological', type=u'string').eid
-    score_defs['current_med_status'] = store.create_entity('ScoreDef', name=u'Currently Taking Medications ?',
+    score_defs['current_med_status'] = store.create_entity('ScoreDefinition', name=u'Currently Taking Medications ?',
                                                            category=u'biological', type=u'numerical',
                                                            possible_values=u'0 = not taking medication; 1 = taking medication').eid
-    score_defs['medication_name'] = store.create_entity('ScoreDef', name=u'Active ingredient of any current psychoactive medications',
+    score_defs['medication_name'] = store.create_entity('ScoreDefinition', name=u'Active ingredient of any current psychoactive medications',
                                                         category=u'biological', type=u'string').eid
-    score_defs['off_stimulants_at_scan'] = store.create_entity('ScoreDef', name=u'Off stimulants 24 hours prior to scan ?',
+    score_defs['off_stimulants_at_scan'] = store.create_entity('ScoreDefinition', name=u'Off stimulants 24 hours prior to scan ?',
                                                                category=u'biological', type=u'numerical',
                                                                possible_values=u'0 = no; 1 = yes').eid
-    score_defs['eye_status_at_scan'] = store.create_entity('ScoreDef', name=u'Eye Status During Rest Scan',
+    score_defs['eye_status_at_scan'] = store.create_entity('ScoreDefinition', name=u'Eye Status During Rest Scan',
                                                                category=u'behavioral', type=u'numerical',
                                                                possible_values=u'1 = open; 2 = closed').eid
-    score_defs['age_at_mprage'] = store.create_entity('ScoreDef', name=u'Age at Anatomical Scan in years',
+    score_defs['age_at_mprage'] = store.create_entity('ScoreDefinition', name=u'Age at Anatomical Scan in years',
                                                                category=u'biological', type=u'numerical').eid
-    score_defs['bmi'] = store.create_entity('ScoreDef', name=u'Body Mass Index',
+    score_defs['bmi'] = store.create_entity('ScoreDefinition', name=u'Body Mass Index',
                                             category=u'biological', type=u'numerical').eid
 
     # FIQ/VIQ/PIQ scores
@@ -98,7 +98,7 @@
                       u'WISC_III', u'WISC_III_DUTCH', u'WISC_IV_4_SUBTESTS',
                       u'WISCC_IV_FULL', u'WST'):
         name = u'FIQ Standard Score - %s' % test_type
-        score_defs['fiq_%s' % test_type.lower()] = store.create_entity('ScoreDef', name=name,
+        score_defs['fiq_%s' % test_type.lower()] = store.create_entity('ScoreDefinition', name=name,
                                                                        category=u'FIQ',
                                                                        type=u'numerical').eid
     for test_type in (u'DAS_II_SA', u'GIT', u'HAWIK', u'PPVT', u'WAIS_III', u'WASI',
@@ -107,7 +107,7 @@
                       u'WISC_III', u'WISC_III_DUTCH', u'WISC_IV_4_SUBTESTS',
                       u'WISCC_IV_FULL', u'WST'):
         name = u'VIQ Standard Score - %s' % test_type
-        score_defs['viq_%s' % test_type.lower()] = store.create_entity('ScoreDef', name=name,
+        score_defs['viq_%s' % test_type.lower()] = store.create_entity('ScoreDefinition', name=name,
                                                                        category=u'VIQ',
                                                                        type=u'numerical').eid
     for test_type in (u'DAS_II_SA', u'GIT', u'HAWIK', u'RAVENS', u'WAIS_III', u'WASI',
@@ -116,7 +116,7 @@
                       u'WISC_III', u'WISC_III_DUTCH', u'WISC_IV_4_SUBTESTS',
                       u'WISCC_IV_FULL', u'WST'):
         name = u'PIQ Standard Score - %s' % test_type
-        score_defs['piq_%s' % test_type.lower()] = store.create_entity('ScoreDef', name=name,
+        score_defs['piq_%s' % test_type.lower()] = store.create_entity('ScoreDefinition', name=name,
                                                                        category=u'PIQ',
                                                                        type=u'numerical').eid
     return score_defs
--- a/importers/imagen.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/importers/imagen.py	Tue Jul 16 13:20:34 2013 +0200
@@ -309,7 +309,7 @@
     if name in SCORE_DEFS:
         entity_eid = SCORE_DEFS[name]
     else:
-        entity = store.create_entity('ScoreDef', name=name,
+        entity = store.create_entity('ScoreDefinition', name=name,
                                      category=category, type=_type,
                                      unit=unit, possible_values=possible_values)
         SCORE_DEFS[name] = entity.eid
@@ -1160,7 +1160,7 @@
 DEVICES = dict(session.execute('Any I, X WHERE X is Device, X name I'))
 STUDIES = dict(session.execute('Any I, X WHERE X is Study, X name I'))
 GENERIC_TESTS = dict(session.execute('Any I, X WHERE X is GenericTest, X identifier I'))
-SCORE_DEFS = dict(session.execute('Any I, X WHERE X is ScoreDef, X name I'))
+SCORE_DEFS = dict(session.execute('Any I, X WHERE X is ScoreDefinition, X name I'))
 INVESTIGATORS = dict(session.execute('Any I, X WHERE X is Investigator, X identifier I'))
 EXPERIMENTS = dict(session.execute('Any I, X WHERE X is IN (Questionnaire, GenericTest), X identifier I'))
 QUESTIONS = dict(session.execute('Any I, X WHERE X is Question, X identifier I'))
@@ -1208,7 +1208,7 @@
     store.flush()
     store.commit()
     # Update gender - Take gender from the QR
-    rset = rql('Any S, V WHERE SD is ScoreDef, SD category %(c)s, SD name %(n)s, SV definition SD, '
+    rset = rql('Any S, V WHERE SD is ScoreDefinition, SD category %(c)s, SD name %(n)s, SV definition SD, '
                'SV measure M, M concerns S, SV text V',
                {'n': 'Adolescent_Gender', 'c': 'qualityreport'})
     for seid, g in rset:
--- a/importers/localizer.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/importers/localizer.py	Tue Jul 16 13:20:34 2013 +0200
@@ -411,7 +411,7 @@
                 score_def['name'] = score_val['name']
                 score_def['category'] = u'demographics'
                 score_def['type'] = u'string'
-                score_def = store.create_entity('ScoreDef', **score_def)
+                score_def = store.create_entity('ScoreDefinition', **score_def)
                 score_defs[score_val['name']] = score_def.eid
                 def_eid = score_def.eid
             score_val = store.create_entity('ScoreValue', definition=def_eid,
--- a/importers/random.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/importers/random.py	Tue Jul 16 13:20:34 2013 +0200
@@ -252,12 +252,12 @@
 ###############################################################################
 score_defs = {}
 possible_values = u'0 = Control; 1 = Autism; 2 = Aspergers; 3 = PDD-NOS; 4 = Aspergers or PDD-NOS'
-score_defs['dsm_iv_tr'] = (store.create_entity('ScoreDef', name=u'DSM-IV-TR Diagnostic Category', category=u'biological', type=u'numerical', possible_values=possible_values).eid, 0, 4)
-score_defs['scq_total'] = (store.create_entity('ScoreDef', name=u'Social Communication Questionnaire Total', category=u'behavioral', type=u'numerical', possible_values=u'0-39').eid, 0, 39)
-score_defs['aq_total'] = (store.create_entity('ScoreDef', name=u'Total Raw Score of the Autism Quotient', category=u'behavioral', type=u'numerical', possible_values=u'0-50').eid, 0, 50)
-score_defs['fiq_WASI'] = (store.create_entity('ScoreDef', name=u'FIQ Standard Score - WASI', category=u'FIQ', type=u'numerical').eid, 50, 160)
-score_defs['viq_WASI'] = (store.create_entity('ScoreDef', name=u'VIQ Standard Score - WASI', category=u'VIQ', type=u'numerical').eid, 55, 160)
-score_defs['piq_WASI'] = (store.create_entity('ScoreDef', name=u'PIQ Standard Score - WASI', category=u'PIQ', type=u'numerical').eid, 53, 160)
+score_defs['dsm_iv_tr'] = (store.create_entity('ScoreDefinition', name=u'DSM-IV-TR Diagnostic Category', category=u'biological', type=u'numerical', possible_values=possible_values).eid, 0, 4)
+score_defs['scq_total'] = (store.create_entity('ScoreDefinition', name=u'Social Communication Questionnaire Total', category=u'behavioral', type=u'numerical', possible_values=u'0-39').eid, 0, 39)
+score_defs['aq_total'] = (store.create_entity('ScoreDefinition', name=u'Total Raw Score of the Autism Quotient', category=u'behavioral', type=u'numerical', possible_values=u'0-50').eid, 0, 50)
+score_defs['fiq_WASI'] = (store.create_entity('ScoreDefinition', name=u'FIQ Standard Score - WASI', category=u'FIQ', type=u'numerical').eid, 50, 160)
+score_defs['viq_WASI'] = (store.create_entity('ScoreDefinition', name=u'VIQ Standard Score - WASI', category=u'VIQ', type=u'numerical').eid, 55, 160)
+score_defs['piq_WASI'] = (store.create_entity('ScoreDefinition', name=u'PIQ Standard Score - WASI', category=u'PIQ', type=u'numerical').eid, 53, 160)
 
 
 store.flush()
--- a/schema.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/schema.py	Tue Jul 16 13:20:34 2013 +0200
@@ -23,7 +23,7 @@
 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
+from cubes.medicalexp.schema  import Assessment, ProcessingRun, ScoreDefinition, ScoreValue
 
 from cubes.brainomics import COMMENTED_ENTITIES, WIKI_ENTITIES
 
@@ -78,8 +78,8 @@
 GenomicMeasure.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
 
 # Various relations
-Questionnaire.add_relation(SubjectRelation('ScoreDef', cardinality='*?'), name='definitions')
-ScoreDef.add_relation(SubjectRelation('Question', cardinality='**'), name='used_by')
+Questionnaire.add_relation(SubjectRelation('ScoreDefinition', cardinality='*?'), name='definitions')
+ScoreDefinition.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')
 
--- a/views/download.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/views/download.py	Tue Jul 16 13:20:34 2013 +0200
@@ -29,7 +29,7 @@
 from cubicweb.web.views.csvexport import CSVRsetView
 
 
-CSV_DOWNLOADABLE = ('Subject', 'Scan', 'ScoreDef', 'QuestionnaireRun',
+CSV_DOWNLOADABLE = ('Subject', 'Scan', 'ScoreDefinition', 'QuestionnaireRun',
                     'Answer', 'GenomicMeasure', 'Snp')
 XCEDE_DOWNLOADABLE = ('Subject', 'Scan', 'GenomicMeasure', 'QuestionnaireRun', 'Questionnaire')
 ZIP_DOWNLOADABLE = ('Scan', 'GenomicMeasure')
@@ -148,9 +148,9 @@
         # Register the anon view if do not allow anon download
         vreg.register(DataZipAnonymousView)
         # Change CSV views selector
-        from cubes.medicalexp.views.csvexport import SubjectCSVView, ScoreDefCSVView
+        from cubes.medicalexp.views.csvexport import SubjectCSVView, ScoreDefinitionCSVView
         SubjectCSVView.__select__ = SubjectCSVView.__select__ & ~anonymous_user()
-        ScoreDefCSVView.__select__ = ScoreDefCSVView.__select__ & ~anonymous_user()
+        ScoreDefinitionCSVView.__select__ = ScoreDefinitionCSVView.__select__ & ~anonymous_user()
         from cubes.genomics.views.csvexport import GenomicMeasureCSVView
         GenomicMeasureCSVView = GenomicMeasureCSVView.__select__ & ~anonymous_user()
         from cubes.neuroimaging.views.csvexport import ScanCSVView
--- a/views/primary.py	Wed Jul 17 12:19:46 2013 +0200
+++ b/views/primary.py	Tue Jul 16 13:20:34 2013 +0200
@@ -283,8 +283,8 @@
 ###############################################################################
 ### SCOREDEF ##################################################################
 ###############################################################################
-class ScoreDefPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('ScoreDef')
+class ScoreDefinitionPrimaryView(BrainomicsPrimaryView):
+    __select__ = BrainomicsPrimaryView.__select__ & is_instance('ScoreDefinition')
 
     def iterate_attributes(self, entity):
         return [(self._cw._('Name'), entity.name),