Changeset 1727

Show
Ignore:
Timestamp:
07-04-11 15:57:59 (3 years ago)
Author:
robert@…
Message:

Adjusted assayservice to make exporting assays work with the sequencing module

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/dbnp/studycapturing/AssayService.groovy

    r1716 r1727  
    227227        def lastDataIndex   = moduleData.size() - 1 
    228228        def stepSize        = sampleTokens.size() + 1 
    229  
    230         // Transpose the data to order it by measurement (compound) so it can be 
    231         // written as 1 column 
    232         int i = 0 
    233         measurementTokens.inject([:]) { map, token -> 
    234  
    235             map + [(token): moduleData[(i++..lastDataIndex).step(stepSize)]] 
    236  
    237         } 
    238  
     229                 
     230                // Convert the three different maps into a map like:  
     231                // 
     232                // [ "measurement 1": [ value1, value2, value3 ], 
     233                //   "measurement 2": [ value4, value5, value6 ] 
     234                // 
     235                def map = [:] 
     236                def numSamples = sampleTokens.size(); 
     237                def idx = 0; 
     238                 
     239                // Loop through all measurementtokens, and get the right slice from the measurement list 
     240                measurementTokens.each { measurementToken -> 
     241                        def startIndex = idx++ * numSamples; 
     242                        def stopIndex = startIndex + numSamples - 1; 
     243                        map[ measurementToken.toString() ] = moduleData[ startIndex..stopIndex ].collect { it.toString() } 
     244                } 
     245 
     246                return map; 
    239247    } 
    240248