source: trunk/grails-app/domain/nl/tno/metagenomics/SequenceData.groovy @ 3

Last change on this file since 3 was 3, checked in by robert@…, 9 years ago

Externalized configuration; improved assay view (detail views of runs and samples); implemented uploading and parsing of FASTA and QUAL files

File size: 1.1 KB
Line 
1package nl.tno.metagenomics
2
3import org.codehaus.groovy.grails.commons.ConfigurationHolder
4
5class SequenceData {
6        def fileService
7       
8        String sequenceFile = ''
9        String qualityFile = ''
10        Long numSequences = 0L
11        Float averageQuality = 0.0
12
13        static belongsTo = [sample: AssaySample, run: Run]
14        static constraints = {
15                qualityFile(nullable: true)
16                numSequences(nullable: true)
17                averageQuality(nullable: true)
18        }
19
20        /**
21         * Returns the number of files in this data object.
22         * @return
23         */
24        public int numFiles() {
25                int number = 0;
26                if( sequenceFile != null && sequenceFile != "" )
27                        number++;
28
29                if( qualityFile != null && qualityFile != "" )
30                        number++;
31
32                return number;
33        }
34       
35        def beforeDelete = {
36                def permanentDir = fileService.absolutePath( ConfigurationHolder.config.metagenomics.fileDir.toString() )
37                if( sequenceFile ) {
38                        fileService.delete( sequenceFile, permanentDir )
39                }
40
41                if( qualityFile )
42                        fileService.delete( qualityFile, permanentDir )
43               
44                // Reset statistics of the assay sample, to ensure the deleted files are removed from statistics
45                sample.resetStats();
46        }
47}
Note: See TracBrowser for help on using the repository browser.