Changeset 662
- Timestamp:
- Jul 19, 2010, 4:28:10 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r639 r662 22 22 System.setProperty('user.timezone', 'CET') 23 23 24 // If there are no templates yet in the database 24 25 if (Template.count() == 0) { 25 26 println "No templates in the current database."; 27 28 // If in development or test mode, add the ontologies manually to the database 29 // without contacting the BioPortal website, to avoid annoying hiccups when the server is busy 30 if (grails.util.GrailsUtil.environment != GrailsApplication.ENV_PRODUCTION) { 31 println "Adding ontology descriptors" 32 BootStrapTemplates.initTemplateOntologies() 33 } 34 26 35 // Add example study, subject, event etc. templates 27 36 BootStrapTemplates.initTemplates() 28 37 29 // Add example studies38 // If in development mode and no studies are present, add example studies 30 39 if (Study.count() == 0 && grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) { 31 32 // When the code is properly refactored, BootStrapStudies.addExampleStudies() may be called here 40 BootStrapStudies.addExampleStudies() 33 41 } 34 42 } … … 45 53 // register methods for accessing SAM's Rest services 46 54 CommunicationManager.SAMServerURL = 'nbx5.nugo.org/sam' 47 55 CommunicationManager.registerRestWrapperMethodsSAMtoGSCF() 48 56 } 49 57 -
trunk/grails-app/conf/BootStrapStudies.groovy
r626 r662 10 10 11 11 import dbnp.studycapturing.* 12 import dbnp.data.Term 13 import dbnp.data.Ontology 12 14 13 15 class BootStrapStudies { 14 16 17 /** 18 * Add example studies. This function is meant to be called only in development mode 19 */ 20 15 21 public static void addExampleStudies() { 16 22 17 // TODO: Strip this code from all references to template and term objects 18 // which now are not there anymore because this code was separated from the template bootstrapping 19 // and because terms should be dynamically added 20 21 /* 23 // Look up the used ontologies which should be in the database by now 24 def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 25 def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) 26 def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) 27 def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) 28 29 // Look up the used templates which should also be in the database by now 30 def studyTemplate = Template.findByName("Academic study") 31 def mouseTemplate = Template.findByName("Mouse") 32 def humanTemplate = Template.findByName("Human") 33 def dietTreatmentTemplate = Template.findByName("Diet treatment") 34 def boostTreatmentTemplate = Template.findByName("Compound challenge") 35 def liverSamplingEventTemplate = Template.findByName("Liver extraction") 36 def fastingTreatmentTemplate = Template.findByName("Fasting treatment") 37 def bloodSamplingEventTemplate = Template.findByName("Blood extraction") 38 def humanBloodSampleTemplate = Template.findByName("Human blood sample") 39 40 41 // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website 42 println ".adding terms" 43 44 45 def mouseTerm = new Term( 46 name: 'Mus musculus', 47 ontology: speciesOntology, 48 accession: '10090' 49 ).with { if (!validate()) { errors.each { println it} } else save()} 50 51 def humanTerm = new Term( 52 name: 'Homo sapiens', 53 ontology: speciesOntology, 54 accession: '9606' 55 ).with { if (!validate()) { errors.each { println it} } else save()} 56 57 def arabTerm = new Term( 58 name: 'Arabidopsis thaliana', 59 ontology: speciesOntology, 60 accession: '3702' 61 ).with { if (!validate()) { errors.each { println it} } else save()} 62 63 def tomatoTerm = new Term( 64 name: 'Solanum lycopersicum', 65 ontology: speciesOntology, 66 accession: '4081' 67 ).with { if (!validate()) { errors.each { println it} } else save()} 68 69 def potatoTerm = new Term( 70 name: 'Solanum tuberosum', 71 ontology: speciesOntology, 72 accession: '0000' 73 ).with { if (!validate()) { errors.each { println it} } else save()} 74 75 def bloodTerm = new Term( 76 name: 'blood plasma', 77 ontology: brendaOntology, 78 accession: 'BTO:0000131' 79 ).with { if (!validate()) { errors.each { println it} } else save()} 80 81 def c57bl6Term = new Term( 82 name: 'C57BL/6 Mouse', 83 ontology: nciOntology, 84 accession: 'C14424' 85 ).with { if (!validate()) { errors.each { println it} } else save()} 86 87 def glucoseTerm = new Term( 88 name: 'Glucose', 89 ontology: chebiOntology, 90 accession: 'CHEBI:17234' 91 ).with { if (!validate()) { errors.each { println it} } else save()} 92 22 93 // Create a few persons, roles and Affiliations 23 94 println ".adding persons, roles and affiliations" … … 313 384 startTime: 3 * 24 * 3600 + 22 * 3600, 314 385 endTime: 3 * 24 * 3600 + 30 * 3600, 315 template: fastingTreatment )386 template: fastingTreatmentTemplate) 316 387 .setFieldValue('Fasting period','8h'); 317 388 … … 421 492 422 493 def clinicalModule = new AssayModule( 423 name: ' Clinical data',424 type: AssayType. CLINICAL_DATA,494 name: 'SAM module for clinical data', 495 type: AssayType.SIMPLE_ASSAY, 425 496 platform: 'clinical measurements', 426 url: 'http:// localhost:8080/gscf'497 url: 'http://sam.dbnp.org' 427 498 ).with { if (!validate()) { errors.each { println it} } else save()} 428 499 … … 441 512 humanStudy.save() 442 513 443 mouseStudy.addToAssays(lipidAssayRef);514 mouseStudy.addToAssays(lipidAssayRef); 444 515 mouseStudy.save() 445 */446 516 } 447 517 -
trunk/grails-app/conf/BootStrapTemplates.groovy
r626 r662 14 14 class BootStrapTemplates { 15 15 16 /** 17 * Add the ontologies that are necessary for the templates below manually 18 * This function can be called to avoid the HTTP requests to BioPortal each time 19 * (e.g. in development or automated test environments) 20 */ 21 public static void initTemplateOntologies() { 22 23 // add Subject>species ontology 24 println ".adding NCBI species ontology" 25 def speciesOntology = new Ontology( 26 name: 'NCBI organismal classification', 27 description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', 28 url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', 29 versionNumber: '1.2', 30 ncboId: '1132', 31 ncboVersionedId: '38802' 32 ).with { if (!validate()) { errors.each { println it} } else save()} 33 34 // add Sample>material ontology 35 println ".adding BRENDA source material ontology" 36 def brendaOntology = new Ontology( 37 name: 'BRENDA tissue / enzyme source', 38 description: 'A structured controlled vocabulary for the source of an enzyme. It comprises terms for tissues, cell lines, cell types and cell cultures from uni- and multicellular organisms.', 39 url: 'http://www.brenda-enzymes.info', 40 versionNumber: '1.3', 41 ncboId: '1005', 42 ncboVersionedId: '40643' 43 ).with { if (!validate()) { errors.each { println it} } else save()} 44 45 // add NCI ontology which is used in Mouse genotype template field 46 def nciOntology = new Ontology( 47 name: 'NCI Thesaurus', 48 description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.', 49 url: 'http://ncicb.nci.nih.gov/core/EVS', 50 versionNumber: '10.01', 51 ncboId: '1032', 52 ncboVersionedId: '42693' 53 ).with { if (!validate()) { errors.each { println it} } else save()} 54 55 // add CHEBI ontology which is used in Mouse genotype template field 56 def chebiOntology = new Ontology( 57 name: 'Chemical entities of biological interest', 58 description: 'A structured classification of chemical compounds of biological relevance.', 59 url: 'http://www.ebi.ac.uk/chebi', 60 versionNumber: '1.68', 61 ncboId: '1007', 62 ncboVersionedId: '42878' 63 ).with { if (!validate()) { errors.each { println it} } else save()} 64 65 } 66 67 /** 68 * Add example templates, this function would normally be called on an empty database 69 */ 16 70 public static void initTemplates() { 17 71 -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r661 r662 623 623 624 624 /** 625 * Look up the type of a certain template field 626 * @param String fieldName The name of the template field 627 * @return String The type (static member of TemplateFieldType) of the field, or null of the field does not exist 628 */ 629 TemplateFieldType giveFieldType(String fieldName) { 630 def field = giveFields().find { 631 it.name == fieldName 632 } 633 field?.type 634 } 635 636 /** 625 637 * Return all relevant 'built-in' domain fields of the super class. Should be implemented by a static method 626 638 * @return List with DomainTemplateFields … … 659 671 } 660 672 661 /**662 * Look up the type of a certain template subject field663 * @param String fieldName The name of the template field664 * @return String The type (static member of TemplateFieldType) of the field, or null of the field does not exist665 */666 def TemplateFieldType getFieldType(String fieldName) {667 def field = this.giveFields().find {668 it.name == fieldName669 }670 field?.type671 }672 673 } -
trunk/test/integration/gscf/SampleTests.groovy
r654 r662 6 6 import dbnp.studycapturing.SamplingEvent 7 7 import dbnp.studycapturing.Sample 8 import dbnp.studycapturing.TemplateFieldType 8 9 9 10 /** … … 177 178 assert sample.isDomainField('material') 178 179 180 // Make sure that they have the right type 181 assert sample.giveFieldType('name') == TemplateFieldType.STRING 182 assert sample.giveFieldType('material') == TemplateFieldType.ONTOLOGYTERM 183 179 184 } 180 185
Note: See TracChangeset
for help on using the changeset viewer.