Changeset 187


Ignore:
Timestamp:
Feb 10, 2010, 4:09:52 PM (13 years ago)
Author:
keesvb
Message:

changed definition of clean data layer, implemented it for the clinical data module, added demonstration to the sandbox

Location:
trunk
Files:
1 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r186 r187  
    295295                                name: 'LDL',
    296296                                unit: 'mg/dL',
    297                                 type: dbnp.clinicaldata.ClinicalMeasurementType.NUMBER,
     297                                type: dbnp.data.FeatureType.QUANTITATIVE,
    298298                                referenceValues: '100 mg/dL',
    299299                                detectableLimit: 250,
     
    304304                                name: 'HDL',
    305305                                unit: 'mg/dL',
    306                                 type: dbnp.clinicaldata.ClinicalMeasurementType.NUMBER,
     306                                type: dbnp.data.FeatureType.QUANTITATIVE,
    307307                                referenceValues: '50 mg/dL',
    308308                                detectableLimit: 100,
  • trunk/grails-app/controllers/SandboxController.groovy

    r186 r187  
    11import dbnp.studycapturing.*
     2import dbnp.clinicaldata.ClinicalFloatData
     3import dbnp.clinicaldata.ClinicalMeasurement
    24
    35// The sandbox is meant for internal communication over code examples etc.
    46
    57class SandboxController {
     8
     9        def clinicalDataLayerService
    610
    711        def index = {
     
    2226
    2327                //Let's get a certain field for a certain subject
    24                 def subject = Subject.findByName('A1')
     28                /*def subject = st.subjects.get(1)
     29
     30                if (subject) {
    2531                println st.template.getSubjectFieldType('Age')
    2632                println subject.getFieldValue('Genotype')
     
    2834                println subject.getFieldValue('Genotype')
    2935                subject.setFieldValue('name','hallo')
    30                 println subject.name
     36                println subject.name }*/
    3137
    32                 println Study.get(2).giveSamples()*.name
    33        
     38
     39                // Demonstration of querying mechanism
     40                println clinicalDataLayerService.getFeaturesQuantitative(1)
     41                clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])
    3442
    3543                // Specify which variables we want to be available in the controller (implicit return statement)
    3644                [fields: f, subjects: st.subjects]
     45        }
    3746}
    38 }
  • trunk/grails-app/domain/dbnp/clinicaldata/ClinicalMeasurement.groovy

    r186 r187  
    11package dbnp.clinicaldata
     2
     3import dbnp.data.FeatureType
    24
    35class ClinicalMeasurement
    46 extends dbnp.data.FeatureBase {
    57
    6         ClinicalMeasurementType type
     8        // For now, let's assume that quantitative values are stored as float,
     9        // and qualitative values as string
     10        // We can always add an additional ClinicalMeasurementType datatype (FLOAT, INTEGER etc.) later (as was here until rev 186)
     11
    712        String referenceValues
    813        float detectableLimit
     
    1318
    1419        static constraints = {
     20                name(unique:true)
    1521                referenceValues(nullable: true, blank: true)
    1622                detectableLimit(nullable: true)
    1723                correctionMethod(nullable: true, blank: true)
    1824        }
     25
     26        Map getValues(long assayID, String[] sampleIDs) {
     27                FeatureType featureType = type
     28                switch(featureType) {
     29                        case FeatureType.QUANTITATIVE:
     30                                def values = ClinicalFloatData.withCriteria {
     31                                        assay { eq("id",assayID) }
     32                                        eq("measurement",this)
     33                                        'in'("sample",sampleIDs)
     34                                }
     35                                def result = new HashMap<String,Float>();
     36                                values.each {
     37                                        result.put(it.sample,it.value)
     38                                }
     39                                return result
     40                        default:
     41                                throw new NoSuchFieldException("Feature type ${featureType} not supported")
     42                }
     43        }
    1944}
  • trunk/grails-app/domain/dbnp/data/FeatureBase.groovy

    r162 r187  
    55        String name
    66        String unit
     7        FeatureType type
    78
    89        static hasMany = [
  • trunk/grails-app/domain/dbnp/data/FeatureType.groovy

    r186 r187  
    1 package dbnp.studycapturing
     1package dbnp.data
    22
    33/**
    44 * Enum describing the different assay types (aka omics submodules).
    55 */
    6 public enum AssayType {
    7     TRANSCRIPTOMICS('Transcriptomics'),
    8     METABOLOMICS('Metabolomics'),
    9     CLINICAL_DATA('Clinical data')
     6public enum FeatureType {
     7    QUANTITATIVE('Quantitative'),
     8    QUALITATIVE('Qualitative'),
     9    PAIRED('Paired'),
     10    DIFFERENTIAL('Differential')
    1011
    1112    String name
    1213
    13     AssayType(String name) {
     14    FeatureType(String name) {
    1415     this.name = name
    1516    }
    1617
    1718    static list() {
    18      [TRANSCRIPTOMICS, METABOLOMICS, CLINICAL_DATA]
     19     [QUANTITATIVE, QUALITATIVE, PAIRED, DIFFERENTIAL]
    1920    }
    2021
  • trunk/grails-app/services/dbnp/clinicaldata/ClinicalDataLayerService.groovy

    r106 r187  
    55        boolean transactional = false
    66
    7         String getAssayDescription(long assayID) {
    8                 return "";
     7        Map getDataQuantitative(String feature, long assayID, String[] sampleIDs) {
     8                def measurement = ClinicalMeasurement.findByName(feature)
     9                if (!measurement) throw new NoSuchFieldException("Feature ${feature} not found")
     10                measurement.getValues(assayID,sampleIDs)
    911        }
    1012
    11         String[] getFeatureNames(long assayID) {
    12                 return new String[0];
    13         }
    14 
    15         Map getFeatureData(long assayID, long[] sampleIDs) {
    16                 return null;
    17         }
    18 
    19         Map getFeatureDataDifferential(long assayID, long[] sampleIDs1, long[] sampleIDs2) {
    20                 return null;
     13        String[] getFeaturesQuantitative(long assayID) {
     14                return ClinicalAssayInstance.get(assayID).assay.measurements*.name;
    2115        }
    2216}
  • trunk/src/java/dbnp/data/CleanDataLayer.java

    r106 r187  
    88public interface CleanDataLayer {
    99
    10         public String getAssayDescription(long assayID);
    11         public String[] getFeatureNames(long assayID);
    12         public Map getFeatureData(long assayID, long[] sampleIDs);
    13         public Map getFeatureDataDifferential(long assayID, long[] sampleIDs1, long[] sampleIDs2);
     10        /**
     11         * Get the names of all quantitative features that are available for a certain assay
     12         * @param assayID the module internal ID for the assay
     13         * @return
     14         */
     15        public String[] getFeaturesQuantitative(long assayID);
     16
     17        /**
     18         * Get the data for a quantitative feature for a certain assay for a certain set of samples
     19         * @param feature
     20         * @param assayID
     21         * @param sampleIDs
     22         * @return
     23         */
     24        public Map getDataQuantitative(String feature, long assayID, String[] sampleIDs);
    1425
    1526}
Note: See TracChangeset for help on using the changeset viewer.