Changeset 406 for trunk/grails-app/conf
- Timestamp:
- May 11, 2010, 3:35:21 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r394 r406 3 3 import dbnp.data.Ontology 4 4 import dbnp.data.Term 5 import org.codehaus.groovy.grails.commons.GrailsApplication 5 6 6 7 /** … … 484 485 */ 485 486 // studies 486 println ".adding NuGO PPS3 leptin example study..." 487 def exampleStudy = new Study( 488 template: studyTemplate, 489 title:"NuGO PPS3 mouse study leptin module", 490 code:"PPS3_leptin_module", 491 researchQuestion:"Leptin etc.", 492 ecCode:"2007117.c", 493 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 494 ) 495 .with { if (!validate()) { errors.each { println it} } else save()} 496 497 exampleStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 498 exampleStudy.save() 499 500 println ".adding NuGO PPSH example study..." 501 def exampleHumanStudy = new Study( 502 template: studyTemplate, 503 title:"Human example template", 504 code:"Human example code", 505 researchQuestion:"Leptin etc.", 506 ecCode:"2007117.c", 507 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 508 ) 509 .with { if (!validate()) { errors.each { println it} } else save()} 510 511 exampleHumanStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 512 exampleHumanStudy.save() 513 514 def evLF = new Event( 515 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 516 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 517 template: dietTreatmentTemplate 518 ) 519 .with { if (!validate()) { errors.each { println it} } else save()} 520 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 521 evLF.save(flush:true) 522 523 def evHF = new Event( 524 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 525 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 526 template: dietTreatmentTemplate 527 ) 528 .setFieldValue( 'Diet','45% fat (palm oil)' ) 529 .with { if (!validate()) { errors.each { println it} } else save()} 530 531 def evBV = new Event( 532 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 533 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 534 template: boostTreatmentTemplate 535 ) 536 .setFieldValue( 'Compound','Vehicle' ) 537 .with { if (!validate()) { errors.each { println it} } else save()} 538 539 def evBL = new Event( 540 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 541 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 542 template: boostTreatmentTemplate 543 ) 544 .setFieldValue( 'Compound','Leptin' ) 545 .with { if (!validate()) { errors.each { println it} } else save()} 546 547 /* 548 def evLF4 = new Event( 549 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 550 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 551 eventDescription: eventDiet, 552 parameterStringValues: ['Diet':'10% fat (palm oil)'] 553 ).with { if (!validate()) { errors.each { println it} } else save()} 554 555 def evHF4 = new Event( 556 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 557 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 558 eventDescription: eventDiet, 559 parameterStringValues: ['Diet':'45% fat (palm oil)'] 560 ).with { if (!validate()) { errors.each { println it} } else save()} 561 562 def evBV4 = new Event( 563 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 564 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 565 eventDescription: eventBoost, 566 parameterStringValues: ['Compound':'Vehicle'] 567 ).with { if (!validate()) { errors.each { println it} } else save()} 568 569 def evBL4 = new Event( 570 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 571 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 572 eventDescription: eventBoost, 573 parameterStringValues: ['Compound':'Leptin'] 574 ).with { if (!validate()) { errors.each { println it} } else save()} 575 576 def evS = new SamplingEvent( 577 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 487 if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) { 488 println ".adding NuGO PPS3 leptin example study..." 489 def exampleStudy = new Study( 490 template: studyTemplate, 491 title:"NuGO PPS3 mouse study leptin module", 492 code:"PPS3_leptin_module", 493 researchQuestion:"Leptin etc.", 494 ecCode:"2007117.c", 495 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 496 ) 497 .with { if (!validate()) { errors.each { println it} } else save()} 498 499 exampleStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 500 exampleStudy.save() 501 502 println ".adding NuGO PPSH example study..." 503 def exampleHumanStudy = new Study( 504 template: studyTemplate, 505 title:"Human example template", 506 code:"Human example code", 507 researchQuestion:"Leptin etc.", 508 ecCode:"2007117.c", 509 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 510 ) 511 .with { if (!validate()) { errors.each { println it} } else save()} 512 513 exampleHumanStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 514 exampleHumanStudy.save() 515 516 def evLF = new Event( 517 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 578 518 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 579 eventDescription: samplingEvent, 580 parameterFloatValues: ['Sample weight':5F] 581 ).with { if (!validate()) { errors.each { println it} } else save()} 582 583 def evS4 = new SamplingEvent( 584 startTime: Date.parse('yyyy-MM-dd','2008-02-04'), 519 template: dietTreatmentTemplate 520 ) 521 .with { if (!validate()) { errors.each { println it} } else save()} 522 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 523 evLF.save(flush:true) 524 525 def evHF = new Event( 526 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 527 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 528 template: dietTreatmentTemplate 529 ) 530 .setFieldValue( 'Diet','45% fat (palm oil)' ) 531 .with { if (!validate()) { errors.each { println it} } else save()} 532 533 def evBV = new Event( 534 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 535 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 536 template: boostTreatmentTemplate 537 ) 538 .setFieldValue( 'Compound','Vehicle' ) 539 .with { if (!validate()) { errors.each { println it} } else save()} 540 541 def evBL = new Event( 542 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 543 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 544 template: boostTreatmentTemplate 545 ) 546 .setFieldValue( 'Compound','Leptin' ) 547 .with { if (!validate()) { errors.each { println it} } else save()} 548 549 /* 550 def evLF4 = new Event( 551 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 585 552 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 586 eventDescription: samplingEvent, 587 parameterFloatValues: ['Sample weight':5F] 588 ).with { if (!validate()) { errors.each { println it} } else save()} 589 */ 590 591 // Add events to study 592 exampleStudy 593 .addToEvents(evLF) 594 .addToEvents(evHF) 595 .addToEvents(evBV) 596 .addToEvents(evBL) 597 /* 598 .addToEvents(evLF4) 599 .addToEvents(evHF4) 600 .addToEvents(evBV4) 601 .addToEvents(evBL4) 602 .addToSamplingEvents(evS) 603 .addToSamplingEvents(evS4) 604 */ 605 .save() 606 607 def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") 608 .addToEvents(evLF) 609 .addToEvents(evBV) 610 .with { if (!validate()) { errors.each { println it} } else save()} 611 612 def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") 613 .addToEvents(evLF) 614 .addToEvents(evBL) 615 .with { if (!validate()) { errors.each { println it} } else save()} 616 617 def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") 618 .addToEvents(evHF) 619 .addToEvents(evBV) 620 .with { if (!validate()) { errors.each { println it} } else save()} 621 622 def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") 623 .addToEvents(evHF) 624 .addToEvents(evBL) 625 .with { if (!validate()) { errors.each { println it} } else save()} 626 627 /* 628 def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") 629 .addToEvents(evLF4) 630 .addToEvents(evBV4) 631 .with { if (!validate()) { errors.each { println it} } else save()} 632 633 def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") 634 .addToEvents(evLF4) 635 .addToEvents(evBL4) 636 .with { if (!validate()) { errors.each { println it} } else save()} 637 638 def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") 639 .addToEvents(evHF4) 640 .addToEvents(evBV4) 641 .with { if (!validate()) { errors.each { println it} } else save()} 642 643 def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") 644 .addToEvents(evHF4) 645 .addToEvents(evBL4) 646 .with { if (!validate()) { errors.each { println it} } else save()} 647 */ 648 649 // Add subjects and samples and compose EventGroups 650 651 def x=1 652 40.times { 653 def currentSubject = new Subject( 654 name: "A" + x++, 655 species: mouseTerm, 656 template: mouseTemplate, 657 ) 658 .setFieldValue("Gender", "Male") 659 //.setFieldValue("Genotype", c57bl6Term) 660 .setFieldValue("Age (weeks)", 17) 661 .setFieldValue("Cage", "" + (int)(x/2)) 662 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 663 664 exampleStudy.addToSubjects(currentSubject) 665 .with { if (!validate()) { errors.each { println it} } else save()} 666 667 // Add subject to appropriate EventGroup 553 eventDescription: eventDiet, 554 parameterStringValues: ['Diet':'10% fat (palm oil)'] 555 ).with { if (!validate()) { errors.each { println it} } else save()} 556 557 def evHF4 = new Event( 558 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 559 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 560 eventDescription: eventDiet, 561 parameterStringValues: ['Diet':'45% fat (palm oil)'] 562 ).with { if (!validate()) { errors.each { println it} } else save()} 563 564 def evBV4 = new Event( 565 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 566 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 567 eventDescription: eventBoost, 568 parameterStringValues: ['Compound':'Vehicle'] 569 ).with { if (!validate()) { errors.each { println it} } else save()} 570 571 def evBL4 = new Event( 572 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 573 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 574 eventDescription: eventBoost, 575 parameterStringValues: ['Compound':'Leptin'] 576 ).with { if (!validate()) { errors.each { println it} } else save()} 577 578 def evS = new SamplingEvent( 579 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 580 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 581 eventDescription: samplingEvent, 582 parameterFloatValues: ['Sample weight':5F] 583 ).with { if (!validate()) { errors.each { println it} } else save()} 584 585 def evS4 = new SamplingEvent( 586 startTime: Date.parse('yyyy-MM-dd','2008-02-04'), 587 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 588 eventDescription: samplingEvent, 589 parameterFloatValues: ['Sample weight':5F] 590 ).with { if (!validate()) { errors.each { println it} } else save()} 591 */ 592 593 // Add events to study 594 exampleStudy 595 .addToEvents(evLF) 596 .addToEvents(evHF) 597 .addToEvents(evBV) 598 .addToEvents(evBL) 668 599 /* 669 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 670 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 671 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 672 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 673 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 674 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 675 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 676 else { LFBV1.addToSubjects(currentSubject).save() } 677 */ 678 679 if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 680 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 681 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 682 else { LFBV1.addToSubjects(currentSubject).save() } 683 684 } 685 686 // Add EventGroups to study 687 exampleStudy 688 .addToEventGroups(LFBV1) 689 .addToEventGroups(LFBL1) 690 .addToEventGroups(HFBV1) 691 .addToEventGroups(HFBL1) 692 //.addToEventGroups(LFBV4) 693 //.addToEventGroups(LFBL4) 694 //.addToEventGroups(HFBV4) 695 //.addToEventGroups(HFBL4) 696 697 // Add persons to study 698 def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); 699 def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); 700 701 exampleStudy 702 .addToPersons( studyperson1 ) 703 .addToPersons( studyperson2 ) 704 .save() 705 706 /* 707 println 'Adding PPSH study' 708 709 def humanStudy = new Study( 710 template: studyTemplate, 711 title:"NuGO PPS human study", 712 code:"PPSH", 713 researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 714 description:"Human study", 715 ecCode:"unknown", 716 startDate: Date.parse('yyyy-MM-dd','2009-01-01') 717 ).with { if (!validate()) { errors.each { println it} } else save()} 718 719 def fastingEvent = new Event( 720 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 721 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 722 eventDescription: fastingTreatment, 723 parameterStringValues: ['Fasting period':'8h']); 724 725 def bloodSamplingEvent = new SamplingEvent( 726 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 727 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 728 eventDescription: bloodSamplingEventDescription, 729 parameterFloatValues: ['Sample volume':4.5F]); 730 731 def rootGroup = new EventGroup(name: 'Root group'); 732 rootGroup.addToEvents fastingEvent 733 rootGroup.addToEvents bloodSamplingEvent 734 rootGroup.save() 735 736 def y = 1 737 11.times { 738 def currentSubject = new Subject( 739 name: "" + y++, 740 species: humanTerm, 741 template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age (years)", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight (kg)", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} 742 743 rootGroup.addToSubjects currentSubject 744 rootGroup.save() 745 746 def currentSample = new Sample( 747 name: currentSubject.name + '_B', 748 material: bloodTerm, 749 parentSubject: currentSubject, 750 parentEvent: bloodSamplingEvent); 751 752 753 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 754 } 755 756 humanStudy.addToEvents(fastingEvent) 757 humanStudy.addToSamplingEvents(bloodSamplingEvent) 758 humanStudy.addToEventGroups rootGroup 759 humanStudy.save() 760 761 // Add clinical data 762 763 def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( 764 name: 'Lipid profile', 765 approved: true 766 ).with { if (!validate()) { errors.each { println it} } else save()} 767 768 def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( 769 name: 'LDL', 770 unit: 'mg/dL', 771 type: dbnp.data.FeatureType.QUANTITATIVE, 772 referenceValues: '100 mg/dL', 773 detectableLimit: 250, 774 isDrug: false, isIntake: true, inSerum: true 775 ).with { if (!validate()) { errors.each { println it} } else save()} 776 777 def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( 778 name: 'HDL', 779 unit: 'mg/dL', 780 type: dbnp.data.FeatureType.QUANTITATIVE, 781 referenceValues: '50 mg/dL', 782 detectableLimit: 100, 783 isDrug: false, isIntake: true, inSerum: true 784 ).with { if (!validate()) { errors.each { println it} } else save()} 785 786 lipidAssay.addToMeasurements ldlMeasurement 787 lipidAssay.addToMeasurements hdlMeasurement 788 789 def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( 790 assay: lipidAssay 791 ).with { if (!validate()) { errors.each { println it} } else save()} 792 793 humanStudy.samples*.each { 794 new dbnp.clinicaldata.ClinicalFloatData( 795 assay: lipidAssayInstance, 796 measurement: ldlMeasurement, 797 sample: it.name, 798 value: Math.round(Math.random()*ldlMeasurement.detectableLimit) 799 ).with { if (!validate()) { errors.each { println it} } else save()} 800 801 new dbnp.clinicaldata.ClinicalFloatData( 802 assay: lipidAssayInstance, 803 measurement: hdlMeasurement, 804 sample: it.name, 805 value: Math.round(Math.random()*hdlMeasurement.detectableLimit) 806 ).with { if (!validate()) { errors.each { println it} } else save()} 600 .addToEvents(evLF4) 601 .addToEvents(evHF4) 602 .addToEvents(evBV4) 603 .addToEvents(evBL4) 604 .addToSamplingEvents(evS) 605 .addToSamplingEvents(evS4) 606 */ 607 .save() 608 609 def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") 610 .addToEvents(evLF) 611 .addToEvents(evBV) 612 .with { if (!validate()) { errors.each { println it} } else save()} 613 614 def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") 615 .addToEvents(evLF) 616 .addToEvents(evBL) 617 .with { if (!validate()) { errors.each { println it} } else save()} 618 619 def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") 620 .addToEvents(evHF) 621 .addToEvents(evBV) 622 .with { if (!validate()) { errors.each { println it} } else save()} 623 624 def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") 625 .addToEvents(evHF) 626 .addToEvents(evBL) 627 .with { if (!validate()) { errors.each { println it} } else save()} 628 629 /* 630 def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") 631 .addToEvents(evLF4) 632 .addToEvents(evBV4) 633 .with { if (!validate()) { errors.each { println it} } else save()} 634 635 def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") 636 .addToEvents(evLF4) 637 .addToEvents(evBL4) 638 .with { if (!validate()) { errors.each { println it} } else save()} 639 640 def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") 641 .addToEvents(evHF4) 642 .addToEvents(evBV4) 643 .with { if (!validate()) { errors.each { println it} } else save()} 644 645 def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") 646 .addToEvents(evHF4) 647 .addToEvents(evBL4) 648 .with { if (!validate()) { errors.each { println it} } else save()} 649 */ 650 651 // Add subjects and samples and compose EventGroups 652 653 def x=1 654 40.times { 655 def currentSubject = new Subject( 656 name: "A" + x++, 657 species: mouseTerm, 658 template: mouseTemplate, 659 ) 660 .setFieldValue("Gender", "Male") 661 //.setFieldValue("Genotype", c57bl6Term) 662 .setFieldValue("Age (weeks)", 17) 663 .setFieldValue("Cage", "" + (int)(x/2)) 664 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 665 666 exampleStudy.addToSubjects(currentSubject) 667 .with { if (!validate()) { errors.each { println it} } else save()} 668 669 // Add subject to appropriate EventGroup 670 /* 671 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 672 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 673 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 674 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 675 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 676 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 677 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 678 else { LFBV1.addToSubjects(currentSubject).save() } 679 */ 680 681 if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 682 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 683 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 684 else { LFBV1.addToSubjects(currentSubject).save() } 685 686 } 687 688 // Add EventGroups to study 689 exampleStudy 690 .addToEventGroups(LFBV1) 691 .addToEventGroups(LFBL1) 692 .addToEventGroups(HFBV1) 693 .addToEventGroups(HFBL1) 694 //.addToEventGroups(LFBV4) 695 //.addToEventGroups(LFBL4) 696 //.addToEventGroups(HFBV4) 697 //.addToEventGroups(HFBL4) 698 699 // Add persons to study 700 def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); 701 def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); 702 703 exampleStudy 704 .addToPersons( studyperson1 ) 705 .addToPersons( studyperson2 ) 706 .save() 707 708 709 /* 710 println 'Adding PPSH study' 711 712 def humanStudy = new Study( 713 template: studyTemplate, 714 title:"NuGO PPS human study", 715 code:"PPSH", 716 researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 717 description:"Human study", 718 ecCode:"unknown", 719 startDate: Date.parse('yyyy-MM-dd','2009-01-01') 720 ).with { if (!validate()) { errors.each { println it} } else save()} 721 722 def fastingEvent = new Event( 723 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 724 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 725 eventDescription: fastingTreatment, 726 parameterStringValues: ['Fasting period':'8h']); 727 728 def bloodSamplingEvent = new SamplingEvent( 729 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 730 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 731 eventDescription: bloodSamplingEventDescription, 732 parameterFloatValues: ['Sample volume':4.5F]); 733 734 def rootGroup = new EventGroup(name: 'Root group'); 735 rootGroup.addToEvents fastingEvent 736 rootGroup.addToEvents bloodSamplingEvent 737 rootGroup.save() 738 739 def y = 1 740 11.times { 741 def currentSubject = new Subject( 742 name: "" + y++, 743 species: humanTerm, 744 template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age (years)", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight (kg)", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} 745 746 rootGroup.addToSubjects currentSubject 747 rootGroup.save() 748 749 def currentSample = new Sample( 750 name: currentSubject.name + '_B', 751 material: bloodTerm, 752 parentSubject: currentSubject, 753 parentEvent: bloodSamplingEvent); 754 755 756 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 757 } 758 759 humanStudy.addToEvents(fastingEvent) 760 humanStudy.addToSamplingEvents(bloodSamplingEvent) 761 humanStudy.addToEventGroups rootGroup 762 humanStudy.save() 763 764 // Add clinical data 765 766 def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( 767 name: 'Lipid profile', 768 approved: true 769 ).with { if (!validate()) { errors.each { println it} } else save()} 770 771 def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( 772 name: 'LDL', 773 unit: 'mg/dL', 774 type: dbnp.data.FeatureType.QUANTITATIVE, 775 referenceValues: '100 mg/dL', 776 detectableLimit: 250, 777 isDrug: false, isIntake: true, inSerum: true 778 ).with { if (!validate()) { errors.each { println it} } else save()} 779 780 def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( 781 name: 'HDL', 782 unit: 'mg/dL', 783 type: dbnp.data.FeatureType.QUANTITATIVE, 784 referenceValues: '50 mg/dL', 785 detectableLimit: 100, 786 isDrug: false, isIntake: true, inSerum: true 787 ).with { if (!validate()) { errors.each { println it} } else save()} 788 789 lipidAssay.addToMeasurements ldlMeasurement 790 lipidAssay.addToMeasurements hdlMeasurement 791 792 def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( 793 assay: lipidAssay 794 ).with { if (!validate()) { errors.each { println it} } else save()} 795 796 humanStudy.samples*.each { 797 new dbnp.clinicaldata.ClinicalFloatData( 798 assay: lipidAssayInstance, 799 measurement: ldlMeasurement, 800 sample: it.name, 801 value: Math.round(Math.random()*ldlMeasurement.detectableLimit) 802 ).with { if (!validate()) { errors.each { println it} } else save()} 803 804 new dbnp.clinicaldata.ClinicalFloatData( 805 assay: lipidAssayInstance, 806 measurement: hdlMeasurement, 807 sample: it.name, 808 value: Math.round(Math.random()*hdlMeasurement.detectableLimit) 809 ).with { if (!validate()) { errors.each { println it} } else save()} 810 } 811 812 // Add assay to study capture module 813 814 def clinicalModule = new AssayModule( 815 name: 'Clinical data', 816 type: AssayType.CLINICAL_DATA, 817 platform: 'clinical measurements', 818 url: 'http://localhost:8080/gscf' 819 ).with { if (!validate()) { errors.each { println it} } else save()} 820 821 def lipidAssayRef = new Assay( 822 name: 'Lipid profiling', 823 module: clinicalModule, 824 externalAssayId: lipidAssayInstance.id 825 ).with { if (!validate()) { errors.each { println it} } else save()} 826 827 humanStudy.samples*.each { 828 lipidAssayRef.addToSamples(it) 829 } 830 lipidAssayRef.save() 831 832 humanStudy.addToAssays(lipidAssayRef); 833 humanStudy.save() 834 */ 807 835 } 808 809 // Add assay to study capture module810 811 def clinicalModule = new AssayModule(812 name: 'Clinical data',813 type: AssayType.CLINICAL_DATA,814 platform: 'clinical measurements',815 url: 'http://localhost:8080/gscf'816 ).with { if (!validate()) { errors.each { println it} } else save()}817 818 def lipidAssayRef = new Assay(819 name: 'Lipid profiling',820 module: clinicalModule,821 externalAssayId: lipidAssayInstance.id822 ).with { if (!validate()) { errors.each { println it} } else save()}823 824 humanStudy.samples*.each {825 lipidAssayRef.addToSamples(it)826 }827 lipidAssayRef.save()828 829 humanStudy.addToAssays(lipidAssayRef);830 humanStudy.save()831 */832 836 } 833 837 }
Note: See TracChangeset
for help on using the changeset viewer.