Last change
on this file since 2 was
2,
checked in by robert@…, 12 years ago
|
Initial import of basic functionality
|
File size:
1.5 KB
|
Line | |
---|
1 | package nl.tno.metagenomics |
---|
2 | |
---|
3 | /** |
---|
4 | * Minimal representation of an assay. The studyToken is the link with an assay object in GSCF. |
---|
5 | * |
---|
6 | * @see GscfService.getAssay |
---|
7 | */ |
---|
8 | class Assay { |
---|
9 | String assayToken |
---|
10 | String name |
---|
11 | |
---|
12 | static belongsTo = [ study: Study ] |
---|
13 | static hasMany = [ assaySamples: AssaySample, runs: Run ] |
---|
14 | static mapping = { |
---|
15 | columns { |
---|
16 | assayToken index:'assaytoken_idx' |
---|
17 | } |
---|
18 | } |
---|
19 | |
---|
20 | static constraints = { |
---|
21 | assayToken(unique:true) |
---|
22 | } |
---|
23 | |
---|
24 | /** |
---|
25 | * Removes all assay samples from this assay |
---|
26 | */ |
---|
27 | public void removeAssaySamples() { |
---|
28 | if( assaySamples == null ) |
---|
29 | return |
---|
30 | |
---|
31 | def assaySamples = assaySamples.toArray(); |
---|
32 | def numAssaySamples = assaySamples.size(); |
---|
33 | for( int i = numAssaySamples - 1; i >= 0; i-- ) { |
---|
34 | def existingSample = assaySamples[i]; |
---|
35 | |
---|
36 | // Delete the sample and also the association |
---|
37 | existingSample.delete() |
---|
38 | removeFromAssaySamples( existingSample ); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * Returns the total number of sequences found in this assay. It is computed |
---|
44 | * as the sum of the number of sequences of all samples |
---|
45 | * @return |
---|
46 | */ |
---|
47 | public int numSequences() { |
---|
48 | if( !assaySamples ) |
---|
49 | return 0 |
---|
50 | |
---|
51 | int numSequences = 0; |
---|
52 | assaySamples.each { numSequences += it.numSequences() } |
---|
53 | |
---|
54 | return numSequences; |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Returns the total number of files in the system, belonging to this assay. |
---|
59 | * It is computed as the sum of the number of files of all samples |
---|
60 | * @return |
---|
61 | */ |
---|
62 | public int numFiles() { |
---|
63 | if( !assaySamples ) |
---|
64 | return 0 |
---|
65 | |
---|
66 | int numFiles = 0; |
---|
67 | assaySamples.each { numFiles += it.numFiles() } |
---|
68 | |
---|
69 | return numFiles; |
---|
70 | } |
---|
71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.