[importer] Update Random importer with schema changes
authorVincent Michel <vincent.michel@logilab.fr>
Fri, 18 Oct 2013 13:41:29 +0000
changeset 393 1a9ca68f34d7
parent 392 9866372aed84
child 394 ae247a2bc0ee
[importer] Update Random importer with schema changes
importers/random_import.py
--- a/importers/random_import.py	Fri Sep 20 17:22:59 2013 +0000
+++ b/importers/random_import.py	Fri Oct 18 13:41:29 2013 +0000
@@ -27,6 +27,19 @@
 
 
 ###############################################################################
+### DATA GENERATION CONFIGURATION #############################################
+###############################################################################
+NB_SUBJECTS = 10000
+NB_SUBJECTS_GROUPS = 5
+AGE_DATETIMES = (datetime.strptime('1/1/1930 1:30 PM', '%m/%d/%Y %I:%M %p'),
+                 datetime.strptime('1/1/1990 4:50 AM', '%m/%d/%Y %I:%M %p'))
+PROJECT_DATETIMES = (datetime.strptime('1/1/2010 1:30 PM', '%m/%d/%Y %I:%M %p'),
+                     datetime.strptime('1/1/2013 4:50 AM', '%m/%d/%Y %I:%M %p'))
+SEX = {0: u'male', 1: u'female'}
+HANDEDNESS = {0: u'right', 1: u'left', 2: u'ambidextrous', 3: u'mixed'}
+
+
+###############################################################################
 ### UTILITY FUNCTIONS #########################################################
 ###############################################################################
 def random_date(_type=None):
@@ -155,239 +168,227 @@
 ###############################################################################
 ### IMPORT ####################################################################
 ###############################################################################
-parser = OptionParser()
-parser.add_option("-c", "--chromosomes", dest="chromosomes",
-                  help="Json file of chromosomes")
-parser.add_option("-g", "--genes", dest="genes",
-                  help="Json file of genes")
-parser.add_option("-s", "--snps", dest="snps",
-                  help="Json file of snps")
-(options, args) = parser.parse_args(__args__)
-
-store = SQLGenObjectStore(session)
-
+if __name__ == '__main__':
+    parser = OptionParser()
+    parser.add_option("-c", "--chromosomes", dest="chromosomes",
+                      help="Json file of chromosomes")
+    parser.add_option("-g", "--genes", dest="genes",
+                      help="Json file of genes")
+    parser.add_option("-s", "--snps", dest="snps",
+                      help="Json file of snps")
+    (options, args) = parser.parse_args(__args__)
 
-###############################################################################
-### DATA GENERATION CONFIGURATION #############################################
-###############################################################################
-NB_SUBJECTS = 10000
-NB_SUBJECTS_GROUPS = 5
-AGE_DATETIMES = (datetime.strptime('1/1/1930 1:30 PM', '%m/%d/%Y %I:%M %p'),
-                 datetime.strptime('1/1/1990 4:50 AM', '%m/%d/%Y %I:%M %p'))
-PROJECT_DATETIMES = (datetime.strptime('1/1/2010 1:30 PM', '%m/%d/%Y %I:%M %p'),
-                     datetime.strptime('1/1/2013 4:50 AM', '%m/%d/%Y %I:%M %p'))
-SEX = {0: u'male', 1: u'female'}
-HANDEDNESS = {0: u'right', 1: u'left', 2: u'ambidextrous', 3: u'mixed'}
+    store = SQLGenObjectStore(session)
 
 
-###############################################################################
-### GENETICS DATA #############################################################
-###############################################################################
-platform = None
-if options.chromosomes:
-    chrs = import_chromosomes(options.chromosomes)
-    chr_map = {}
-    for _chr in chrs:
-        print 'chr', _chr['name']
-        _chr = store.create_entity('Chromosome', **_chr)
-        chr_map.setdefault(_chr['name'], _chr.eid)
-    store.flush()
-    if options.genes:
-        genes = import_genes(options.chromosomes, options.genes)
-        for gene in genes:
-            print 'gene', gene['name'], gene['chromosome']
-            gene['chromosome'] = chr_map[gene['chromosome']]
-            gene = store.create_entity('Gene', **gene)
-        store.flush()
-    if options.snps:
-        snps = import_snps(options.chromosomes, options.snps)
-        snp_eids = []
-        for ind, snp in enumerate(snps):
-            print 'snp', snp['rs_id']
-            snp['chromosome'] = chr_map[snp['chromosome']]
-            snp = store.create_entity('Snp', **snp)
-            snp_eids.append(snp.eid)
-            if ind and ind % 100000 == 0:
-                store.flush()
+    ###############################################################################
+    ### GENETICS DATA #############################################################
+    ###############################################################################
+    platform = None
+    if options.chromosomes:
+        chrs = import_chromosomes(options.chromosomes)
+        chr_map = {}
+        for _chr in chrs:
+            print 'chr', _chr['name']
+            _chr = store.create_entity('Chromosome', **_chr)
+            chr_map.setdefault(_chr['name'], _chr.eid)
         store.flush()
-    # Platform
-    platform = {'identifier': 'Affymetrix_6.0'}
-    platform = store.create_entity('GenomicPlatform', **platform).eid
-    for snp_eid in snp_eids:
-        store.relate(platform, 'related_snps', snp_eid)
-    store.flush()
+        if options.genes:
+            genes = import_genes(options.chromosomes, options.genes)
+            for gene in genes:
+                print 'gene', gene['name'], gene['chromosome']
+                gene['chromosome'] = chr_map[gene['chromosome']]
+                gene = store.create_entity('Gene', **gene)
+            store.flush()
+        if options.snps:
+            snps = import_snps(options.chromosomes, options.snps)
+            snp_eids = []
+            for ind, snp in enumerate(snps):
+                print 'snp', snp['rs_id']
+                snp['chromosome'] = chr_map[snp['chromosome']]
+                snp = store.create_entity('Snp', **snp)
+                snp_eids.append(snp.eid)
+                if ind and ind % 100000 == 0:
+                    store.flush()
+            store.flush()
+        # Platform
+        platform = {'identifier': 'Affymetrix_6.0'}
+        platform = store.create_entity('GenomicPlatform', **platform).eid
+        for snp_eid in snp_eids:
+            store.relate(platform, 'related_snps', snp_eid)
+        store.flush()
 
-###############################################################################
-### STUDY/PI/CENTERS ##########################################################
-###############################################################################
-study = store.create_entity('Study', name=u'Demo study',
-                            data_filepath=u'/tmp/demo_data',
-                            description=u'Demo study with random data',
-                            keywords=u'demo;random;semantic').eid
-pi_1 = store.create_entity('Investigator', identifier=u'pi_1',
-                           firstname=u'Angus', lastname=u'Young', title=u'PhD',
-                           institution=u'Research Center', department=u'Cognitive Sciences').eid
-pi_2 = store.create_entity('Investigator', identifier=u'pi_2',
-                           firstname=u'Malcom', lastname=u'Young', title=u'MD',
-                           institution=u'Research Center', department=u'Cognitive Sciences').eid
-pi_3 = store.create_entity('Investigator', identifier=u'pi_3',
-                           firstname=u'Brian', lastname=u'Jonhson', title=u'PhD',
-                           institution=u'Research Center', department=u'IT').eid
-pi_4 = store.create_entity('Investigator', identifier=u'pi_4',
-                           firstname=u'Phil', lastname=u'Rudd', title=u'PhD',
-                           institution=u'Research Center', department=u'IT').eid
-center = store.create_entity('Center', identifier=u'center', name=u'Demo center',
-                             department=u'Medical research', city=u'Paris',
-                             country=u'France').eid
-mri_1 = store.create_entity('Device', name=u'Magnetom', model=u'Trio',
-                            manufacturer=u'Siemens',
-                            serialnum=1234, hosted_by=center).eid
-mri_2 = store.create_entity('Device', name=u'Ingenia', model=u'3.0 T',
-                            manufacturer=u'Philips',
-                            serialnum=4321, hosted_by=center).eid
+    ###############################################################################
+    ### STUDY/PI/CENTERS ##########################################################
+    ###############################################################################
+    study = store.create_entity('Study', name=u'Demo study',
+                                data_filepath=u'/tmp/demo_data',
+                                description=u'Demo study with random data',
+                                keywords=u'demo;random;semantic').eid
+    pi_1 = store.create_entity('Investigator', identifier=u'pi_1',
+                               firstname=u'Angus', lastname=u'Young', title=u'PhD',
+                               institution=u'Research Center', department=u'Cognitive Sciences').eid
+    pi_2 = store.create_entity('Investigator', identifier=u'pi_2',
+                               firstname=u'Malcom', lastname=u'Young', title=u'MD',
+                               institution=u'Research Center', department=u'Cognitive Sciences').eid
+    pi_3 = store.create_entity('Investigator', identifier=u'pi_3',
+                               firstname=u'Brian', lastname=u'Jonhson', title=u'PhD',
+                               institution=u'Research Center', department=u'IT').eid
+    pi_4 = store.create_entity('Investigator', identifier=u'pi_4',
+                               firstname=u'Phil', lastname=u'Rudd', title=u'PhD',
+                               institution=u'Research Center', department=u'IT').eid
+    center = store.create_entity('Center', identifier=u'center', name=u'Demo center',
+                                 department=u'Medical research', city=u'Paris',
+                                 country=u'France').eid
+    mri_1 = store.create_entity('Device', name=u'Magnetom', model=u'Trio',
+                                manufacturer=u'Siemens',
+                                serialnum=1234, hosted_by=center).eid
+    mri_2 = store.create_entity('Device', name=u'Ingenia', model=u'3.0 T',
+                                manufacturer=u'Philips',
+                                serialnum=4321, hosted_by=center).eid
 
 
-###############################################################################
-### SCOREDEFS #################################################################
-###############################################################################
-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('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)
+    ###############################################################################
+    ### SCOREDEFS #################################################################
+    ###############################################################################
+    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('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()
+    store.flush()
 
 
-###############################################################################
-### QUESTIONNAIRES ############################################################
-###############################################################################
-# ADOS
-name = u'Autism Diagnostic Observation Schedule Module (ADOS)'
-ados_questionnaire_eid = store.create_entity('Questionnaire', name=name, language=u'en', version=u'v 0.2.1', identifier=u'ados', type=u'behavioral').eid
-ados_questions = {}
-text = u'Autism Diagnostic Observation Schedule Module'
-ados_questions['ados_module'] = (store.create_entity('Question', identifier=u'ados_module', position=0, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'1-4').eid, 1, 4)
-text = u'Classical Total ADOS Score (Communication subscore + Social Interaction subscore)'
-ados_questions['ados_total'] = (store.create_entity('Question', identifier=u'ados_total', position=1, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-22').eid, 0, 22)
-text = u'Communication Total Subscore of the Classic ADOS'
-ados_questions['ados_comm'] = (store.create_entity('Question', identifier=u'ados_comm', position=2, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
-text = u'Social Total Subscore of the Classic ADOS'
-ados_questions['ados_social'] = (store.create_entity('Question', identifier=u'ados_social', position=3, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-14').eid, 0, 14)
-text = u'Stereotyped Behaviors and Restricted Interests Total Subscore of the Classic ADOS'
-ados_questions['ados_stereo_behav'] = (store.create_entity('Question', identifier=u'ados_stereo_behav', position=4, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
-text = u'Was ADOS scored and administered by research reliable personnel?'
-possible_answers = u'0 = not research reliable; 1 = research reliable'
-ados_questions['ados_rsrch_reliable'] = (store.create_entity('Question', identifier=u'ados_rsrch_reliable', position=5, text=text, type=u'boolean', questionnaire=ados_questionnaire_eid, possible_answers=possible_answers).eid, 0, 1)
-text = u'Social Affect Total Subscore for Gotham Algorithm of the ADOS'
-ados_questions['ados_gotham_soc_affect'] = (store.create_entity('Question', identifier=u'ados_gotham_soc_affect', position=6, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-20').eid, 0, 20)
-text = u'Restrictive and Repetitive Behaviors Total Subscore for Gotham Algorithm of the ADOS'
-ados_questions['ados_gotham_rrb'] = (store.create_entity('Question', identifier=u'ados_gotham_rrb', position=7, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
-text = u'Social Affect Total + Restricted and Repetitive Behaviors Total'
-ados_questions['ados_gotham_total'] = (store.create_entity('Question', identifier=u'ados_gotham_total', position=8, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-28').eid, 0, 28)
-text = u'Individually Calibrated Severity Score for Gotham Algorithm of the ADOS'
-ados_questions['ados_gotham_severity'] = (store.create_entity('Question', identifier=u'ados_gotham_severity', position=9, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'1-10').eid, 1, 10)
+    ###############################################################################
+    ### QUESTIONNAIRES ############################################################
+    ###############################################################################
+    # ADOS
+    name = u'Autism Diagnostic Observation Schedule Module (ADOS)'
+    ados_questionnaire_eid = store.create_entity('Questionnaire', name=name, language=u'en', version=u'v 0.2.1', identifier=u'ados', type=u'behavioral').eid
+    ados_questions = {}
+    text = u'Autism Diagnostic Observation Schedule Module'
+    ados_questions['ados_module'] = (store.create_entity('Question', identifier=u'ados_module', position=0, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'1-4').eid, 1, 4)
+    text = u'Classical Total ADOS Score (Communication subscore + Social Interaction subscore)'
+    ados_questions['ados_total'] = (store.create_entity('Question', identifier=u'ados_total', position=1, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-22').eid, 0, 22)
+    text = u'Communication Total Subscore of the Classic ADOS'
+    ados_questions['ados_comm'] = (store.create_entity('Question', identifier=u'ados_comm', position=2, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
+    text = u'Social Total Subscore of the Classic ADOS'
+    ados_questions['ados_social'] = (store.create_entity('Question', identifier=u'ados_social', position=3, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-14').eid, 0, 14)
+    text = u'Stereotyped Behaviors and Restricted Interests Total Subscore of the Classic ADOS'
+    ados_questions['ados_stereo_behav'] = (store.create_entity('Question', identifier=u'ados_stereo_behav', position=4, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
+    text = u'Was ADOS scored and administered by research reliable personnel?'
+    possible_answers = u'0 = not research reliable; 1 = research reliable'
+    ados_questions['ados_rsrch_reliable'] = (store.create_entity('Question', identifier=u'ados_rsrch_reliable', position=5, text=text, type=u'boolean', questionnaire=ados_questionnaire_eid, possible_answers=possible_answers).eid, 0, 1)
+    text = u'Social Affect Total Subscore for Gotham Algorithm of the ADOS'
+    ados_questions['ados_gotham_soc_affect'] = (store.create_entity('Question', identifier=u'ados_gotham_soc_affect', position=6, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-20').eid, 0, 20)
+    text = u'Restrictive and Repetitive Behaviors Total Subscore for Gotham Algorithm of the ADOS'
+    ados_questions['ados_gotham_rrb'] = (store.create_entity('Question', identifier=u'ados_gotham_rrb', position=7, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-8').eid, 0, 8)
+    text = u'Social Affect Total + Restricted and Repetitive Behaviors Total'
+    ados_questions['ados_gotham_total'] = (store.create_entity('Question', identifier=u'ados_gotham_total', position=8, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'0-28').eid, 0, 28)
+    text = u'Individually Calibrated Severity Score for Gotham Algorithm of the ADOS'
+    ados_questions['ados_gotham_severity'] = (store.create_entity('Question', identifier=u'ados_gotham_severity', position=9, text=text, type=u'numerical', questionnaire=ados_questionnaire_eid, possible_answers=u'1-10').eid, 1, 10)
 
-# VINELAND
-vineland_questionnaire_eid = store.create_entity('Questionnaire', name=u'Vineland Adaptive Behavior Scales', identifier=u'vineland', language=u'fr', version=u'v 0.1.0', type=u'behavioral').eid
-vineland_questions = {}
-text = u'Vineland Adaptive Behavior Scales Receptive Language V Scaled Score'
-vineland_questions['vineland_receptive_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_receptive_v_scaled', position=0, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Expressive Language V Scaled Score'
-vineland_questions['vineland_expressive_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_expressive_v_scaled', position=1, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Written Language V Scaled Score'
-vineland_questions['vineland_written_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_written_v_scaled', position=2, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Communication Standard Score'
-vineland_questions['vineland_communication_standard'] = (store.create_entity('Question', identifier=u'vineland_communication_standard', position=3, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
-text = u'Vineland Adaptive Behavior Scales Personal Daily Living Skills V Scaled Score'
-vineland_questions['vineland_personal_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_personal_v_scaled', position=4, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Domestic Daily Living Skills V Scaled Score'
-vineland_questions['vineland_domestic_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_domestic_v_scaled', position=5, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Community Daily Living Skills V Scaled Score'
-vineland_questions['vineland_community_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_community_v_scaled', position=6, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Daily Living Skills Standard Score'
-vineland_questions['vineland_dailylvng_standard'] = (store.create_entity('Question', identifier=u'vineland_dailylvng_standard', position=7, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
-text = u'Vineland Adaptive Behavior Scales Interpersonal Relationships V Scaled Score'
-vineland_questions['vineland_interpersonal_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_interpersonal_v_scaled', position=8, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Play and Leisure Time V Scaled Score'
-vineland_questions['vineland_play_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_play_v_scaled', position=9, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior ScalesCoping Skills V Scaled Score'
-vineland_questions['vineland_coping_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_coping_v_scaled', position=10, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
-text = u'Vineland Adaptive Behavior Scales Socialization Standard Score'
-vineland_questions['vineland_social_standard'] = (store.create_entity('Question', identifier=u'vineland_social_standard', position=11, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
-text = u'Sum of Vineland Standard Scores (Communication + Daily Living Skills + Socialization)'
-vineland_questions['vineland_sum_scores'] = (store.create_entity('Question', identifier=u'vineland_sum_scores', position=12, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'76-480').eid, 76, 480)
-text = u'Vineland Adaptive Behavior Composite Standard score'
-vineland_questions['vineland_abc_standard'] = (store.create_entity('Question', identifier=u'vineland_abc_standard', position=13, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
-text = u'Vineland Adaptive Behavior Scales Informant'
-vineland_questions['vineland_informant'] = (store.create_entity('Question', identifier=u'vineland_informant', position=14, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1 = parent; 2 = self').eid, 1, 2)
+    # VINELAND
+    vineland_questionnaire_eid = store.create_entity('Questionnaire', name=u'Vineland Adaptive Behavior Scales', identifier=u'vineland', language=u'fr', version=u'v 0.1.0', type=u'behavioral').eid
+    vineland_questions = {}
+    text = u'Vineland Adaptive Behavior Scales Receptive Language V Scaled Score'
+    vineland_questions['vineland_receptive_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_receptive_v_scaled', position=0, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Expressive Language V Scaled Score'
+    vineland_questions['vineland_expressive_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_expressive_v_scaled', position=1, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Written Language V Scaled Score'
+    vineland_questions['vineland_written_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_written_v_scaled', position=2, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Communication Standard Score'
+    vineland_questions['vineland_communication_standard'] = (store.create_entity('Question', identifier=u'vineland_communication_standard', position=3, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
+    text = u'Vineland Adaptive Behavior Scales Personal Daily Living Skills V Scaled Score'
+    vineland_questions['vineland_personal_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_personal_v_scaled', position=4, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Domestic Daily Living Skills V Scaled Score'
+    vineland_questions['vineland_domestic_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_domestic_v_scaled', position=5, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Community Daily Living Skills V Scaled Score'
+    vineland_questions['vineland_community_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_community_v_scaled', position=6, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Daily Living Skills Standard Score'
+    vineland_questions['vineland_dailylvng_standard'] = (store.create_entity('Question', identifier=u'vineland_dailylvng_standard', position=7, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
+    text = u'Vineland Adaptive Behavior Scales Interpersonal Relationships V Scaled Score'
+    vineland_questions['vineland_interpersonal_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_interpersonal_v_scaled', position=8, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Play and Leisure Time V Scaled Score'
+    vineland_questions['vineland_play_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_play_v_scaled', position=9, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior ScalesCoping Skills V Scaled Score'
+    vineland_questions['vineland_coping_v_scaled'] = (store.create_entity('Question', identifier=u'vineland_coping_v_scaled', position=10, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1-24').eid, 1, 24)
+    text = u'Vineland Adaptive Behavior Scales Socialization Standard Score'
+    vineland_questions['vineland_social_standard'] = (store.create_entity('Question', identifier=u'vineland_social_standard', position=11, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
+    text = u'Sum of Vineland Standard Scores (Communication + Daily Living Skills + Socialization)'
+    vineland_questions['vineland_sum_scores'] = (store.create_entity('Question', identifier=u'vineland_sum_scores', position=12, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'76-480').eid, 76, 480)
+    text = u'Vineland Adaptive Behavior Composite Standard score'
+    vineland_questions['vineland_abc_standard'] = (store.create_entity('Question', identifier=u'vineland_abc_standard', position=13, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'20-160').eid, 20, 160)
+    text = u'Vineland Adaptive Behavior Scales Informant'
+    vineland_questions['vineland_informant'] = (store.create_entity('Question', identifier=u'vineland_informant', position=14, text=text, type=u'numerical', questionnaire=vineland_questionnaire_eid, possible_answers=u'1 = parent; 2 = self').eid, 1, 2)
 
-store.flush()
+    store.flush()
 
-###############################################################################
-### SUBJECTS ##################################################################
-###############################################################################
-groups = []
-for ind in range(NB_SUBJECTS_GROUPS):
-    groups.append(store.create_entity('Group', identifier=u'demo_group_%s' % ind,
-                                      name=u'Demo group of subjects %s' % ind).eid)
-subjects = []
-for ind in range(NB_SUBJECTS):
-    print ind
-    date = random_date('age')
-    subject = store.create_entity('Subject', identifier='demo_subject_%s' % ind,
-                                  gender=SEX[nr.randint(len(SEX))],
-                                  date_of_birth=date,
-                                  handedness=HANDEDNESS[nr.randint(len(HANDEDNESS))]).eid
-    subjects.append(subject)
-    store.relate(subject, 'related_studies', study)
-    store.relate(subject, 'related_groups', groups[nr.randint(len(groups))])
-    # Scores
-    for name, (score, _min, _max) in score_defs.iteritems():
-        score_value = store.create_entity('ScoreValue', definition=score,
-                                          datetime=random_date(), value=nr.randint(_min, _max)).eid
-        store.relate(subject, 'related_infos', score_value)
+    ###############################################################################
+    ### SUBJECTS ##################################################################
+    ###############################################################################
+    groups = []
+    for ind in range(NB_SUBJECTS_GROUPS):
+        groups.append(store.create_entity('Group', identifier=u'demo_group_%s' % ind,
+                                          name=u'Demo group of subjects %s' % ind).eid)
+    subjects = []
+    for ind in range(NB_SUBJECTS):
+        print ind
+        date = random_date('age')
+        subject = store.create_entity('Subject', identifier='demo_subject_%s' % ind,
+                                      gender=SEX[nr.randint(len(SEX))],
+                                      date_of_birth=date,
+                                      handedness=HANDEDNESS[nr.randint(len(HANDEDNESS))]).eid
+        subjects.append(subject)
+        store.relate(subject, 'related_studies', study)
+        store.relate(subject, 'related_groups', groups[nr.randint(len(groups))])
+        # Scores
+        for name, (score, _min, _max) in score_defs.iteritems():
+            score_value = store.create_entity('ScoreValue', definition=score,
+                                              datetime=random_date(), value=nr.randint(_min, _max)).eid
+            store.relate(subject, 'related_infos', score_value)
 
-store.flush()
-store.commit()
+    store.flush()
+    store.commit()
 
 
-###############################################################################
-### QUESTIONNAIRE RUNS ########################################################
-###############################################################################
-for subject_eid in subjects:
-    print subject_eid, 'questionnaire'
-    import_questionnaire(store, subject_eid, center, study,
-                         ados_questionnaire_eid, ados_questions, 'ados')
-    import_questionnaire(store, subject_eid, center, study,
-                         vineland_questionnaire_eid, vineland_questions, 'vineland')
+    ###############################################################################
+    ### QUESTIONNAIRE RUNS ########################################################
+    ###############################################################################
+    for subject_eid in subjects:
+        print subject_eid, 'questionnaire'
+        import_questionnaire(store, subject_eid, center, study,
+                             ados_questionnaire_eid, ados_questions, 'ados')
+        import_questionnaire(store, subject_eid, center, study,
+                             vineland_questionnaire_eid, vineland_questions, 'vineland')
 
-store.flush()
-store.commit()
+    store.flush()
+    store.commit()
 
 
-###############################################################################
-### GENOMIC MEASURES ##########################################################
-###############################################################################
-for subject_eid in subjects:
-    print subject_eid, 'genomics'
-    import_genomic(store, subject_eid, center, study, platform)
+    ###############################################################################
+    ### GENOMIC MEASURES ##########################################################
+    ###############################################################################
+    for subject_eid in subjects:
+        print subject_eid, 'genomics'
+        import_genomic(store, subject_eid, center, study, platform)
 
-store.flush()
-store.commit()
+    store.flush()
+    store.commit()
 
 
-###############################################################################
-### IMAGES MEASURES ###########################################################
-###############################################################################
-for subject_eid in subjects:
-    print subject_eid, 'images'
-    import_anat_images(store, subject_eid, center, study, mri_1, mri_2)
-    import_fmri_images(store, subject_eid, center, study, mri_1, mri_2)
-    import_constrat_images(store, subject_eid, center, study, mri_1, mri_2)
-store.flush()
-store.commit()
+    ###############################################################################
+    ### IMAGES MEASURES ###########################################################
+    ###############################################################################
+    for subject_eid in subjects:
+        print subject_eid, 'images'
+        import_anat_images(store, subject_eid, center, study, mri_1, mri_2)
+        import_fmri_images(store, subject_eid, center, study, mri_1, mri_2)
+        import_constrat_images(store, subject_eid, center, study, mri_1, mri_2)
+    store.flush()
+    store.commit()