3059 |
19 Dec 14 |
nicklas |
1 |
package net.sf.basedb.reggie.counter; |
3059 |
19 Dec 14 |
nicklas |
2 |
|
3059 |
19 Dec 14 |
nicklas |
3 |
|
6177 |
23 Mar 21 |
nicklas |
4 |
import java.util.ArrayList; |
4687 |
26 Feb 18 |
nicklas |
5 |
import java.util.Arrays; |
3844 |
14 Apr 16 |
nicklas |
6 |
import java.util.HashSet; |
3844 |
14 Apr 16 |
nicklas |
7 |
import java.util.List; |
3844 |
14 Apr 16 |
nicklas |
8 |
import java.util.Set; |
3059 |
19 Dec 14 |
nicklas |
9 |
import java.util.TimerTask; |
3844 |
14 Apr 16 |
nicklas |
10 |
import java.util.TreeSet; |
3059 |
19 Dec 14 |
nicklas |
11 |
|
3571 |
30 Oct 15 |
nicklas |
12 |
import net.sf.basedb.clients.web.extensions.service.ServiceControllerAction; |
3059 |
19 Dec 14 |
nicklas |
13 |
import net.sf.basedb.clients.web.extensions.service.Services; |
3059 |
19 Dec 14 |
nicklas |
14 |
import net.sf.basedb.core.Application; |
3247 |
14 Apr 15 |
nicklas |
15 |
import net.sf.basedb.core.ItemList; |
3059 |
19 Dec 14 |
nicklas |
16 |
import net.sf.basedb.core.BioPlate; |
3059 |
19 Dec 14 |
nicklas |
17 |
import net.sf.basedb.core.BioSource; |
3059 |
19 Dec 14 |
nicklas |
18 |
import net.sf.basedb.core.DbControl; |
3059 |
19 Dec 14 |
nicklas |
19 |
import net.sf.basedb.core.DerivedBioAssay; |
3059 |
19 Dec 14 |
nicklas |
20 |
import net.sf.basedb.core.Extract; |
7372 |
06 Oct 23 |
nicklas |
21 |
import net.sf.basedb.core.FastAnnotationLoader; |
4687 |
26 Feb 18 |
nicklas |
22 |
import net.sf.basedb.core.Include; |
3059 |
19 Dec 14 |
nicklas |
23 |
import net.sf.basedb.core.Item; |
3059 |
19 Dec 14 |
nicklas |
24 |
import net.sf.basedb.core.ItemQuery; |
3059 |
19 Dec 14 |
nicklas |
25 |
import net.sf.basedb.core.Job; |
3059 |
19 Dec 14 |
nicklas |
26 |
import net.sf.basedb.core.PhysicalBioAssay; |
3059 |
19 Dec 14 |
nicklas |
27 |
import net.sf.basedb.core.RawBioAssay; |
3059 |
19 Dec 14 |
nicklas |
28 |
import net.sf.basedb.core.Sample; |
3059 |
19 Dec 14 |
nicklas |
29 |
import net.sf.basedb.core.SessionControl; |
5340 |
29 Mar 19 |
nicklas |
30 |
import net.sf.basedb.core.Type; |
3059 |
19 Dec 14 |
nicklas |
31 |
import net.sf.basedb.core.query.Annotations; |
3059 |
19 Dec 14 |
nicklas |
32 |
import net.sf.basedb.core.query.Expression; |
3059 |
19 Dec 14 |
nicklas |
33 |
import net.sf.basedb.core.query.Expressions; |
3059 |
19 Dec 14 |
nicklas |
34 |
import net.sf.basedb.core.query.Hql; |
3059 |
19 Dec 14 |
nicklas |
35 |
import net.sf.basedb.core.query.Restrictions; |
3059 |
19 Dec 14 |
nicklas |
36 |
import net.sf.basedb.reggie.Reggie; |
3059 |
19 Dec 14 |
nicklas |
37 |
import net.sf.basedb.reggie.dao.Annotationtype; |
3158 |
04 Mar 15 |
nicklas |
38 |
import net.sf.basedb.reggie.dao.BiomaterialList; |
3059 |
19 Dec 14 |
nicklas |
39 |
import net.sf.basedb.reggie.dao.BioplateType; |
3059 |
19 Dec 14 |
nicklas |
40 |
import net.sf.basedb.reggie.dao.DemuxedSequences; |
5358 |
12 Apr 19 |
nicklas |
41 |
import net.sf.basedb.reggie.dao.Dna; |
3844 |
14 Apr 16 |
nicklas |
42 |
import net.sf.basedb.reggie.dao.Fileserver; |
3059 |
19 Dec 14 |
nicklas |
43 |
import net.sf.basedb.reggie.dao.Histology; |
5434 |
17 May 19 |
nicklas |
44 |
import net.sf.basedb.reggie.dao.Pipeline; |
4665 |
31 Jan 18 |
nicklas |
45 |
import net.sf.basedb.reggie.dao.Rawdatatype; |
3059 |
19 Dec 14 |
nicklas |
46 |
import net.sf.basedb.reggie.dao.ReactionPlate; |
3059 |
19 Dec 14 |
nicklas |
47 |
import net.sf.basedb.reggie.dao.Rna; |
3059 |
19 Dec 14 |
nicklas |
48 |
import net.sf.basedb.reggie.dao.SequencingRun; |
3059 |
19 Dec 14 |
nicklas |
49 |
import net.sf.basedb.reggie.dao.Subtype; |
3506 |
23 Sep 15 |
nicklas |
50 |
import net.sf.basedb.reggie.pdf.GeneReportWorker; |
7171 |
15 May 23 |
nicklas |
51 |
import net.sf.basedb.reggie.plugins.TransportBoxImporter; |
6199 |
08 Apr 21 |
nicklas |
52 |
import net.sf.basedb.reggie.plugins.cmd.JsonFile; |
3059 |
19 Dec 14 |
nicklas |
53 |
import net.sf.basedb.reggie.query.AnyToAnyRestriction; |
3844 |
14 Apr 16 |
nicklas |
54 |
import net.sf.basedb.reggie.servlet.AdminServlet; |
3844 |
14 Apr 16 |
nicklas |
55 |
import net.sf.basedb.reggie.servlet.AdminServlet.RemoteFolder; |
5554 |
13 Aug 19 |
nicklas |
56 |
import net.sf.basedb.util.Values; |
3059 |
19 Dec 14 |
nicklas |
57 |
import net.sf.basedb.util.extensions.Extension; |
7076 |
27 Mar 23 |
nicklas |
58 |
import net.sf.basedb.util.extensions.logging.ExtensionsLog; |
7076 |
27 Mar 23 |
nicklas |
59 |
import net.sf.basedb.util.extensions.logging.ExtensionsLogger; |
3059 |
19 Dec 14 |
nicklas |
60 |
|
3059 |
19 Dec 14 |
nicklas |
61 |
import org.json.simple.JSONObject; |
3059 |
19 Dec 14 |
nicklas |
62 |
import org.slf4j.LoggerFactory; |
3059 |
19 Dec 14 |
nicklas |
63 |
|
3059 |
19 Dec 14 |
nicklas |
64 |
/** |
3059 |
19 Dec 14 |
nicklas |
Service for counting items at various steps in the lab |
3059 |
19 Dec 14 |
nicklas |
procedure. It will check the database at regular intervals and |
3059 |
19 Dec 14 |
nicklas |
count a lot of items. |
3059 |
19 Dec 14 |
nicklas |
68 |
|
3059 |
19 Dec 14 |
nicklas |
Note that checks are usually made in 60-minute intervals. |
3059 |
19 Dec 14 |
nicklas |
Servlets and other code that is updating items should call |
3059 |
19 Dec 14 |
nicklas |
{@link #setForceCount()} to force a count more or less immediately. |
3059 |
19 Dec 14 |
nicklas |
72 |
|
3059 |
19 Dec 14 |
nicklas |
@author nicklas |
3059 |
19 Dec 14 |
nicklas |
@since 3.0 |
3059 |
19 Dec 14 |
nicklas |
75 |
*/ |
3059 |
19 Dec 14 |
nicklas |
76 |
public class CounterService |
3059 |
19 Dec 14 |
nicklas |
77 |
{ |
3059 |
19 Dec 14 |
nicklas |
78 |
|
7076 |
27 Mar 23 |
nicklas |
79 |
private static final ExtensionsLogger logger = |
7076 |
27 Mar 23 |
nicklas |
80 |
ExtensionsLog.getLogger("net.sf.basedb.reggie.counter-service", true).wrap(LoggerFactory.getLogger(CounterService.class)); |
3059 |
19 Dec 14 |
nicklas |
81 |
|
3059 |
19 Dec 14 |
nicklas |
// The singleton |
3059 |
19 Dec 14 |
nicklas |
83 |
private static CounterService instance = null; |
3059 |
19 Dec 14 |
nicklas |
84 |
|
7076 |
27 Mar 23 |
nicklas |
// At most 60 minutes between counter updates (1 when debugging) |
7076 |
27 Mar 23 |
nicklas |
86 |
private static final long MAX_WAIT_INTERVAL_NORMAL = 60 * 60000; |
7076 |
27 Mar 23 |
nicklas |
87 |
private static final long MAX_WAIT_INTERVAL_DEBUG = 1 * 60000; |
3059 |
19 Dec 14 |
nicklas |
88 |
|
3059 |
19 Dec 14 |
nicklas |
89 |
/** |
3059 |
19 Dec 14 |
nicklas |
Get the singleton instance of the service. If the service has |
3059 |
19 Dec 14 |
nicklas |
not been created yet it is created at this time. |
3059 |
19 Dec 14 |
nicklas |
92 |
*/ |
3059 |
19 Dec 14 |
nicklas |
93 |
public static final CounterService getInstance() |
3059 |
19 Dec 14 |
nicklas |
94 |
{ |
3059 |
19 Dec 14 |
nicklas |
95 |
if (instance == null) |
3059 |
19 Dec 14 |
nicklas |
96 |
{ |
3059 |
19 Dec 14 |
nicklas |
97 |
synchronized (CounterService.class) |
3059 |
19 Dec 14 |
nicklas |
98 |
{ |
3059 |
19 Dec 14 |
nicklas |
99 |
if (instance == null) |
3059 |
19 Dec 14 |
nicklas |
100 |
{ |
3059 |
19 Dec 14 |
nicklas |
101 |
CounterService tmp = new CounterService(); |
3059 |
19 Dec 14 |
nicklas |
102 |
instance = tmp; |
3059 |
19 Dec 14 |
nicklas |
103 |
} |
3059 |
19 Dec 14 |
nicklas |
104 |
} |
3059 |
19 Dec 14 |
nicklas |
105 |
} |
3059 |
19 Dec 14 |
nicklas |
106 |
return instance; |
3059 |
19 Dec 14 |
nicklas |
107 |
} |
3059 |
19 Dec 14 |
nicklas |
108 |
|
3059 |
19 Dec 14 |
nicklas |
109 |
private volatile boolean isRunning; |
4691 |
13 Mar 18 |
nicklas |
110 |
private volatile boolean isCounting; |
3059 |
19 Dec 14 |
nicklas |
111 |
private SessionControl systemSc; |
3571 |
30 Oct 15 |
nicklas |
112 |
private Extension<ServiceControllerAction> ext; |
3059 |
19 Dec 14 |
nicklas |
113 |
private TimerTask counterTimer; |
3770 |
26 Feb 16 |
nicklas |
114 |
private YellowLabelStatistics yellowLabelStatistics; |
5554 |
13 Aug 19 |
nicklas |
115 |
private boolean disableStrayFoldersCount = false; |
3059 |
19 Dec 14 |
nicklas |
116 |
|
3059 |
19 Dec 14 |
nicklas |
// Time when last count was made |
3059 |
19 Dec 14 |
nicklas |
118 |
private volatile long lastCount; |
3059 |
19 Dec 14 |
nicklas |
// If flag is set, we force a new count |
3059 |
19 Dec 14 |
nicklas |
120 |
private volatile boolean forceCount; |
3059 |
19 Dec 14 |
nicklas |
// Store the current counts |
3059 |
19 Dec 14 |
nicklas |
122 |
private volatile JSONObject currentCounts; |
3059 |
19 Dec 14 |
nicklas |
123 |
|
3059 |
19 Dec 14 |
nicklas |
124 |
private CounterService() |
3059 |
19 Dec 14 |
nicklas |
125 |
{} |
3059 |
19 Dec 14 |
nicklas |
126 |
|
3059 |
19 Dec 14 |
nicklas |
127 |
/** |
3059 |
19 Dec 14 |
nicklas |
Is the counter service running or not? |
3059 |
19 Dec 14 |
nicklas |
129 |
*/ |
3059 |
19 Dec 14 |
nicklas |
130 |
public boolean isRunning() |
3059 |
19 Dec 14 |
nicklas |
131 |
{ |
3059 |
19 Dec 14 |
nicklas |
132 |
return isRunning; |
3059 |
19 Dec 14 |
nicklas |
133 |
} |
4691 |
13 Mar 18 |
nicklas |
134 |
|
4691 |
13 Mar 18 |
nicklas |
135 |
/** |
4691 |
13 Mar 18 |
nicklas |
Is the service currently counting or waiting? |
4691 |
13 Mar 18 |
nicklas |
@since 4.16 |
4691 |
13 Mar 18 |
nicklas |
138 |
*/ |
4691 |
13 Mar 18 |
nicklas |
139 |
public boolean isCounting() |
4691 |
13 Mar 18 |
nicklas |
140 |
{ |
4691 |
13 Mar 18 |
nicklas |
141 |
return isCounting; |
4691 |
13 Mar 18 |
nicklas |
142 |
} |
3059 |
19 Dec 14 |
nicklas |
143 |
|
3059 |
19 Dec 14 |
nicklas |
144 |
/** |
3059 |
19 Dec 14 |
nicklas |
Start the service if it is not running. |
3059 |
19 Dec 14 |
nicklas |
146 |
*/ |
3571 |
30 Oct 15 |
nicklas |
147 |
public synchronized void start(SessionControl systemSc, Extension<ServiceControllerAction> ext) |
3059 |
19 Dec 14 |
nicklas |
148 |
{ |
3059 |
19 Dec 14 |
nicklas |
149 |
if (!isRunning) |
3059 |
19 Dec 14 |
nicklas |
150 |
{ |
3059 |
19 Dec 14 |
nicklas |
151 |
logger.debug("Starting counter service"); |
3059 |
19 Dec 14 |
nicklas |
152 |
this.systemSc = systemSc; |
3059 |
19 Dec 14 |
nicklas |
153 |
this.ext = ext; |
3059 |
19 Dec 14 |
nicklas |
154 |
this.currentCounts = new JSONObject(); |
3770 |
26 Feb 16 |
nicklas |
155 |
this.yellowLabelStatistics = new YellowLabelStatistics(); |
5554 |
13 Aug 19 |
nicklas |
156 |
reloadConfig(); |
3059 |
19 Dec 14 |
nicklas |
157 |
|
3059 |
19 Dec 14 |
nicklas |
158 |
Reggie.getRootSessionControl(systemSc); |
3059 |
19 Dec 14 |
nicklas |
159 |
|
3059 |
19 Dec 14 |
nicklas |
160 |
counterTimer = Application.getScheduler().scheduleAtFixedRate( |
3059 |
19 Dec 14 |
nicklas |
161 |
new CounterTimerTask(), 1000, 1000, false); |
3059 |
19 Dec 14 |
nicklas |
162 |
|
3059 |
19 Dec 14 |
nicklas |
163 |
isRunning = true; |
3059 |
19 Dec 14 |
nicklas |
164 |
logger.debug("Counter service is now running"); |
3059 |
19 Dec 14 |
nicklas |
165 |
} |
3059 |
19 Dec 14 |
nicklas |
166 |
} |
3059 |
19 Dec 14 |
nicklas |
167 |
|
3059 |
19 Dec 14 |
nicklas |
168 |
/** |
3059 |
19 Dec 14 |
nicklas |
Stop the service if it is running. |
3059 |
19 Dec 14 |
nicklas |
170 |
*/ |
3059 |
19 Dec 14 |
nicklas |
171 |
public synchronized void stop() |
3059 |
19 Dec 14 |
nicklas |
172 |
{ |
3059 |
19 Dec 14 |
nicklas |
173 |
if (isRunning) |
3059 |
19 Dec 14 |
nicklas |
174 |
{ |
3059 |
19 Dec 14 |
nicklas |
175 |
logger.debug("Stopping counter service"); |
3059 |
19 Dec 14 |
nicklas |
176 |
isRunning = false; |
3059 |
19 Dec 14 |
nicklas |
177 |
|
3059 |
19 Dec 14 |
nicklas |
178 |
if (counterTimer != null) |
3059 |
19 Dec 14 |
nicklas |
179 |
{ |
3059 |
19 Dec 14 |
nicklas |
180 |
counterTimer.cancel(); |
3059 |
19 Dec 14 |
nicklas |
181 |
counterTimer = null; |
3059 |
19 Dec 14 |
nicklas |
182 |
} |
3059 |
19 Dec 14 |
nicklas |
183 |
systemSc = null; |
3059 |
19 Dec 14 |
nicklas |
184 |
ext = null; |
3059 |
19 Dec 14 |
nicklas |
185 |
lastCount = 0; |
3059 |
19 Dec 14 |
nicklas |
186 |
forceCount = false; |
3059 |
19 Dec 14 |
nicklas |
187 |
currentCounts = null; |
3770 |
26 Feb 16 |
nicklas |
188 |
yellowLabelStatistics = null; |
3059 |
19 Dec 14 |
nicklas |
189 |
Reggie.closeRootSessionControl(); |
3059 |
19 Dec 14 |
nicklas |
190 |
|
3059 |
19 Dec 14 |
nicklas |
191 |
logger.debug("Counter service has stopped"); |
3059 |
19 Dec 14 |
nicklas |
192 |
} |
3059 |
19 Dec 14 |
nicklas |
193 |
} |
3059 |
19 Dec 14 |
nicklas |
194 |
|
3059 |
19 Dec 14 |
nicklas |
195 |
/** |
3059 |
19 Dec 14 |
nicklas |
Restart the service. |
3059 |
19 Dec 14 |
nicklas |
197 |
*/ |
3059 |
19 Dec 14 |
nicklas |
198 |
public synchronized void restart() |
3059 |
19 Dec 14 |
nicklas |
199 |
{ |
3059 |
19 Dec 14 |
nicklas |
200 |
if (ext != null) Services.restart(ext); |
3059 |
19 Dec 14 |
nicklas |
201 |
} |
3059 |
19 Dec 14 |
nicklas |
202 |
|
3059 |
19 Dec 14 |
nicklas |
203 |
/** |
5554 |
13 Aug 19 |
nicklas |
Re-load configuration settings for the counter service. Settings are |
5554 |
13 Aug 19 |
nicklas |
stored in reggie-config.xml under the <counter-service> tag: |
5554 |
13 Aug 19 |
nicklas |
206 |
|
5554 |
13 Aug 19 |
nicklas |
<counter-service> |
5554 |
13 Aug 19 |
nicklas |
<no-stray-folders>1</no-stray-folders> // Do not check and count stray folders in the project archive |
5554 |
13 Aug 19 |
nicklas |
</counter-service> |
5554 |
13 Aug 19 |
nicklas |
@since 4.23 |
5554 |
13 Aug 19 |
nicklas |
211 |
*/ |
5554 |
13 Aug 19 |
nicklas |
212 |
public synchronized void reloadConfig() |
5554 |
13 Aug 19 |
nicklas |
213 |
{ |
5554 |
13 Aug 19 |
nicklas |
214 |
disableStrayFoldersCount = Values.getBoolean(Reggie.getConfig().getConfig("counter-service/no-stray-folders")); |
5554 |
13 Aug 19 |
nicklas |
215 |
} |
5554 |
13 Aug 19 |
nicklas |
216 |
|
5554 |
13 Aug 19 |
nicklas |
217 |
|
5554 |
13 Aug 19 |
nicklas |
218 |
/** |
3059 |
19 Dec 14 |
nicklas |
Set a flag forcing the service to perform a count at the next |
3059 |
19 Dec 14 |
nicklas |
timer event. This method should be called by servlets as soon |
3059 |
19 Dec 14 |
nicklas |
as they modify items. |
3059 |
19 Dec 14 |
nicklas |
222 |
*/ |
3059 |
19 Dec 14 |
nicklas |
223 |
public void setForceCount() |
3059 |
19 Dec 14 |
nicklas |
224 |
{ |
3059 |
19 Dec 14 |
nicklas |
225 |
this.forceCount = true; |
3059 |
19 Dec 14 |
nicklas |
226 |
} |
3059 |
19 Dec 14 |
nicklas |
227 |
|
3124 |
09 Feb 15 |
nicklas |
228 |
/** |
3124 |
09 Feb 15 |
nicklas |
Set the fource count flag and wait for the count update to complete. |
3124 |
09 Feb 15 |
nicklas |
The method will wait at most maxSeconds seconds. |
3124 |
09 Feb 15 |
nicklas |
@return TRUE if the count was updated while in this method, FALSE if not |
3124 |
09 Feb 15 |
nicklas |
@since 3.1 |
3124 |
09 Feb 15 |
nicklas |
233 |
*/ |
3124 |
09 Feb 15 |
nicklas |
234 |
public boolean setForceCountAndWait(int maxSeconds) |
3124 |
09 Feb 15 |
nicklas |
235 |
{ |
3124 |
09 Feb 15 |
nicklas |
236 |
long currentCount = lastCount; |
3124 |
09 Feb 15 |
nicklas |
237 |
long waitUntil = System.currentTimeMillis() + maxSeconds * 1000; |
3124 |
09 Feb 15 |
nicklas |
238 |
this.forceCount = true; |
3124 |
09 Feb 15 |
nicklas |
239 |
while (lastCount == currentCount && System.currentTimeMillis() < waitUntil) |
3124 |
09 Feb 15 |
nicklas |
240 |
{ |
3124 |
09 Feb 15 |
nicklas |
241 |
try |
3124 |
09 Feb 15 |
nicklas |
242 |
{ |
3124 |
09 Feb 15 |
nicklas |
243 |
Thread.sleep(500); |
3124 |
09 Feb 15 |
nicklas |
244 |
} |
3124 |
09 Feb 15 |
nicklas |
245 |
catch (InterruptedException ex) |
3124 |
09 Feb 15 |
nicklas |
246 |
{ |
3124 |
09 Feb 15 |
nicklas |
247 |
break; |
3124 |
09 Feb 15 |
nicklas |
248 |
} |
3124 |
09 Feb 15 |
nicklas |
249 |
} |
3124 |
09 Feb 15 |
nicklas |
250 |
return currentCount != lastCount; |
3124 |
09 Feb 15 |
nicklas |
251 |
} |
3124 |
09 Feb 15 |
nicklas |
252 |
|
3124 |
09 Feb 15 |
nicklas |
253 |
/** |
3124 |
09 Feb 15 |
nicklas |
Get the current counts. |
3124 |
09 Feb 15 |
nicklas |
255 |
*/ |
3059 |
19 Dec 14 |
nicklas |
256 |
public JSONObject getCurrentCounts() |
3059 |
19 Dec 14 |
nicklas |
257 |
{ |
3059 |
19 Dec 14 |
nicklas |
258 |
return currentCounts; |
3059 |
19 Dec 14 |
nicklas |
259 |
} |
3059 |
19 Dec 14 |
nicklas |
260 |
|
3059 |
19 Dec 14 |
nicklas |
261 |
/** |
3124 |
09 Feb 15 |
nicklas |
Get the timestamp of the current counts. |
3124 |
09 Feb 15 |
nicklas |
@since 3.1 |
3124 |
09 Feb 15 |
nicklas |
264 |
*/ |
3124 |
09 Feb 15 |
nicklas |
265 |
public long getCurrentCountTime() |
3124 |
09 Feb 15 |
nicklas |
266 |
{ |
3124 |
09 Feb 15 |
nicklas |
267 |
return lastCount; |
3124 |
09 Feb 15 |
nicklas |
268 |
} |
3124 |
09 Feb 15 |
nicklas |
269 |
|
3124 |
09 Feb 15 |
nicklas |
270 |
/** |
3770 |
26 Feb 16 |
nicklas |
Get statistics about YellowLabel specimen. |
3770 |
26 Feb 16 |
nicklas |
@since 4.2 |
3770 |
26 Feb 16 |
nicklas |
273 |
*/ |
3770 |
26 Feb 16 |
nicklas |
274 |
public YellowLabelStatistics getYellowLabelStatistics() |
3770 |
26 Feb 16 |
nicklas |
275 |
{ |
3770 |
26 Feb 16 |
nicklas |
276 |
return yellowLabelStatistics; |
3770 |
26 Feb 16 |
nicklas |
277 |
} |
3770 |
26 Feb 16 |
nicklas |
278 |
|
3770 |
26 Feb 16 |
nicklas |
279 |
/** |
3844 |
14 Apr 16 |
nicklas |
Update the count of stray folders. |
3844 |
14 Apr 16 |
nicklas |
281 |
*/ |
3844 |
14 Apr 16 |
nicklas |
282 |
public void setStrayFoldersCount(int numStrayFolders) |
3844 |
14 Apr 16 |
nicklas |
283 |
{ |
4306 |
17 Jan 17 |
nicklas |
284 |
if (currentCounts == null) return; |
3844 |
14 Apr 16 |
nicklas |
285 |
currentCounts.put("stray-folders", numStrayFolders); |
3844 |
14 Apr 16 |
nicklas |
286 |
} |
3844 |
14 Apr 16 |
nicklas |
287 |
|
3844 |
14 Apr 16 |
nicklas |
288 |
/** |
3059 |
19 Dec 14 |
nicklas |
Perform a count. Note that this method may return without doing |
3059 |
19 Dec 14 |
nicklas |
anything depending on how long time it was since the last count and if |
3059 |
19 Dec 14 |
nicklas |
the {@link #setForceCount()} has been called or not. |
3059 |
19 Dec 14 |
nicklas |
292 |
*/ |
3059 |
19 Dec 14 |
nicklas |
293 |
void count() |
3059 |
19 Dec 14 |
nicklas |
294 |
{ |
3059 |
19 Dec 14 |
nicklas |
295 |
long now = System.currentTimeMillis(); |
3059 |
19 Dec 14 |
nicklas |
296 |
long timeSinceLastCheck = now - lastCount; |
3059 |
19 Dec 14 |
nicklas |
297 |
|
3059 |
19 Dec 14 |
nicklas |
// If we have not waited long enough and there there is no recent request we don't have to check |
7076 |
27 Mar 23 |
nicklas |
299 |
long maxWaitInterval = logger.isDebugEnabled() ? MAX_WAIT_INTERVAL_DEBUG : MAX_WAIT_INTERVAL_NORMAL; |
7076 |
27 Mar 23 |
nicklas |
300 |
if (timeSinceLastCheck < maxWaitInterval && !forceCount) |
3059 |
19 Dec 14 |
nicklas |
301 |
{ |
7076 |
27 Mar 23 |
nicklas |
302 |
logger.trace("No count since no recent change and not long enough wait time [" + (timeSinceLastCheck / 1000) + " seconds]"); |
3059 |
19 Dec 14 |
nicklas |
303 |
return; |
3059 |
19 Dec 14 |
nicklas |
304 |
} |
3059 |
19 Dec 14 |
nicklas |
305 |
|
3059 |
19 Dec 14 |
nicklas |
306 |
forceCount = false; |
7076 |
27 Mar 23 |
nicklas |
307 |
logger.debug("Time for count [" + (timeSinceLastCheck / 1000) + " seconds]"); |
3059 |
19 Dec 14 |
nicklas |
308 |
int numItems = 0; |
3059 |
19 Dec 14 |
nicklas |
309 |
|
3059 |
19 Dec 14 |
nicklas |
310 |
SessionControl sc = Reggie.getRootSessionControl(systemSc); |
3059 |
19 Dec 14 |
nicklas |
311 |
DbControl dc = null; |
3059 |
19 Dec 14 |
nicklas |
312 |
try |
3059 |
19 Dec 14 |
nicklas |
313 |
{ |
6599 |
22 Feb 22 |
nicklas |
314 |
dc = sc.newDbControl("Reggie: Counter service"); |
4691 |
13 Mar 18 |
nicklas |
315 |
isCounting = true; |
3059 |
19 Dec 14 |
nicklas |
316 |
JSONObject json = new JSONObject(); |
3059 |
19 Dec 14 |
nicklas |
317 |
countPatients(dc, json); |
3085 |
15 Jan 15 |
olle |
318 |
countPatientsReadyForRetractionFollowUp(dc, json); |
3085 |
15 Jan 15 |
olle |
319 |
countPatientsReadyForDestruction(dc, json); |
3059 |
19 Dec 14 |
nicklas |
320 |
countSpecimen(dc, json); |
7076 |
27 Mar 23 |
nicklas |
321 |
countHistology(dc, json); |
3059 |
19 Dec 14 |
nicklas |
322 |
countExtracts(dc, json); |
7076 |
27 Mar 23 |
nicklas |
323 |
countLibraries(dc, json); |
3059 |
19 Dec 14 |
nicklas |
324 |
countBioPlates(dc, json); |
3059 |
19 Dec 14 |
nicklas |
325 |
countPhysicalBioAssays(dc, json); |
3059 |
19 Dec 14 |
nicklas |
326 |
countDerivedBioAssays(dc, json); |
7076 |
27 Mar 23 |
nicklas |
327 |
countRawBioAssays(dc, json); |
3059 |
19 Dec 14 |
nicklas |
328 |
countJobs(dc, json); |
4138 |
29 Sep 16 |
nicklas |
329 |
countItemLists(dc, json); |
6177 |
23 Mar 21 |
nicklas |
330 |
countImportFiles(dc, json); |
3844 |
14 Apr 16 |
nicklas |
331 |
|
3844 |
14 Apr 16 |
nicklas |
// Some counts are NOT updated as a result of the forceCount flag |
7076 |
27 Mar 23 |
nicklas |
333 |
if (timeSinceLastCheck > maxWaitInterval) |
3844 |
14 Apr 16 |
nicklas |
334 |
{ |
7076 |
27 Mar 23 |
nicklas |
335 |
if (!disableStrayFoldersCount) |
7076 |
27 Mar 23 |
nicklas |
336 |
{ |
7076 |
27 Mar 23 |
nicklas |
337 |
logger.debug("Counting stray folders"); |
7076 |
27 Mar 23 |
nicklas |
338 |
int numFolders = countStrayFolders(dc, json); |
7076 |
27 Mar 23 |
nicklas |
339 |
logger.info("Stray folders counted: "+numFolders); |
7076 |
27 Mar 23 |
nicklas |
340 |
} |
7076 |
27 Mar 23 |
nicklas |
341 |
else |
7076 |
27 Mar 23 |
nicklas |
342 |
{ |
7076 |
27 Mar 23 |
nicklas |
343 |
logger.info("Counting of stray folders is disabled in config"); |
7076 |
27 Mar 23 |
nicklas |
344 |
} |
3844 |
14 Apr 16 |
nicklas |
345 |
} |
3844 |
14 Apr 16 |
nicklas |
346 |
else |
3844 |
14 Apr 16 |
nicklas |
347 |
{ |
3844 |
14 Apr 16 |
nicklas |
// These must be copied from the old count instead |
3844 |
14 Apr 16 |
nicklas |
349 |
json.put("stray-folders", currentCounts.get("stray-folders")); |
3844 |
14 Apr 16 |
nicklas |
350 |
} |
3844 |
14 Apr 16 |
nicklas |
351 |
lastCount = now; |
3770 |
26 Feb 16 |
nicklas |
352 |
currentCounts = json; |
3059 |
19 Dec 14 |
nicklas |
353 |
|
3770 |
26 Feb 16 |
nicklas |
// YellowLabel statistics |
3770 |
26 Feb 16 |
nicklas |
355 |
yellowLabelStatistics.updateStatistics(dc); |
3770 |
26 Feb 16 |
nicklas |
356 |
|
3770 |
26 Feb 16 |
nicklas |
357 |
dc.commit(); |
3059 |
19 Dec 14 |
nicklas |
358 |
} |
3059 |
19 Dec 14 |
nicklas |
359 |
finally |
3059 |
19 Dec 14 |
nicklas |
360 |
{ |
4691 |
13 Mar 18 |
nicklas |
361 |
isCounting = false; |
3059 |
19 Dec 14 |
nicklas |
362 |
lastCount = System.currentTimeMillis(); |
3059 |
19 Dec 14 |
nicklas |
363 |
if (dc != null) dc.close(); |
7076 |
27 Mar 23 |
nicklas |
364 |
logger.info("Count complete"); |
3059 |
19 Dec 14 |
nicklas |
365 |
} |
3059 |
19 Dec 14 |
nicklas |
366 |
} |
3059 |
19 Dec 14 |
nicklas |
367 |
|
3059 |
19 Dec 14 |
nicklas |
368 |
|
3059 |
19 Dec 14 |
nicklas |
369 |
private void countPatients(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
370 |
{ |
3059 |
19 Dec 14 |
nicklas |
// All patients |
3059 |
19 Dec 14 |
nicklas |
372 |
ItemQuery<BioSource> query = BioSource.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
373 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
374 |
Subtype.PATIENT.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
375 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
376 |
json.put("patients-all", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
377 |
} |
3059 |
19 Dec 14 |
nicklas |
378 |
|
3085 |
15 Jan 15 |
olle |
379 |
private void countPatientsReadyForRetractionFollowUp(DbControl dc, JSONObject json) |
3085 |
15 Jan 15 |
olle |
380 |
{ |
3085 |
15 Jan 15 |
olle |
// All "Retract" and "RetroNo" biosource items with annotation RETRACT_STATUS set to 'null' |
3085 |
15 Jan 15 |
olle |
382 |
ItemQuery<BioSource> query = BioSource.getQuery(); |
3085 |
15 Jan 15 |
olle |
383 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3085 |
15 Jan 15 |
olle |
// ...only include 'Retract' and 'RetroNo' items |
3085 |
15 Jan 15 |
olle |
385 |
query.restrict( |
3085 |
15 Jan 15 |
olle |
386 |
Restrictions.or( |
3085 |
15 Jan 15 |
olle |
387 |
Subtype.RETRACT.restriction(dc, null), |
3085 |
15 Jan 15 |
olle |
388 |
Subtype.RETRO_NO.restriction(dc, null) |
3085 |
15 Jan 15 |
olle |
389 |
)); |
3085 |
15 Jan 15 |
olle |
// Value 'null' for RETRACT_STATUS annotation |
3085 |
15 Jan 15 |
olle |
391 |
query.join(Annotations.leftJoin(null, Annotationtype.RETRACT_STATUS.load(dc), "rs")); |
3085 |
15 Jan 15 |
olle |
392 |
query.restrict( |
3085 |
15 Jan 15 |
olle |
393 |
Restrictions.eq(Hql.alias("rs"), null) |
3085 |
15 Jan 15 |
olle |
394 |
); |
3085 |
15 Jan 15 |
olle |
395 |
query.setCacheResult(true); |
3085 |
15 Jan 15 |
olle |
396 |
json.put("patientitems-ready-for-retraction-followup", query.count(dc)); |
3085 |
15 Jan 15 |
olle |
397 |
} |
3085 |
15 Jan 15 |
olle |
398 |
|
3085 |
15 Jan 15 |
olle |
399 |
private void countPatientsReadyForDestruction(DbControl dc, JSONObject json) |
3085 |
15 Jan 15 |
olle |
400 |
{ |
3085 |
15 Jan 15 |
olle |
// All "Retract" and "RetroNo" biosource items with annotation RETRACT_STATUS set to "ReadyForDestruction" |
3085 |
15 Jan 15 |
olle |
402 |
ItemQuery<BioSource> query = BioSource.getQuery(); |
3085 |
15 Jan 15 |
olle |
403 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3085 |
15 Jan 15 |
olle |
// ...only include 'Retract' and 'RetroNo' items |
3085 |
15 Jan 15 |
olle |
405 |
query.restrict( |
3085 |
15 Jan 15 |
olle |
406 |
Restrictions.or( |
3085 |
15 Jan 15 |
olle |
407 |
Subtype.RETRACT.restriction(dc, null), |
3085 |
15 Jan 15 |
olle |
408 |
Subtype.RETRO_NO.restriction(dc, null) |
3085 |
15 Jan 15 |
olle |
409 |
)); |
3085 |
15 Jan 15 |
olle |
// Value "ReadyForDestruction" for RETRACT_STATUS annotation |
3085 |
15 Jan 15 |
olle |
411 |
query.join(Annotations.leftJoin(null, Annotationtype.RETRACT_STATUS.load(dc), "rs")); |
3085 |
15 Jan 15 |
olle |
412 |
query.restrict( |
3085 |
15 Jan 15 |
olle |
413 |
Restrictions.eq(Hql.alias("rs"), Expressions.string("ReadyForDestruction")) |
3085 |
15 Jan 15 |
olle |
414 |
); |
3085 |
15 Jan 15 |
olle |
415 |
query.setCacheResult(true); |
3085 |
15 Jan 15 |
olle |
416 |
json.put("patientitems-ready-for-destruction", query.count(dc)); |
3085 |
15 Jan 15 |
olle |
417 |
} |
3085 |
15 Jan 15 |
olle |
418 |
|
3059 |
19 Dec 14 |
nicklas |
419 |
private void countSpecimen(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
420 |
{ |
3059 |
19 Dec 14 |
nicklas |
// All specimen tubes |
3059 |
19 Dec 14 |
nicklas |
422 |
ItemQuery<Sample> query = Sample.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
423 |
Subtype.SPECIMEN.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
424 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
425 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
426 |
json.put("specimen-all", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
427 |
|
6510 |
03 Dec 21 |
nicklas |
// Specimen tubes not linked to a Case |
6510 |
03 Dec 21 |
nicklas |
429 |
query = Sample.getQuery(); |
6510 |
03 Dec 21 |
nicklas |
430 |
Subtype.SPECIMEN.addFilter(dc, query); |
6510 |
03 Dec 21 |
nicklas |
431 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6510 |
03 Dec 21 |
nicklas |
432 |
query.restrict(Restrictions.eq(Hql.property("parent"), null)); |
6510 |
03 Dec 21 |
nicklas |
// Filter on externalId to get rid of external samples that never get a parent item |
6510 |
03 Dec 21 |
nicklas |
434 |
query.restrict(Restrictions.like(Hql.property("externalId"), Expressions.string(Subtype.SPECIMEN.getExternalIdPrefix()+"%"))); |
6510 |
03 Dec 21 |
nicklas |
435 |
query.setCacheResult(true); |
6510 |
03 Dec 21 |
nicklas |
436 |
long specimenAllWithNoCase = query.count(dc); |
6510 |
03 Dec 21 |
nicklas |
437 |
|
6510 |
03 Dec 21 |
nicklas |
// Specimen tubes not linked to a Case that have an ExternalRef annotation |
6510 |
03 Dec 21 |
nicklas |
439 |
query = Sample.getQuery(); |
6510 |
03 Dec 21 |
nicklas |
440 |
Subtype.SPECIMEN.addFilter(dc, query); |
6510 |
03 Dec 21 |
nicklas |
441 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6510 |
03 Dec 21 |
nicklas |
442 |
query.restrict(Restrictions.eq(Hql.property("parent"), null)); |
6510 |
03 Dec 21 |
nicklas |
// Filter on externalId to get rid of external samples that never get a parent item |
6510 |
03 Dec 21 |
nicklas |
444 |
query.restrict(Restrictions.like(Hql.property("externalId"), Expressions.string(Subtype.SPECIMEN.getExternalIdPrefix()+"%"))); |
6510 |
03 Dec 21 |
nicklas |
// ExternaRef not null |
6510 |
03 Dec 21 |
nicklas |
446 |
query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref")); |
6510 |
03 Dec 21 |
nicklas |
447 |
query.setCacheResult(true); |
6510 |
03 Dec 21 |
nicklas |
448 |
long specimenExternalWithNoCase = query.count(dc); |
6510 |
03 Dec 21 |
nicklas |
449 |
json.put("specimen-local-without-case", specimenAllWithNoCase - specimenExternalWithNoCase); |
6510 |
03 Dec 21 |
nicklas |
450 |
json.put("specimen-external-without-case", specimenExternalWithNoCase); |
6510 |
03 Dec 21 |
nicklas |
451 |
|
3059 |
19 Dec 14 |
nicklas |
// Specimen tubes to be partitioned |
3059 |
19 Dec 14 |
nicklas |
453 |
query = Sample.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
454 |
Subtype.SPECIMEN.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
455 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
456 |
query.restrict(Restrictions.eq(Hql.property("originalQuantity"), null)); |
3059 |
19 Dec 14 |
nicklas |
457 |
query.restrict(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("Sp%"))); |
3059 |
19 Dec 14 |
nicklas |
458 |
query.join(Hql.leftJoin("childCreationEvents", "cce")); |
3059 |
19 Dec 14 |
nicklas |
459 |
query.restrict(Restrictions.eq(Hql.alias("cce"), null)); |
3059 |
19 Dec 14 |
nicklas |
460 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
461 |
json.put("specimen-for-partition", query.count(dc)); |
5336 |
28 Mar 19 |
nicklas |
462 |
|
5336 |
28 Mar 19 |
nicklas |
// Specimen tubes that are paused but not stored |
5336 |
28 Mar 19 |
nicklas |
464 |
query = Sample.getQuery(); |
5336 |
28 Mar 19 |
nicklas |
465 |
Subtype.SPECIMEN.addFilter(dc, query); |
5336 |
28 Mar 19 |
nicklas |
466 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5336 |
28 Mar 19 |
nicklas |
// Located in PSpNNN storage box |
5336 |
28 Mar 19 |
nicklas |
468 |
query.restrict(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("PSp%"))); |
5336 |
28 Mar 19 |
nicklas |
// AutoProcessing = null |
5336 |
28 Mar 19 |
nicklas |
470 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
5336 |
28 Mar 19 |
nicklas |
471 |
query.restrict(Restrictions.eq(Hql.alias("ap"), null)); |
5336 |
28 Mar 19 |
nicklas |
472 |
query.setCacheResult(true); |
5336 |
28 Mar 19 |
nicklas |
473 |
json.put("paused-specimen-to-store", query.count(dc)); |
3144 |
24 Feb 15 |
nicklas |
474 |
|
3144 |
24 Feb 15 |
nicklas |
// Specimen tubes to be re-partitioned |
3144 |
24 Feb 15 |
nicklas |
476 |
query = Sample.getQuery(); |
3144 |
24 Feb 15 |
nicklas |
477 |
Subtype.SPECIMEN.addFilter(dc, query); |
3144 |
24 Feb 15 |
nicklas |
478 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3144 |
24 Feb 15 |
nicklas |
// Join AutoProcessing annotation |
3144 |
24 Feb 15 |
nicklas |
480 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3144 |
24 Feb 15 |
nicklas |
481 |
query.restrict(Restrictions.eq(Hql.alias("ap"), Expressions.string("ReProcess"))); |
3059 |
19 Dec 14 |
nicklas |
482 |
|
3144 |
24 Feb 15 |
nicklas |
483 |
query.setCacheResult(true); |
3144 |
24 Feb 15 |
nicklas |
484 |
json.put("specimen-for-reextraction", query.count(dc)); |
3144 |
24 Feb 15 |
nicklas |
485 |
|
5337 |
29 Mar 19 |
nicklas |
// Specimen tubes that are paused and stored |
5337 |
29 Mar 19 |
nicklas |
487 |
query = Sample.getQuery(); |
5337 |
29 Mar 19 |
nicklas |
488 |
Subtype.SPECIMEN.addFilter(dc, query); |
5337 |
29 Mar 19 |
nicklas |
489 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5337 |
29 Mar 19 |
nicklas |
// Located in PSpNNN storage box |
5337 |
29 Mar 19 |
nicklas |
491 |
query.restrict(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("PSp%"))); |
5337 |
29 Mar 19 |
nicklas |
// AutoProcessing = Disable |
5337 |
29 Mar 19 |
nicklas |
493 |
query.join(Annotations.innerJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
5341 |
02 Apr 19 |
nicklas |
494 |
query.restrict(Restrictions.in(Hql.alias("ap"), Expressions.string("Disable"), Expressions.string("ReProcess"))); |
5337 |
29 Mar 19 |
nicklas |
495 |
query.setCacheResult(true); |
5337 |
29 Mar 19 |
nicklas |
496 |
json.put("paused-specimen", query.count(dc)); |
5337 |
29 Mar 19 |
nicklas |
497 |
|
3783 |
16 Mar 16 |
nicklas |
// Specimen with active YellowLabel |
3783 |
16 Mar 16 |
nicklas |
499 |
query = Sample.getQuery(); |
3783 |
16 Mar 16 |
nicklas |
500 |
Subtype.SPECIMEN.addFilter(dc, query); |
3783 |
16 Mar 16 |
nicklas |
501 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3783 |
16 Mar 16 |
nicklas |
// Must have YellowLabel annotation |
3783 |
16 Mar 16 |
nicklas |
503 |
query.join(Annotations.innerJoin(Annotationtype.YELLOW_LABEL.get(dc), "yl")); |
3784 |
16 Mar 16 |
nicklas |
// Must not have CompletedDate annotation |
3784 |
16 Mar 16 |
nicklas |
505 |
query.join(Annotations.leftJoin(Annotationtype.COMPLETED_DATE.get(dc), "cd")); |
3784 |
16 Mar 16 |
nicklas |
506 |
query.restrict(Restrictions.eq(Hql.alias("cd"), null)); |
5334 |
28 Mar 19 |
nicklas |
// Must be in an 'Sp' storage box |
5334 |
28 Mar 19 |
nicklas |
508 |
query.restrict(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("Sp%"))); |
3783 |
16 Mar 16 |
nicklas |
509 |
query.setCacheResult(true); |
3783 |
16 Mar 16 |
nicklas |
510 |
json.put("specimen-active-yellow-label", query.count(dc)); |
3847 |
14 Apr 16 |
nicklas |
511 |
|
3847 |
14 Apr 16 |
nicklas |
// Cases+blood without consent |
3847 |
14 Apr 16 |
nicklas |
513 |
query = Sample.getQuery(); |
3847 |
14 Apr 16 |
nicklas |
514 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3847 |
14 Apr 16 |
nicklas |
515 |
query.restrict(Restrictions.or( |
3847 |
14 Apr 16 |
nicklas |
516 |
Subtype.CASE.restriction(dc, null), |
3847 |
14 Apr 16 |
nicklas |
517 |
Subtype.BLOOD.restriction(dc, null) |
3847 |
14 Apr 16 |
nicklas |
518 |
)); |
3847 |
14 Apr 16 |
nicklas |
// Must NOT have a CONSENT annotation |
3847 |
14 Apr 16 |
nicklas |
520 |
query.join(Annotations.leftJoin(Annotationtype.CONSENT.get(dc), "cns")); |
3847 |
14 Apr 16 |
nicklas |
521 |
query.restrict(Restrictions.eq(Hql.alias("cns"), null)); |
3847 |
14 Apr 16 |
nicklas |
522 |
query.setCacheResult(true); |
3847 |
14 Apr 16 |
nicklas |
523 |
json.put("case-or-blood-without-consent", query.count(dc)); |
6582 |
11 Feb 22 |
nicklas |
524 |
|
6582 |
11 Feb 22 |
nicklas |
// NoSpecimen with ExternalSpecimenExists=Yes |
6582 |
11 Feb 22 |
nicklas |
526 |
query = Sample.getQuery(); |
6582 |
11 Feb 22 |
nicklas |
527 |
Subtype.NO_SPECIMEN.addFilter(dc, query); |
6582 |
11 Feb 22 |
nicklas |
528 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6582 |
11 Feb 22 |
nicklas |
// Must have ExternalSpecimenExists=Yes annotation |
6582 |
11 Feb 22 |
nicklas |
530 |
query.join(Annotations.innerJoin(Annotationtype.EXTERNAL_SPECIMEN_EXISTS.get(dc), "es")); |
6582 |
11 Feb 22 |
nicklas |
531 |
query.restrict(Restrictions.eq(Hql.alias("es"), Expressions.string("Yes"))); |
6582 |
11 Feb 22 |
nicklas |
532 |
query.setCacheResult(true); |
7165 |
12 May 23 |
nicklas |
533 |
long externalSpecimenExists = query.count(dc); |
7165 |
12 May 23 |
nicklas |
534 |
json.put("nospecimen-with-external-specimen", externalSpecimenExists); |
6582 |
11 Feb 22 |
nicklas |
535 |
|
7167 |
12 May 23 |
nicklas |
// Specimen with ExternalSpecimenExists=Yes and no assigned storage box location |
7165 |
12 May 23 |
nicklas |
537 |
query = Sample.getQuery(); |
7165 |
12 May 23 |
nicklas |
538 |
Subtype.SPECIMEN.addFilter(dc, query); |
7165 |
12 May 23 |
nicklas |
539 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
7165 |
12 May 23 |
nicklas |
// Must have ExternalSpecimenExists=Yes annotation |
7165 |
12 May 23 |
nicklas |
541 |
query.join(Annotations.innerJoin(Annotationtype.EXTERNAL_SPECIMEN_EXISTS.get(dc), "es")); |
7165 |
12 May 23 |
nicklas |
542 |
query.restrict(Restrictions.eq(Hql.alias("es"), Expressions.string("Yes"))); |
7167 |
12 May 23 |
nicklas |
// But no assigned storage location |
7167 |
12 May 23 |
nicklas |
544 |
query.restrict(Restrictions.eq(Hql.property("bioWell"), null)); |
7165 |
12 May 23 |
nicklas |
545 |
query.setCacheResult(true); |
7165 |
12 May 23 |
nicklas |
546 |
externalSpecimenExists += query.count(dc); |
7165 |
12 May 23 |
nicklas |
547 |
json.put("items-with-external-specimen", externalSpecimenExists); |
3059 |
19 Dec 14 |
nicklas |
548 |
} |
3059 |
19 Dec 14 |
nicklas |
549 |
|
3059 |
19 Dec 14 |
nicklas |
550 |
private void countExtracts(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
551 |
{ |
3059 |
19 Dec 14 |
nicklas |
// Lysates waiting for AllPrep |
3059 |
19 Dec 14 |
nicklas |
553 |
ItemQuery<Extract> query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
554 |
Subtype.LYSATE.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
555 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Filter on created date |
3059 |
19 Dec 14 |
nicklas |
557 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
558 |
query.restrict(Restrictions.eq(Hql.property("ce", "eventDate"), null)); |
7170 |
15 May 23 |
nicklas |
// AutoProcessing must not be set |
7170 |
15 May 23 |
nicklas |
560 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
7170 |
15 May 23 |
nicklas |
561 |
query.restrict(Restrictions.eq(Hql.alias("ap"), null)); |
3059 |
19 Dec 14 |
nicklas |
562 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
563 |
json.put("lysates-for-allprep", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
564 |
// --- |
3059 |
19 Dec 14 |
nicklas |
565 |
|
4087 |
07 Sep 16 |
nicklas |
// Lysate to be picked for re-extraction |
4087 |
07 Sep 16 |
nicklas |
567 |
query = Extract.getQuery(); |
4087 |
07 Sep 16 |
nicklas |
568 |
Subtype.LYSATE.addFilter(dc, query); |
4087 |
07 Sep 16 |
nicklas |
569 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6722 |
04 May 22 |
nicklas |
// Must NOT be in a ExtraLys* box (moved to ExtraLys* after picking) |
6722 |
04 May 22 |
nicklas |
571 |
query.restrict(Restrictions.not(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("ExtraLys%")))); |
4087 |
07 Sep 16 |
nicklas |
// Join AutoProcessing annotation |
4087 |
07 Sep 16 |
nicklas |
573 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
4087 |
07 Sep 16 |
nicklas |
574 |
query.restrict(Restrictions.eq(Hql.alias("ap"), Expressions.string("ReProcess"))); |
4087 |
07 Sep 16 |
nicklas |
575 |
query.setCacheResult(true); |
4087 |
07 Sep 16 |
nicklas |
576 |
json.put("lysates-to-pick-for-reextraction", query.count(dc)); |
4087 |
07 Sep 16 |
nicklas |
577 |
|
4087 |
07 Sep 16 |
nicklas |
// Lysate already picked for re-extraction |
4087 |
07 Sep 16 |
nicklas |
579 |
query = Extract.getQuery(); |
4087 |
07 Sep 16 |
nicklas |
580 |
Subtype.LYSATE.addFilter(dc, query); |
4087 |
07 Sep 16 |
nicklas |
581 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4087 |
07 Sep 16 |
nicklas |
// Must be in a ExtraLys* box |
4087 |
07 Sep 16 |
nicklas |
583 |
query.restrict(Restrictions.like(Hql.property("bioWell.bioPlate.name"), Expressions.string("ExtraLys%"))); |
4087 |
07 Sep 16 |
nicklas |
// Join AutoProcessing annotation |
4087 |
07 Sep 16 |
nicklas |
585 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
4087 |
07 Sep 16 |
nicklas |
586 |
query.restrict(Restrictions.eq(Hql.alias("ap"), Expressions.string("ReProcess"))); |
4087 |
07 Sep 16 |
nicklas |
587 |
query.setCacheResult(true); |
4087 |
07 Sep 16 |
nicklas |
588 |
json.put("lysates-picked-for-rextraction", query.count(dc)); |
4087 |
07 Sep 16 |
nicklas |
589 |
|
3059 |
19 Dec 14 |
nicklas |
// All RNA that has been extracted |
3059 |
19 Dec 14 |
nicklas |
591 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
592 |
Subtype.RNA.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
593 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a creation date and a parent (to get rid of stratagene) |
3059 |
19 Dec 14 |
nicklas |
// Filter on creation date==null and parent != null (eg. to get rid of 'Stratagene') |
3059 |
19 Dec 14 |
nicklas |
596 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
597 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
598 |
query.restrict(Restrictions.neq(Hql.property("parent"), null)); |
3059 |
19 Dec 14 |
nicklas |
599 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
600 |
json.put("rna-all-extracted", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
601 |
// --- |
3059 |
19 Dec 14 |
nicklas |
602 |
|
3059 |
19 Dec 14 |
nicklas |
// RNA that is waiting for pre-normalization |
3059 |
19 Dec 14 |
nicklas |
604 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
605 |
Subtype.RNA.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
606 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Join AutoProcessing annotation |
5358 |
12 Apr 19 |
nicklas |
608 |
query.join(Annotations.innerJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
609 |
query.restrict(Restrictions.eq(Hql.alias("ap"), Expressions.string(Rna.AUTO_PROCESSING_PRE_NORMALIZE))); |
3059 |
19 Dec 14 |
nicklas |
610 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
611 |
json.put("rna-to-normalize", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
612 |
// --- |
3059 |
19 Dec 14 |
nicklas |
613 |
|
5358 |
12 Apr 19 |
nicklas |
// DNA that is waiting for pre-normalization |
5358 |
12 Apr 19 |
nicklas |
615 |
query = Extract.getQuery(); |
5358 |
12 Apr 19 |
nicklas |
616 |
Subtype.DNA.addFilter(dc, query); |
5358 |
12 Apr 19 |
nicklas |
617 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5358 |
12 Apr 19 |
nicklas |
// Join AutoProcessing annotation |
5358 |
12 Apr 19 |
nicklas |
619 |
query.join(Annotations.innerJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
5358 |
12 Apr 19 |
nicklas |
620 |
query.restrict(Restrictions.eq(Hql.alias("ap"), Expressions.string(Dna.AUTO_PROCESSING_PRE_NORMALIZE))); |
5358 |
12 Apr 19 |
nicklas |
621 |
query.setCacheResult(true); |
5358 |
12 Apr 19 |
nicklas |
622 |
json.put("dna-to-normalize", query.count(dc)); |
5358 |
12 Apr 19 |
nicklas |
623 |
// --- |
5358 |
12 Apr 19 |
nicklas |
624 |
|
3059 |
19 Dec 14 |
nicklas |
// RNA that has not yet any RNAQC child item |
3059 |
19 Dec 14 |
nicklas |
626 |
ItemQuery<Extract> subquery = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
627 |
Subtype.RNA.addFilter(dc, subquery); |
3059 |
19 Dec 14 |
nicklas |
628 |
subquery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Join child items and filter on RNAQC subtype |
3059 |
19 Dec 14 |
nicklas |
630 |
subquery.join(Hql.innerJoin("childCreationEvents", "cce")); |
3059 |
19 Dec 14 |
nicklas |
631 |
subquery.join(Hql.innerJoin("cce", "event", "evt", null, false)); |
3059 |
19 Dec 14 |
nicklas |
632 |
subquery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false)); |
3059 |
19 Dec 14 |
nicklas |
633 |
Subtype.RNAQC.addFilter(dc, subquery, "bm"); |
3059 |
19 Dec 14 |
nicklas |
634 |
|
3059 |
19 Dec 14 |
nicklas |
635 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
636 |
Subtype.RNA.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
637 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Filter on id not equal to any that has a RNAQC child |
3059 |
19 Dec 14 |
nicklas |
639 |
query.restrict(Restrictions.neq(Hql.property("id"), Expressions.all(subquery))); |
3059 |
19 Dec 14 |
nicklas |
// Filter on creation date==null and parent != null (eg. to get rid of 'Stratagene') |
3059 |
19 Dec 14 |
nicklas |
641 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
642 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
643 |
query.restrict(Restrictions.neq(Hql.property("parent"), null)); |
3059 |
19 Dec 14 |
nicklas |
644 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
645 |
json.put("rna-without-rnaqc", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
646 |
// --- |
3059 |
19 Dec 14 |
nicklas |
647 |
|
3317 |
08 May 15 |
nicklas |
// RNA that has no mRNA/Library child item (and has not been disabled for auto-processing) |
3059 |
19 Dec 14 |
nicklas |
649 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
650 |
Subtype.RNA.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
651 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Filter for non-empty creation date |
3059 |
19 Dec 14 |
nicklas |
653 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
654 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Filter on parent != null (to get rid of 'Stratagene') |
3059 |
19 Dec 14 |
nicklas |
656 |
query.restrict(Restrictions.neq(Hql.property("parent"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Join AUTO_PROCESSING annotation |
3059 |
19 Dec 14 |
nicklas |
658 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
659 |
|
3317 |
08 May 15 |
nicklas |
// Create a subquery that load all RNA extracts that has at least one mRNA or Library child extract |
3059 |
19 Dec 14 |
nicklas |
661 |
ItemQuery<Extract> mrnaQuery = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
662 |
Subtype.RNA.addFilter(dc, mrnaQuery); |
3059 |
19 Dec 14 |
nicklas |
663 |
mrnaQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Join child items and filter on mRNA subtype |
3059 |
19 Dec 14 |
nicklas |
665 |
mrnaQuery.join(Hql.innerJoin("childCreationEvents", "cce")); |
3059 |
19 Dec 14 |
nicklas |
666 |
mrnaQuery.join(Hql.innerJoin("cce", "event", "evt", null, false)); |
3059 |
19 Dec 14 |
nicklas |
667 |
mrnaQuery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false)); |
3317 |
08 May 15 |
nicklas |
668 |
mrnaQuery.restrict(Restrictions.or( |
3317 |
08 May 15 |
nicklas |
669 |
Subtype.MRNA.restriction(dc, "bm"), |
3317 |
08 May 15 |
nicklas |
670 |
Subtype.LIBRARY.restriction(dc, "bm") |
3317 |
08 May 15 |
nicklas |
671 |
)); |
3059 |
19 Dec 14 |
nicklas |
672 |
|
3317 |
08 May 15 |
nicklas |
/* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND <no mrna/library children>) */ |
3059 |
19 Dec 14 |
nicklas |
674 |
Expression autoProcessing = Hql.alias("ap"); |
3059 |
19 Dec 14 |
nicklas |
675 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
676 |
Restrictions.nullSafeOr( |
3059 |
19 Dec 14 |
nicklas |
677 |
Restrictions.eq(autoProcessing, Expressions.string("ReProcess")), |
3059 |
19 Dec 14 |
nicklas |
678 |
Restrictions.and( |
3059 |
19 Dec 14 |
nicklas |
679 |
Restrictions.eq(autoProcessing, null), |
3059 |
19 Dec 14 |
nicklas |
680 |
Restrictions.neq(Hql.property("id"), Expressions.all(mrnaQuery)) |
3059 |
19 Dec 14 |
nicklas |
681 |
) |
3059 |
19 Dec 14 |
nicklas |
682 |
) |
3059 |
19 Dec 14 |
nicklas |
683 |
); |
3059 |
19 Dec 14 |
nicklas |
684 |
query.setCacheResult(true); |
3317 |
08 May 15 |
nicklas |
685 |
json.put("rna-without-mrna-or-lib", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
686 |
// --- |
3059 |
19 Dec 14 |
nicklas |
687 |
|
3059 |
19 Dec 14 |
nicklas |
// Pre-normalized RNA that has no mRNA child item (and has not been disabled for auto-processing) |
3059 |
19 Dec 14 |
nicklas |
689 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
690 |
Subtype.RNA_NORMALIZED_ALIQUOT.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
691 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Filter for non-empty creation date |
3059 |
19 Dec 14 |
nicklas |
693 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
694 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Join AUTO_PROCESSING annotation |
3059 |
19 Dec 14 |
nicklas |
696 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
697 |
|
3317 |
08 May 15 |
nicklas |
// Create a subquery that load all RNA extracts that has at least one mRNA or Library child extract |
3059 |
19 Dec 14 |
nicklas |
699 |
mrnaQuery = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
700 |
Subtype.RNA_NORMALIZED_ALIQUOT.addFilter(dc, mrnaQuery); |
3059 |
19 Dec 14 |
nicklas |
701 |
mrnaQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Join child items and filter on mRNA subtype |
3059 |
19 Dec 14 |
nicklas |
703 |
mrnaQuery.join(Hql.innerJoin("childCreationEvents", "cce")); |
3059 |
19 Dec 14 |
nicklas |
704 |
mrnaQuery.join(Hql.innerJoin("cce", "event", "evt", null, false)); |
3059 |
19 Dec 14 |
nicklas |
705 |
mrnaQuery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false)); |
3317 |
08 May 15 |
nicklas |
706 |
mrnaQuery.restrict(Restrictions.or( |
3317 |
08 May 15 |
nicklas |
707 |
Subtype.MRNA.restriction(dc, "bm"), |
3317 |
08 May 15 |
nicklas |
708 |
Subtype.LIBRARY.restriction(dc, "bm") |
3317 |
08 May 15 |
nicklas |
709 |
)); |
3059 |
19 Dec 14 |
nicklas |
710 |
|
3317 |
08 May 15 |
nicklas |
/* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND <no mrna/library children>) */ |
3059 |
19 Dec 14 |
nicklas |
712 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
713 |
Restrictions.nullSafeOr( |
3059 |
19 Dec 14 |
nicklas |
714 |
Restrictions.eq(autoProcessing, Expressions.string("ReProcess")), |
3059 |
19 Dec 14 |
nicklas |
715 |
Restrictions.and( |
3059 |
19 Dec 14 |
nicklas |
716 |
Restrictions.eq(autoProcessing, null), |
3059 |
19 Dec 14 |
nicklas |
717 |
Restrictions.neq(Hql.property("id"), Expressions.all(mrnaQuery)) |
3059 |
19 Dec 14 |
nicklas |
718 |
) |
3059 |
19 Dec 14 |
nicklas |
719 |
) |
3059 |
19 Dec 14 |
nicklas |
720 |
); |
3059 |
19 Dec 14 |
nicklas |
721 |
query.setCacheResult(true); |
3317 |
08 May 15 |
nicklas |
722 |
json.put("normalized-rna-without-mrna-or-lib", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
723 |
// --- |
3059 |
19 Dec 14 |
nicklas |
724 |
|
3158 |
04 Mar 15 |
nicklas |
// RNA in the Flagged RNA list |
3247 |
14 Apr 15 |
nicklas |
726 |
ItemList flaggedRna = BiomaterialList.FLAGGED_RNA.load(dc); |
3158 |
04 Mar 15 |
nicklas |
727 |
json.put("flagged-rna", flaggedRna.getSize()); |
3158 |
04 Mar 15 |
nicklas |
728 |
// --- |
3158 |
04 Mar 15 |
nicklas |
729 |
|
3059 |
19 Dec 14 |
nicklas |
730 |
} |
3059 |
19 Dec 14 |
nicklas |
731 |
|
3059 |
19 Dec 14 |
nicklas |
732 |
|
3059 |
19 Dec 14 |
nicklas |
733 |
private void countBioPlates(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
734 |
{ |
3059 |
19 Dec 14 |
nicklas |
// Caliper RNAQC plates waiting to be processed |
3059 |
19 Dec 14 |
nicklas |
736 |
ItemQuery<BioPlate> query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
737 |
BioplateType.CALIPER_RNAQC.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
738 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must not have QC_RUN_DATE annotation |
3059 |
19 Dec 14 |
nicklas |
740 |
query.join(Annotations.leftJoin(null, Annotationtype.QC_RUN_DATE.load(dc), "rd")); |
3059 |
19 Dec 14 |
nicklas |
741 |
query.restrict(Restrictions.eq(Hql.alias("rd"), null)); |
3059 |
19 Dec 14 |
nicklas |
742 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
743 |
json.put("caliper-rnaqc-waiting", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
744 |
// --- |
3059 |
19 Dec 14 |
nicklas |
745 |
|
3059 |
19 Dec 14 |
nicklas |
// BioaAalyzer RNAQC plates waiting to be processed |
3059 |
19 Dec 14 |
nicklas |
747 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
748 |
BioplateType.BA_RNAQC.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
749 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must not have QC_RUN_DATE annotation |
3059 |
19 Dec 14 |
nicklas |
751 |
query.join(Annotations.leftJoin(null, Annotationtype.QC_RUN_DATE.load(dc), "rd")); |
3059 |
19 Dec 14 |
nicklas |
752 |
query.restrict(Restrictions.eq(Hql.alias("rd"), null)); |
3059 |
19 Dec 14 |
nicklas |
753 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
754 |
json.put("bioanalyzer-rnaqc-waiting", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
755 |
// --- |
3059 |
19 Dec 14 |
nicklas |
756 |
|
5456 |
29 May 19 |
nicklas |
// Pre-normalized DNA plates waiting for MIPs (PlateProcessing=DesignMIPs) |
5408 |
08 May 19 |
nicklas |
758 |
query = BioPlate.getQuery(); |
5408 |
08 May 19 |
nicklas |
759 |
BioplateType.PRE_NORMALIZED_DNA.addFilter(dc, query, true); |
5408 |
08 May 19 |
nicklas |
760 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5408 |
08 May 19 |
nicklas |
// Must have PlateProcess=DesignMIPs |
5408 |
08 May 19 |
nicklas |
762 |
query.join(Annotations.innerJoin(Annotationtype.PLATE_PROCESSING.load(dc), "pp")); |
5408 |
08 May 19 |
nicklas |
763 |
query.restrict(Restrictions.eq(Hql.alias("pp"), Expressions.string("DesignMIPs"))); |
5408 |
08 May 19 |
nicklas |
764 |
query.setCacheResult(true); |
5456 |
29 May 19 |
nicklas |
765 |
json.put("prenormalized-designmips", query.count(dc)); |
5456 |
29 May 19 |
nicklas |
766 |
|
5456 |
29 May 19 |
nicklas |
// Pre-normalized DNA plates waiting for MIPs (PlateProcessing=AddAliquots) |
5456 |
29 May 19 |
nicklas |
768 |
query = BioPlate.getQuery(); |
5456 |
29 May 19 |
nicklas |
769 |
BioplateType.PRE_NORMALIZED_DNA.addFilter(dc, query, true); |
5456 |
29 May 19 |
nicklas |
770 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5456 |
29 May 19 |
nicklas |
// Must have PlateProcess=DesignMIPs |
5456 |
29 May 19 |
nicklas |
772 |
query.join(Annotations.innerJoin(Annotationtype.PLATE_PROCESSING.load(dc), "pp")); |
5456 |
29 May 19 |
nicklas |
773 |
query.restrict(Restrictions.eq(Hql.alias("pp"), Expressions.string("AddAliquots"))); |
5456 |
29 May 19 |
nicklas |
774 |
query.setCacheResult(true); |
5456 |
29 May 19 |
nicklas |
775 |
json.put("prenormalized-addaliquots", query.count(dc)); |
5408 |
08 May 19 |
nicklas |
776 |
|
3059 |
19 Dec 14 |
nicklas |
// mRNA plates waiting for registration |
3059 |
19 Dec 14 |
nicklas |
778 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
779 |
BioplateType.MRNA.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
780 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
781 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
782 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
783 |
json.put("mrna-plates-not-registered", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
784 |
// --- |
3059 |
19 Dec 14 |
nicklas |
785 |
|
3059 |
19 Dec 14 |
nicklas |
// mRNA plates waiting for dilution |
3059 |
19 Dec 14 |
nicklas |
787 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
788 |
BioplateType.MRNA.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
789 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must not have a DILUTION_DATE annotation AND no AUTO_PROCESSING annotation |
3059 |
19 Dec 14 |
nicklas |
791 |
query.join(Annotations.leftJoin(null, Annotationtype.DILUTION_DATE.load(dc), "dd")); |
3059 |
19 Dec 14 |
nicklas |
792 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
793 |
query.restrict(Restrictions.eq(Hql.alias("dd"), null)); |
3059 |
19 Dec 14 |
nicklas |
794 |
query.restrict(Restrictions.eq(Hql.alias("ap"), null)); |
3059 |
19 Dec 14 |
nicklas |
795 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
796 |
json.put("mrna-plates-not-diluted", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
797 |
// --- |
3059 |
19 Dec 14 |
nicklas |
798 |
|
3059 |
19 Dec 14 |
nicklas |
// mRNA plates diluted but not registered |
3059 |
19 Dec 14 |
nicklas |
800 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
801 |
BioplateType.MRNA.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
802 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a DILUTION_DATE annotation OR AUTO_PROCESSING = PreNormalizeRNA |
3059 |
19 Dec 14 |
nicklas |
804 |
query.join(Annotations.leftJoin(null, Annotationtype.DILUTION_DATE.load(dc), "dd")); |
3059 |
19 Dec 14 |
nicklas |
805 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
806 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
807 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
808 |
Restrictions.neq(Hql.alias("dd"), null), |
3059 |
19 Dec 14 |
nicklas |
809 |
Restrictions.eq(Hql.alias("ap"), Expressions.string(Rna.AUTO_PROCESSING_PRE_NORMALIZE)) |
3059 |
19 Dec 14 |
nicklas |
810 |
)); |
3059 |
19 Dec 14 |
nicklas |
811 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
812 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
813 |
json.put("mrna-plates-diluted-not-registered", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
814 |
// --- |
3059 |
19 Dec 14 |
nicklas |
815 |
|
3059 |
19 Dec 14 |
nicklas |
// cDNA plates waiting for registration |
3059 |
19 Dec 14 |
nicklas |
817 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
818 |
BioplateType.CDNA.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
819 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
820 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
821 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
822 |
json.put("cdna-plates-not-registered", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
823 |
// --- |
3059 |
19 Dec 14 |
nicklas |
824 |
|
3059 |
19 Dec 14 |
nicklas |
// cDNA plates for barcoding |
3059 |
19 Dec 14 |
nicklas |
826 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
827 |
BioplateType.CDNA.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
828 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a creation date |
3059 |
19 Dec 14 |
nicklas |
830 |
query.restrict(Restrictions.neq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must not have a BARCODE_VARIANT annotation |
3059 |
19 Dec 14 |
nicklas |
832 |
query.join(Annotations.leftJoin(null, Annotationtype.BARCODE_VARIANT.load(dc), "bv")); |
3059 |
19 Dec 14 |
nicklas |
833 |
query.restrict(Restrictions.eq(Hql.alias("bv"), null)); |
3059 |
19 Dec 14 |
nicklas |
834 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
835 |
json.put("cdna-plates-for-barcoding", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
836 |
// --- |
3059 |
19 Dec 14 |
nicklas |
837 |
|
3059 |
19 Dec 14 |
nicklas |
// Library plates for lib-prep |
3059 |
19 Dec 14 |
nicklas |
839 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
840 |
BioplateType.LIBRARY.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
841 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Only Library bioplates that are not destroyed |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a creation date |
3059 |
19 Dec 14 |
nicklas |
844 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must have a BARCODE_VARIANT annotation |
3059 |
19 Dec 14 |
nicklas |
846 |
query.join(Annotations.leftJoin(null, Annotationtype.BARCODE_VARIANT.load(dc), "bv")); |
3059 |
19 Dec 14 |
nicklas |
847 |
query.restrict(Restrictions.neq(Hql.alias("bv"), null)); |
3059 |
19 Dec 14 |
nicklas |
848 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
849 |
json.put("lib-plates-for-libprep", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
850 |
// --- |
5887 |
02 Apr 20 |
nicklas |
851 |
|
5887 |
02 Apr 20 |
nicklas |
// External plates for lib-prep/sequencing |
5887 |
02 Apr 20 |
nicklas |
853 |
query = BioPlate.getQuery(); |
5887 |
02 Apr 20 |
nicklas |
854 |
BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, true); |
5887 |
02 Apr 20 |
nicklas |
855 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5887 |
02 Apr 20 |
nicklas |
// Only Library bioplates that are not destroyed |
5887 |
02 Apr 20 |
nicklas |
// Must NOT have a creation date |
5887 |
02 Apr 20 |
nicklas |
858 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
5887 |
02 Apr 20 |
nicklas |
859 |
query.setCacheResult(true); |
5887 |
02 Apr 20 |
nicklas |
860 |
json.put("external-plates-not-registered", query.count(dc)); |
5887 |
02 Apr 20 |
nicklas |
861 |
// --- |
3059 |
19 Dec 14 |
nicklas |
862 |
|
3059 |
19 Dec 14 |
nicklas |
// Library plates for pooling |
3059 |
19 Dec 14 |
nicklas |
864 |
ItemQuery<Extract> libQuery = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
865 |
Subtype.LIBRARY.addFilter(dc, libQuery); |
3059 |
19 Dec 14 |
nicklas |
866 |
libQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
867 |
libQuery.restrict(Restrictions.neq(Hql.property("originalQuantity"), null)); |
3059 |
19 Dec 14 |
nicklas |
868 |
libQuery.restrict(Restrictions.eq(Hql.property("originalQuantity"), Hql.property("remainingQuantity"))); |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a Flag annotation |
3059 |
19 Dec 14 |
nicklas |
870 |
libQuery.join(Annotations.leftJoin(null, Annotationtype.FLAG.load(dc), "flg")); |
3059 |
19 Dec 14 |
nicklas |
871 |
libQuery.restrict(Restrictions.eq(Hql.alias("flg"), null)); |
3059 |
19 Dec 14 |
nicklas |
872 |
|
3059 |
19 Dec 14 |
nicklas |
873 |
query = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
874 |
BioplateType.LIBRARY.addFilter(dc, query, true); |
3059 |
19 Dec 14 |
nicklas |
875 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a PLATE_PROCESS_RESULT=Success annotation |
3059 |
19 Dec 14 |
nicklas |
877 |
query.join(Annotations.leftJoin(null, Annotationtype.PLATE_PROCESS_RESULT.load(dc), "ppr")); |
3059 |
19 Dec 14 |
nicklas |
878 |
query.restrict(Restrictions.eq(Hql.alias("ppr"), Expressions.string(ReactionPlate.PROCESS_SUCCESSFUL))); |
3059 |
19 Dec 14 |
nicklas |
879 |
query.join(Hql.innerJoin("bioWells", "bw")); |
3059 |
19 Dec 14 |
nicklas |
880 |
query.join(Hql.innerJoin("bw", "bioMaterial", "bm")); |
3059 |
19 Dec 14 |
nicklas |
881 |
query.restrict(Restrictions.eq(Hql.alias("bm"), Expressions.any(libQuery))); |
3059 |
19 Dec 14 |
nicklas |
882 |
query.setDistinct(true); |
3059 |
19 Dec 14 |
nicklas |
883 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
884 |
json.put("lib-plates-for-pooling", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
885 |
// --- |
3059 |
19 Dec 14 |
nicklas |
886 |
|
5419 |
10 May 19 |
nicklas |
// MIPs plates waiting for registration |
5419 |
10 May 19 |
nicklas |
888 |
query = BioPlate.getQuery(); |
5419 |
10 May 19 |
nicklas |
889 |
BioplateType.MIPS.addFilter(dc, query, true); |
5419 |
10 May 19 |
nicklas |
890 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5419 |
10 May 19 |
nicklas |
891 |
query.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
5419 |
10 May 19 |
nicklas |
892 |
query.setCacheResult(true); |
5419 |
10 May 19 |
nicklas |
893 |
json.put("mips-plates-for-libprep", query.count(dc)); |
5419 |
10 May 19 |
nicklas |
894 |
// --- |
5419 |
10 May 19 |
nicklas |
895 |
|
5426 |
14 May 19 |
nicklas |
// MIPs plates for pooling |
5426 |
14 May 19 |
nicklas |
897 |
query = BioPlate.getQuery(); |
5426 |
14 May 19 |
nicklas |
898 |
BioplateType.MIPS.addFilter(dc, query, true); |
5426 |
14 May 19 |
nicklas |
899 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5426 |
14 May 19 |
nicklas |
// Must have a PLATE_PROCESS_RESULT=Success annotation |
5427 |
14 May 19 |
nicklas |
901 |
query.join(Annotations.innerJoin(null, Annotationtype.PLATE_PROCESS_RESULT.load(dc), "ppr")); |
5426 |
14 May 19 |
nicklas |
902 |
query.restrict(Restrictions.eq(Hql.alias("ppr"), Expressions.string(ReactionPlate.PROCESS_SUCCESSFUL))); |
5427 |
14 May 19 |
nicklas |
// Must NOT have a PoolDate annotation |
5427 |
14 May 19 |
nicklas |
904 |
query.join(Annotations.leftJoin(null, Annotationtype.POOL_DATE.load(dc), "pd")); |
5427 |
14 May 19 |
nicklas |
905 |
query.restrict(Restrictions.eq(Hql.alias("pd"), null)); |
5426 |
14 May 19 |
nicklas |
906 |
query.setCacheResult(true); |
5426 |
14 May 19 |
nicklas |
907 |
json.put("mips-plates-for-pooling", query.count(dc)); |
5426 |
14 May 19 |
nicklas |
908 |
// --- |
5426 |
14 May 19 |
nicklas |
909 |
|
4544 |
28 Jun 17 |
nicklas |
// Number of empty specimen storage boxes |
4544 |
28 Jun 17 |
nicklas |
911 |
query = BioPlate.getQuery(); |
4544 |
28 Jun 17 |
nicklas |
912 |
BioplateType.STORAGE_BOX.addFilter(dc, query, true); |
4544 |
28 Jun 17 |
nicklas |
913 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4544 |
28 Jun 17 |
nicklas |
// Must have freeWells equal to geometry.rows x geometry.columns |
4544 |
28 Jun 17 |
nicklas |
915 |
query.join(Hql.innerJoin("plateGeometry", "g")); |
4544 |
28 Jun 17 |
nicklas |
916 |
query.restrict(Restrictions.eq(Hql.property("freeWells"), |
4544 |
28 Jun 17 |
nicklas |
917 |
Expressions.multiply(Hql.property("g", "rows"), Hql.property("g", "columns")) |
4544 |
28 Jun 17 |
nicklas |
918 |
)); |
5340 |
29 Mar 19 |
nicklas |
// Name must start with Sp% or PSp% |
4544 |
28 Jun 17 |
nicklas |
920 |
query.restrict(Restrictions.like( |
5340 |
29 Mar 19 |
nicklas |
921 |
Hql.property("name"), Expressions.parameter("name")) |
5340 |
29 Mar 19 |
nicklas |
922 |
); |
4544 |
28 Jun 17 |
nicklas |
923 |
query.setCacheResult(true); |
5340 |
29 Mar 19 |
nicklas |
924 |
|
5340 |
29 Mar 19 |
nicklas |
925 |
query.setParameter("name", "Sp%", Type.STRING); |
4544 |
28 Jun 17 |
nicklas |
926 |
json.put("empty-storage-boxes", query.count(dc)); |
5340 |
29 Mar 19 |
nicklas |
927 |
|
5340 |
29 Mar 19 |
nicklas |
928 |
query.setParameter("name", "PSp%", Type.STRING); |
5340 |
29 Mar 19 |
nicklas |
929 |
json.put("empty-paused-storage-boxes", query.count(dc)); |
7138 |
26 Apr 23 |
nicklas |
930 |
|
7138 |
26 Apr 23 |
nicklas |
931 |
query.setParameter("name", "E-Sp%", Type.STRING); |
7138 |
26 Apr 23 |
nicklas |
932 |
json.put("empty-external-storage-boxes", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
933 |
} |
3059 |
19 Dec 14 |
nicklas |
934 |
|
4138 |
29 Sep 16 |
nicklas |
935 |
private void countItemLists(DbControl dc, JSONObject json) |
4138 |
29 Sep 16 |
nicklas |
936 |
{ |
4138 |
29 Sep 16 |
nicklas |
// Number of active outtake lists |
4138 |
29 Sep 16 |
nicklas |
938 |
ItemQuery<ItemList> query = ItemList.getQuery(); |
4138 |
29 Sep 16 |
nicklas |
939 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4138 |
29 Sep 16 |
nicklas |
940 |
query.restrict(Restrictions.eq(Hql.property("externalId"), Expressions.string(Reggie.OUTTAKE_ALIQUOTS_LIST_ID))); |
4138 |
29 Sep 16 |
nicklas |
941 |
query.join(Annotations.leftJoin(null, Annotationtype.OUTTAKE_COMPLETED_DATE.load(dc), "ocd")); |
4138 |
29 Sep 16 |
nicklas |
942 |
query.restrict(Restrictions.eq(Hql.alias("ocd"), null)); |
4138 |
29 Sep 16 |
nicklas |
943 |
query.setCacheResult(true); |
4138 |
29 Sep 16 |
nicklas |
944 |
json.put("active-outtake-lists", query.count(dc)); |
4138 |
29 Sep 16 |
nicklas |
945 |
// --- |
4138 |
29 Sep 16 |
nicklas |
946 |
|
4138 |
29 Sep 16 |
nicklas |
// Number of completed outtakes lists not yet delivered |
4138 |
29 Sep 16 |
nicklas |
948 |
query = ItemList.getQuery(); |
4138 |
29 Sep 16 |
nicklas |
949 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4138 |
29 Sep 16 |
nicklas |
950 |
query.restrict(Restrictions.eq(Hql.property("externalId"), Expressions.string(Reggie.OUTTAKE_ALIQUOTS_LIST_ID))); |
4179 |
27 Oct 16 |
nicklas |
951 |
query.join(Annotations.innerJoin(null, Annotationtype.OUTTAKE_RESULT.load(dc), "ors")); |
4179 |
27 Oct 16 |
nicklas |
952 |
query.restrict(Restrictions.eq(Hql.alias("ors"), Expressions.string("Successful"))); |
4138 |
29 Sep 16 |
nicklas |
953 |
query.join(Annotations.innerJoin(null, Annotationtype.OUTTAKE_COMPLETED_DATE.load(dc), "ocd")); |
4138 |
29 Sep 16 |
nicklas |
954 |
query.join(Annotations.leftJoin(null, Annotationtype.OUTTAKE_DELIVERED_DATE.load(dc), "odd")); |
4138 |
29 Sep 16 |
nicklas |
955 |
query.restrict(Restrictions.eq(Hql.alias("odd"), null)); |
4138 |
29 Sep 16 |
nicklas |
956 |
query.setCacheResult(true); |
4138 |
29 Sep 16 |
nicklas |
957 |
json.put("undelivered-outtake-lists", query.count(dc)); |
4138 |
29 Sep 16 |
nicklas |
958 |
|
7171 |
15 May 23 |
nicklas |
// Number of transport boxes to move |
7171 |
15 May 23 |
nicklas |
960 |
query = ItemList.getQuery(); |
7171 |
15 May 23 |
nicklas |
961 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
7171 |
15 May 23 |
nicklas |
962 |
query.restrict(Restrictions.eq(Hql.property("externalId"), Expressions.string(TransportBoxImporter.WORK_LIST_ID))); |
7187 |
22 May 23 |
nicklas |
963 |
query.join(Annotations.leftJoin(null, Annotationtype.MOVE_DATE.load(dc), "md")); |
7187 |
22 May 23 |
nicklas |
964 |
query.restrict(Restrictions.eq(Hql.alias("md"), null)); |
7171 |
15 May 23 |
nicklas |
965 |
query.setCacheResult(true); |
7171 |
15 May 23 |
nicklas |
966 |
json.put("transport-boxes-to-move", query.count(dc)); |
4138 |
29 Sep 16 |
nicklas |
967 |
} |
4138 |
29 Sep 16 |
nicklas |
968 |
|
3059 |
19 Dec 14 |
nicklas |
969 |
private void countHistology(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
970 |
{ |
3059 |
19 Dec 14 |
nicklas |
// Number of active histology work lists |
3247 |
14 Apr 15 |
nicklas |
972 |
ItemQuery<ItemList> query = ItemList.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
973 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
974 |
query.restrict(Restrictions.eq(Hql.property("externalId"), Expressions.string(Histology.WORK_LIST_ID))); |
3059 |
19 Dec 14 |
nicklas |
975 |
query.join(Annotations.leftJoin(null, Annotationtype.EMBED_DATE.load(dc), "em")); |
3059 |
19 Dec 14 |
nicklas |
976 |
query.restrict(Restrictions.eq(Hql.alias("em"), null)); |
3059 |
19 Dec 14 |
nicklas |
977 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
978 |
json.put("histology-active-lists", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
979 |
// --- |
3059 |
19 Dec 14 |
nicklas |
980 |
|
3059 |
19 Dec 14 |
nicklas |
// Paraffin blocks not yet embedded |
3059 |
19 Dec 14 |
nicklas |
982 |
ItemQuery<BioPlate> pbQuery = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
983 |
BioplateType.PARAFFIN_BLOCK.addFilter(dc, pbQuery, true); |
3059 |
19 Dec 14 |
nicklas |
984 |
pbQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a creation date |
3059 |
19 Dec 14 |
nicklas |
986 |
pbQuery.restrict(Restrictions.eq(Hql.property("eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
987 |
pbQuery.setCacheResult(true); |
3094 |
19 Jan 15 |
nicklas |
988 |
json.put("paraffin-blocks-not-embedded", pbQuery.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
989 |
// --- |
3059 |
19 Dec 14 |
nicklas |
990 |
|
3059 |
19 Dec 14 |
nicklas |
// Paraffin blocks without HE glass |
3059 |
19 Dec 14 |
nicklas |
// Create a query that load all Histology samples that has at least one Stained child sample |
3059 |
19 Dec 14 |
nicklas |
993 |
ItemQuery<Sample> subquery = Sample.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
994 |
Subtype.HISTOLOGY.addFilter(dc, subquery); |
3059 |
19 Dec 14 |
nicklas |
995 |
subquery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Join child items and filter on STAINED subtype |
3059 |
19 Dec 14 |
nicklas |
997 |
subquery.join(Hql.innerJoin("childCreationEvents", "cce")); |
3059 |
19 Dec 14 |
nicklas |
998 |
subquery.join(Hql.innerJoin("cce", "event", "evt", null, false)); |
3059 |
19 Dec 14 |
nicklas |
999 |
subquery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false)); |
3059 |
19 Dec 14 |
nicklas |
1000 |
Subtype.STAINED.addFilter(dc, subquery, "bm"); |
3059 |
19 Dec 14 |
nicklas |
1001 |
|
3059 |
19 Dec 14 |
nicklas |
1002 |
pbQuery = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1003 |
BioplateType.PARAFFIN_BLOCK.addFilter(dc, pbQuery, true); |
3059 |
19 Dec 14 |
nicklas |
1004 |
pbQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
1005 |
pbQuery.join(Hql.innerJoin("bioWells", "bw")); |
3059 |
19 Dec 14 |
nicklas |
1006 |
pbQuery.join(Hql.innerJoin("bw", "bioMaterial", "bm")); |
3059 |
19 Dec 14 |
nicklas |
// Filter on id not equal to any that has a STAINED child |
3059 |
19 Dec 14 |
nicklas |
1008 |
pbQuery.restrict(Restrictions.neq(Hql.alias("bm"), Expressions.all(subquery))); |
3059 |
19 Dec 14 |
nicklas |
1009 |
pbQuery.setDistinct(true); |
3059 |
19 Dec 14 |
nicklas |
1010 |
pbQuery.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
1011 |
json.put("paraffin-blocks-without-heglass", pbQuery.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1012 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1013 |
|
3059 |
19 Dec 14 |
nicklas |
// Unscored HE glass |
3059 |
19 Dec 14 |
nicklas |
1015 |
pbQuery = BioPlate.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1016 |
BioplateType.HE_GLASS.addFilter(dc, pbQuery, true); |
3059 |
19 Dec 14 |
nicklas |
1017 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Missing of 'false' for SCORE_COMPLETE annotation |
3059 |
19 Dec 14 |
nicklas |
1019 |
pbQuery.join(Annotations.leftJoin(null, Annotationtype.SCORE_COMPLETE.load(dc), "sc")); |
3059 |
19 Dec 14 |
nicklas |
1020 |
pbQuery.restrict( |
3059 |
19 Dec 14 |
nicklas |
1021 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
1022 |
Restrictions.eq(Hql.alias("sc"), null), |
3059 |
19 Dec 14 |
nicklas |
1023 |
Restrictions.eq(Hql.alias("sc"), Expressions.bool(false)) |
3059 |
19 Dec 14 |
nicklas |
1024 |
)); |
3059 |
19 Dec 14 |
nicklas |
1025 |
pbQuery.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
1026 |
json.put("heglass-not-scored", pbQuery.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1027 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1028 |
|
3424 |
25 Jun 15 |
nicklas |
1029 |
ItemQuery<Sample> scoredQuery = Sample.getQuery(); |
3424 |
25 Jun 15 |
nicklas |
1030 |
Subtype.STAINED.addFilter(dc, scoredQuery); |
3424 |
25 Jun 15 |
nicklas |
1031 |
scoredQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3424 |
25 Jun 15 |
nicklas |
// 'true' for SCORE_COMPLETE annotation |
3424 |
25 Jun 15 |
nicklas |
1033 |
scoredQuery.join(Annotations.leftJoin(null, Annotationtype.SCORE_COMPLETE.load(dc), "sc")); |
3424 |
25 Jun 15 |
nicklas |
1034 |
scoredQuery.restrict(Restrictions.eq(Hql.alias("sc"), Expressions.bool(true))); |
3424 |
25 Jun 15 |
nicklas |
1035 |
scoredQuery.setCacheResult(true); |
3424 |
25 Jun 15 |
nicklas |
1036 |
json.put("stained-score-complete", scoredQuery.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1037 |
} |
3059 |
19 Dec 14 |
nicklas |
1038 |
|
3059 |
19 Dec 14 |
nicklas |
1039 |
|
3059 |
19 Dec 14 |
nicklas |
1040 |
private void countLibraries(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
1041 |
{ |
5434 |
17 May 19 |
nicklas |
// Pools (RNAseq) not yet registered |
3059 |
19 Dec 14 |
nicklas |
1043 |
ItemQuery<Extract> query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1044 |
Subtype.POOLED_LIBRARY.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1045 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5434 |
17 May 19 |
nicklas |
1046 |
Pipeline.RNA_SEQ.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1047 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
1048 |
query.restrict(Restrictions.eq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
1049 |
query.setCacheResult(true); |
5434 |
17 May 19 |
nicklas |
1050 |
json.put("pools-not-registered-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1051 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1052 |
|
5434 |
17 May 19 |
nicklas |
// Pools (RNAseq) not used on any flow cell |
3059 |
19 Dec 14 |
nicklas |
1054 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1055 |
Subtype.POOLED_LIBRARY.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1056 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5434 |
17 May 19 |
nicklas |
1057 |
Pipeline.RNA_SEQ.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
// Filter on created date != null |
3059 |
19 Dec 14 |
nicklas |
1059 |
query.join(Hql.innerJoin(null, "creationEvent", "ce", true)); |
3059 |
19 Dec 14 |
nicklas |
1060 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
5452 |
28 May 19 |
nicklas |
/* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND size(childCreationEvents)==0) */ |
3059 |
19 Dec 14 |
nicklas |
1062 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
1063 |
Expression autoProcessing = Hql.alias("ap"); |
3059 |
19 Dec 14 |
nicklas |
1064 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
1065 |
Restrictions.nullSafeOr( |
3059 |
19 Dec 14 |
nicklas |
1066 |
Restrictions.eq(autoProcessing, Expressions.string("ReProcess")), |
3059 |
19 Dec 14 |
nicklas |
1067 |
Restrictions.and( |
3059 |
19 Dec 14 |
nicklas |
1068 |
Restrictions.eq(autoProcessing, null), |
5452 |
28 May 19 |
nicklas |
1069 |
Restrictions.eq(Hql.size(null, "childCreationEvents"), Expressions.integer(0)) |
5452 |
28 May 19 |
nicklas |
// Restrictions.eq(Hql.property("originalQuantity"), Hql.property("remainingQuantity")) |
3059 |
19 Dec 14 |
nicklas |
1071 |
) |
3059 |
19 Dec 14 |
nicklas |
1072 |
) |
3059 |
19 Dec 14 |
nicklas |
1073 |
); |
3059 |
19 Dec 14 |
nicklas |
1074 |
query.setCacheResult(true); |
5434 |
17 May 19 |
nicklas |
1075 |
json.put("pools-not-used-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1076 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1077 |
|
5435 |
17 May 19 |
nicklas |
// Pools (MIPs) not used on any flow cell |
5435 |
17 May 19 |
nicklas |
1079 |
query = Extract.getQuery(); |
5435 |
17 May 19 |
nicklas |
1080 |
Subtype.POOLED_LIBRARY.addFilter(dc, query); |
5435 |
17 May 19 |
nicklas |
1081 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5435 |
17 May 19 |
nicklas |
1082 |
Pipeline.MIPS.addFilter(dc, query); |
5435 |
17 May 19 |
nicklas |
// Filter on created date != null |
5435 |
17 May 19 |
nicklas |
1084 |
query.join(Hql.innerJoin(null, "creationEvent", "ce", true)); |
5435 |
17 May 19 |
nicklas |
1085 |
query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null)); |
5452 |
28 May 19 |
nicklas |
// Join AUTO_PROCESSING annotation |
5435 |
17 May 19 |
nicklas |
1087 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
5452 |
28 May 19 |
nicklas |
/* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND size(childCreationEvents)==0) */ |
5435 |
17 May 19 |
nicklas |
1089 |
query.restrict( |
5435 |
17 May 19 |
nicklas |
1090 |
Restrictions.nullSafeOr( |
5435 |
17 May 19 |
nicklas |
1091 |
Restrictions.eq(autoProcessing, Expressions.string("ReProcess")), |
5435 |
17 May 19 |
nicklas |
1092 |
Restrictions.and( |
5435 |
17 May 19 |
nicklas |
1093 |
Restrictions.eq(autoProcessing, null), |
5452 |
28 May 19 |
nicklas |
1094 |
Restrictions.eq(Hql.size(null, "childCreationEvents"), Expressions.integer(0)) |
5435 |
17 May 19 |
nicklas |
1095 |
) |
5435 |
17 May 19 |
nicklas |
1096 |
) |
5435 |
17 May 19 |
nicklas |
1097 |
); |
5452 |
28 May 19 |
nicklas |
1098 |
|
5435 |
17 May 19 |
nicklas |
1099 |
query.setCacheResult(true); |
5435 |
17 May 19 |
nicklas |
1100 |
json.put("pools-not-used-mips", query.count(dc)); |
5435 |
17 May 19 |
nicklas |
1101 |
// --- |
5435 |
17 May 19 |
nicklas |
1102 |
|
3059 |
19 Dec 14 |
nicklas |
// All successfully aligned and confirmed sequences (libs) |
3059 |
19 Dec 14 |
nicklas |
1104 |
query = Extract.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1105 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
1106 |
Subtype.LIBRARY.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1107 |
query.join(Hql.innerJoin("derivedBioAssays", "aligned")); |
3059 |
19 Dec 14 |
nicklas |
1108 |
Subtype.ALIGNED_SEQUENCES.addFilter(dc, query, "aligned"); |
3059 |
19 Dec 14 |
nicklas |
// Must have a ANALYSIS_RESULT=Successful annotation |
3059 |
19 Dec 14 |
nicklas |
1110 |
query.join(Annotations.leftJoin("aligned", Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
3059 |
19 Dec 14 |
nicklas |
1111 |
query.restrict(Restrictions.eq(Hql.alias("ar"), Expressions.string(DemuxedSequences.DEMUX_SUCCESSFUL))); |
3059 |
19 Dec 14 |
nicklas |
1112 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
1113 |
query.setDistinct(true); |
3059 |
19 Dec 14 |
nicklas |
1114 |
json.put("libraries-all-aligned", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1115 |
// --- |
5868 |
18 Mar 20 |
nicklas |
1116 |
|
5868 |
18 Mar 20 |
nicklas |
// Libraries (RNAseq) waiting for external sequencing |
5868 |
18 Mar 20 |
nicklas |
1118 |
query = Extract.getQuery(); |
5868 |
18 Mar 20 |
nicklas |
1119 |
Subtype.LIBRARY.addFilter(dc, query); |
5868 |
18 Mar 20 |
nicklas |
1120 |
Pipeline.RNA_SEQ.addFilter(dc, query); |
5868 |
18 Mar 20 |
nicklas |
1121 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5868 |
18 Mar 20 |
nicklas |
// Filter for empty creation date |
5868 |
18 Mar 20 |
nicklas |
1123 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
5868 |
18 Mar 20 |
nicklas |
1124 |
query.restrict(Restrictions.eq(Hql.property("ce", "eventDate"), null)); |
5868 |
18 Mar 20 |
nicklas |
// Must be on "External library plate" |
5868 |
18 Mar 20 |
nicklas |
1126 |
query.join(Hql.innerJoin("bioWell", "bw")); |
5868 |
18 Mar 20 |
nicklas |
1127 |
query.join(Hql.innerJoin("bw", "bioPlate", "bp")); |
5868 |
18 Mar 20 |
nicklas |
1128 |
BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, "bp", true); |
5868 |
18 Mar 20 |
nicklas |
1129 |
json.put("external-libs-not-sequenced", query.count(dc)); |
5868 |
18 Mar 20 |
nicklas |
1130 |
|
3059 |
19 Dec 14 |
nicklas |
1131 |
} |
3059 |
19 Dec 14 |
nicklas |
1132 |
|
3059 |
19 Dec 14 |
nicklas |
1133 |
private void countPhysicalBioAssays(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
1134 |
{ |
5441 |
21 May 19 |
nicklas |
// Flow cells not sequenced (RNAseq) |
3059 |
19 Dec 14 |
nicklas |
1136 |
ItemQuery<PhysicalBioAssay> query = PhysicalBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1137 |
Subtype.FLOW_CELL.addFilter(dc, query); |
5472 |
05 Jun 19 |
nicklas |
1138 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1139 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
1140 |
query.join(Hql.innerJoin("creationEvent", "ce")); |
3059 |
19 Dec 14 |
nicklas |
1141 |
query.restrict(Restrictions.eq(Hql.property("ce", "eventDate"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a PLATE_PROCESS_RESULT annotation |
3059 |
19 Dec 14 |
nicklas |
1143 |
query.join(Annotations.leftJoin(null, Annotationtype.PLATE_PROCESS_RESULT.load(dc), "ppr")); |
3059 |
19 Dec 14 |
nicklas |
1144 |
query.restrict(Restrictions.eq(Hql.alias("ppr"), null)); |
3059 |
19 Dec 14 |
nicklas |
1145 |
query.setCacheResult(true); |
5472 |
05 Jun 19 |
nicklas |
1146 |
query.setParameter("pipeline", Pipeline.RNA_SEQ.getName(), Type.STRING); |
5441 |
21 May 19 |
nicklas |
1147 |
json.put("flow-cells-not-sequenced-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1148 |
// --- |
5441 |
21 May 19 |
nicklas |
1149 |
|
5441 |
21 May 19 |
nicklas |
// Flow cells not sequenced (MIPs) |
5472 |
05 Jun 19 |
nicklas |
1151 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5441 |
21 May 19 |
nicklas |
1152 |
json.put("flow-cells-not-sequenced-mips", query.count(dc)); |
5441 |
21 May 19 |
nicklas |
1153 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1154 |
} |
3059 |
19 Dec 14 |
nicklas |
1155 |
|
3059 |
19 Dec 14 |
nicklas |
1156 |
private void countDerivedBioAssays(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
1157 |
{ |
5472 |
05 Jun 19 |
nicklas |
// Sequencing runs that are running (RNAseq) |
3059 |
19 Dec 14 |
nicklas |
1159 |
ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1160 |
Subtype.SEQUENCING_RUN.addFilter(dc, query); |
5472 |
05 Jun 19 |
nicklas |
1161 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1162 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a SEQUENCING_START annotation |
3059 |
19 Dec 14 |
nicklas |
1164 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_START.load(dc), "sst")); |
3059 |
19 Dec 14 |
nicklas |
1165 |
query.restrict(Restrictions.neq(Hql.alias("sst"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a SEQUENCING_END annotation |
3059 |
19 Dec 14 |
nicklas |
1167 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_END.load(dc), "sse")); |
3059 |
19 Dec 14 |
nicklas |
1168 |
query.restrict(Restrictions.eq(Hql.alias("sse"), null)); |
3059 |
19 Dec 14 |
nicklas |
1169 |
query.setCacheResult(true); |
5472 |
05 Jun 19 |
nicklas |
1170 |
query.setParameter("pipeline", Pipeline.RNA_SEQ.getName(), Type.STRING); |
5472 |
05 Jun 19 |
nicklas |
1171 |
json.put("sequencing-runs-active-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1172 |
// --- |
5472 |
05 Jun 19 |
nicklas |
1173 |
|
5472 |
05 Jun 19 |
nicklas |
// Sequencing runs that are running (MIPs) |
5472 |
05 Jun 19 |
nicklas |
1175 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5472 |
05 Jun 19 |
nicklas |
1176 |
json.put("sequencing-runs-active-mips", query.count(dc)); |
5472 |
05 Jun 19 |
nicklas |
1177 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1178 |
|
5478 |
10 Jun 19 |
nicklas |
// Ended but not confirmed sequencing runs (RNAseq) |
3059 |
19 Dec 14 |
nicklas |
1180 |
query = DerivedBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1181 |
Subtype.SEQUENCING_RUN.addFilter(dc, query); |
5478 |
10 Jun 19 |
nicklas |
1182 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1183 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// Must have a SEQUENCING_END annotation |
3059 |
19 Dec 14 |
nicklas |
1185 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_END.load(dc), "sse")); |
3059 |
19 Dec 14 |
nicklas |
1186 |
query.restrict(Restrictions.neq(Hql.alias("sse"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must have SEQUENCING_CONFIRMED=FALSE|NULL annotation |
3059 |
19 Dec 14 |
nicklas |
1188 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_CONFIRMED.load(dc), "scf")); |
3059 |
19 Dec 14 |
nicklas |
1189 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
1190 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
1191 |
Restrictions.eq(Hql.alias("scf"), Expressions.bool(false)), |
3059 |
19 Dec 14 |
nicklas |
1192 |
Restrictions.eq(Hql.alias("scf"), null) |
3059 |
19 Dec 14 |
nicklas |
1193 |
)); |
3059 |
19 Dec 14 |
nicklas |
1194 |
query.setCacheResult(true); |
5478 |
10 Jun 19 |
nicklas |
1195 |
query.setParameter("pipeline", Pipeline.RNA_SEQ.getName(), Type.STRING); |
5478 |
10 Jun 19 |
nicklas |
1196 |
json.put("sequencing-runs-unconfirmed-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1197 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1198 |
|
5478 |
10 Jun 19 |
nicklas |
// Ended but not confirmed sequencing runs (MIPs) |
5478 |
10 Jun 19 |
nicklas |
1200 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5478 |
10 Jun 19 |
nicklas |
1201 |
json.put("sequencing-runs-unconfirmed-mips", query.count(dc)); |
5478 |
10 Jun 19 |
nicklas |
1202 |
// --- |
5478 |
10 Jun 19 |
nicklas |
1203 |
|
5479 |
10 Jun 19 |
nicklas |
// Sequencing runs waiting for demux (RNAseq) |
3059 |
19 Dec 14 |
nicklas |
1205 |
query = DerivedBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1206 |
Subtype.SEQUENCING_RUN.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1207 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5479 |
10 Jun 19 |
nicklas |
1208 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
// Must have a SEQUENCING_CONFIRMED=TRUE annotation |
3059 |
19 Dec 14 |
nicklas |
1210 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_CONFIRMED.load(dc), "scf")); |
3059 |
19 Dec 14 |
nicklas |
1211 |
query.restrict(Restrictions.eq(Hql.alias("scf"), Expressions.bool(true))); |
3059 |
19 Dec 14 |
nicklas |
// And SEQUENCING_RESULT=Successful |
3059 |
19 Dec 14 |
nicklas |
1213 |
query.join(Annotations.leftJoin(null, Annotationtype.SEQUENCING_RESULT.load(dc), "ssr")); |
3059 |
19 Dec 14 |
nicklas |
1214 |
query.restrict(Restrictions.eq(Hql.alias("ssr"), Expressions.string(SequencingRun.SEQUENCING_SUCCESSFUL))); |
3059 |
19 Dec 14 |
nicklas |
// And AUTO_PROCESSING==ReProcess OR AUTO_PROCESSING==null && <no child (DemuxedSequences) items> |
3059 |
19 Dec 14 |
nicklas |
1216 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
1217 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
1218 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
1219 |
Restrictions.eq(Hql.alias("ap"), Expressions.string("ReProcess")), |
3059 |
19 Dec 14 |
nicklas |
1220 |
Restrictions.and( |
3059 |
19 Dec 14 |
nicklas |
1221 |
Restrictions.eq(Hql.alias("ap"), null), |
5533 |
27 Jun 19 |
nicklas |
1222 |
Restrictions.eq(Hql.size(null, "children"), Expressions.integer(0)) |
3059 |
19 Dec 14 |
nicklas |
1223 |
) |
3059 |
19 Dec 14 |
nicklas |
1224 |
)); |
3059 |
19 Dec 14 |
nicklas |
1225 |
query.setCacheResult(true); |
5479 |
10 Jun 19 |
nicklas |
1226 |
query.setParameter("pipeline", Pipeline.RNA_SEQ.getName(), Type.STRING); |
5479 |
10 Jun 19 |
nicklas |
1227 |
json.put("sequencing-runs-for-demux-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1228 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1229 |
|
5479 |
10 Jun 19 |
nicklas |
// Sequencing runs waiting for demux (MIPs) |
5479 |
10 Jun 19 |
nicklas |
1231 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5479 |
10 Jun 19 |
nicklas |
1232 |
json.put("sequencing-runs-for-demux-mips", query.count(dc)); |
5479 |
10 Jun 19 |
nicklas |
1233 |
// --- |
6179 |
24 Mar 21 |
nicklas |
1234 |
|
6179 |
24 Mar 21 |
nicklas |
// External merged sequences waiting for FASTQ import |
6179 |
24 Mar 21 |
nicklas |
1236 |
ItemList fastqImportPipeline = BiomaterialList.FASTQ_IMPORT_PIPELINE.load(dc); |
6215 |
16 Apr 21 |
nicklas |
1237 |
json.put("demuxed-sequences-for-fastq-import", fastqImportPipeline.getSize()); |
5479 |
10 Jun 19 |
nicklas |
1238 |
|
6187 |
26 Mar 21 |
nicklas |
// Merged sequences with FASTQ import not confirmed |
6187 |
26 Mar 21 |
nicklas |
1240 |
query = DerivedBioAssay.getQuery(); |
6187 |
26 Mar 21 |
nicklas |
1241 |
Subtype.MERGED_SEQUENCES.addFilter(dc, query); |
6187 |
26 Mar 21 |
nicklas |
1242 |
Pipeline.RNA_SEQ.addFilter(dc, query); |
6187 |
26 Mar 21 |
nicklas |
1243 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6187 |
26 Mar 21 |
nicklas |
// The job must be ended |
6187 |
26 Mar 21 |
nicklas |
1245 |
query.join(Hql.innerJoin("job", "jb")); |
6187 |
26 Mar 21 |
nicklas |
1246 |
Subtype.FASTQ_IMPORT_JOB.addFilter(dc, query, "jb"); |
6187 |
26 Mar 21 |
nicklas |
1247 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
6187 |
26 Mar 21 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
6187 |
26 Mar 21 |
nicklas |
1249 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
6187 |
26 Mar 21 |
nicklas |
1250 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
6187 |
26 Mar 21 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
6187 |
26 Mar 21 |
nicklas |
1252 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
6187 |
26 Mar 21 |
nicklas |
1253 |
query.restrict( |
6187 |
26 Mar 21 |
nicklas |
1254 |
Restrictions.or( |
6187 |
26 Mar 21 |
nicklas |
1255 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
6187 |
26 Mar 21 |
nicklas |
1256 |
Restrictions.eq(Hql.alias("ap"), null) |
6187 |
26 Mar 21 |
nicklas |
1257 |
)); |
6187 |
26 Mar 21 |
nicklas |
1258 |
query.setCacheResult(true); |
6187 |
26 Mar 21 |
nicklas |
1259 |
json.put("merged-sequences-fastq-import-not-confirmed", query.count(dc)); |
6187 |
26 Mar 21 |
nicklas |
1260 |
// --- |
6187 |
26 Mar 21 |
nicklas |
1261 |
|
4596 |
27 Sep 17 |
nicklas |
// Items in the Legacy pipeline waiting to be aligned |
4596 |
27 Sep 17 |
nicklas |
1263 |
ItemList legacyPipeline = BiomaterialList.LEGACY_PIPELINE.load(dc); |
4596 |
27 Sep 17 |
nicklas |
1264 |
json.put("merged-sequences-for-legacy-alignment", legacyPipeline.getSize()); |
4596 |
27 Sep 17 |
nicklas |
1265 |
|
4596 |
27 Sep 17 |
nicklas |
// Items in the Hisat pipeline waiting to be aligned |
4596 |
27 Sep 17 |
nicklas |
1267 |
ItemList hisatPipeline = BiomaterialList.HISAT_PIPELINE.load(dc); |
4596 |
27 Sep 17 |
nicklas |
1268 |
json.put("merged-sequences-for-hisat-alignment", hisatPipeline.getSize()); |
4596 |
27 Sep 17 |
nicklas |
1269 |
|
6807 |
24 Aug 22 |
nicklas |
// Items in the Hisat pipeline waiting to be aligned |
6811 |
25 Aug 22 |
nicklas |
1271 |
ItemList hisat2023Pipeline = BiomaterialList.HISAT_2023_PIPELINE.load(dc); |
6807 |
24 Aug 22 |
nicklas |
1272 |
json.put("merged-sequences-for-hisat2023-alignment", hisat2023Pipeline.getSize()); |
6807 |
24 Aug 22 |
nicklas |
1273 |
|
7083 |
28 Mar 23 |
nicklas |
// Items in the Hisat pipeline waiting to be aligned |
7083 |
28 Mar 23 |
nicklas |
1275 |
ItemList bwaMem2Pipeline = BiomaterialList.BWA_MEM2_PIPELINE.load(dc); |
7083 |
28 Mar 23 |
nicklas |
1276 |
json.put("merged-sequences-for-bwamem2-alignment", bwaMem2Pipeline.getSize()); |
7083 |
28 Mar 23 |
nicklas |
1277 |
|
5826 |
18 Feb 20 |
nicklas |
// Items in the MIPs pipeline waiting to be aligned |
5826 |
18 Feb 20 |
nicklas |
1279 |
ItemList mipsAlignPipeline = BiomaterialList.MIPS_ALIGN_PIPELINE.load(dc); |
5826 |
18 Feb 20 |
nicklas |
1280 |
json.put("merged-sequences-for-mips-alignment", mipsAlignPipeline.getSize()); |
7266 |
19 Jun 23 |
nicklas |
1281 |
|
5845 |
26 Feb 20 |
nicklas |
// Aligned sequences not confirmed |
3059 |
19 Dec 14 |
nicklas |
1283 |
query = DerivedBioAssay.getQuery(); |
4596 |
27 Sep 17 |
nicklas |
1284 |
Subtype.ALIGNED_SEQUENCES.addFilter(dc, query); |
5845 |
26 Feb 20 |
nicklas |
1285 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
1286 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5845 |
26 Feb 20 |
nicklas |
// The align job must be ended |
4596 |
27 Sep 17 |
nicklas |
1288 |
query.join(Hql.innerJoin("job", "jb")); |
5845 |
26 Feb 20 |
nicklas |
1289 |
Subtype.createFilterParameter(dc, query, "jb", "jobType"); |
4596 |
27 Sep 17 |
nicklas |
1290 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
4596 |
27 Sep 17 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
3059 |
19 Dec 14 |
nicklas |
1292 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
4596 |
27 Sep 17 |
nicklas |
1293 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
4596 |
27 Sep 17 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
3059 |
19 Dec 14 |
nicklas |
1295 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
1296 |
query.restrict( |
4596 |
27 Sep 17 |
nicklas |
1297 |
Restrictions.or( |
4596 |
27 Sep 17 |
nicklas |
1298 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
4596 |
27 Sep 17 |
nicklas |
1299 |
Restrictions.eq(Hql.alias("ap"), null) |
4596 |
27 Sep 17 |
nicklas |
1300 |
)); |
3059 |
19 Dec 14 |
nicklas |
1301 |
query.setCacheResult(true); |
5845 |
26 Feb 20 |
nicklas |
1302 |
|
5845 |
26 Feb 20 |
nicklas |
// Hisat alignments |
5845 |
26 Feb 20 |
nicklas |
1304 |
query.setParameter("pipeline", Pipeline.RNASEQ_HISAT_STRINGTIE.getName(), Type.STRING); |
5845 |
26 Feb 20 |
nicklas |
1305 |
query.setEntityParameter("jobType", Subtype.HISAT_ALIGN_JOB.get(dc)); |
4596 |
27 Sep 17 |
nicklas |
1306 |
json.put("hisat-aligned-sequences-not-confirmed", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1307 |
// --- |
6811 |
25 Aug 22 |
nicklas |
// Hisat/2023 alignments |
6811 |
25 Aug 22 |
nicklas |
1309 |
query.setParameter("pipeline", Pipeline.RNASEQ_HISAT_2023.getName(), Type.STRING); |
6807 |
24 Aug 22 |
nicklas |
1310 |
query.setEntityParameter("jobType", Subtype.HISAT_ALIGN_JOB.get(dc)); |
6807 |
24 Aug 22 |
nicklas |
1311 |
json.put("hisat2023-aligned-sequences-not-confirmed", query.count(dc)); |
6807 |
24 Aug 22 |
nicklas |
1312 |
// --- |
5845 |
26 Feb 20 |
nicklas |
// MIPs alignments |
5845 |
26 Feb 20 |
nicklas |
1314 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5845 |
26 Feb 20 |
nicklas |
1315 |
query.setEntityParameter("jobType", Subtype.MIPS_ALIGN_JOB.get(dc)); |
5845 |
26 Feb 20 |
nicklas |
1316 |
json.put("mips-aligned-sequences-not-confirmed", query.count(dc)); |
5845 |
26 Feb 20 |
nicklas |
1317 |
// --- |
7092 |
04 Apr 23 |
nicklas |
// WGS alignments -- we must check DNA_NORMAL_WGS AND DNA_TUMOR_WGS |
7092 |
04 Apr 23 |
nicklas |
1319 |
query.setEntityParameter("jobType", Subtype.BWA_MEM2_ALIGN_JOB.get(dc)); |
7092 |
04 Apr 23 |
nicklas |
1320 |
query.setParameter("pipeline", Pipeline.DNA_NORMAL_WGS.getName(), Type.STRING); |
7092 |
04 Apr 23 |
nicklas |
1321 |
long count = query.count(dc); |
7092 |
04 Apr 23 |
nicklas |
1322 |
query.setParameter("pipeline", Pipeline.DNA_TUMOR_WGS.getName(), Type.STRING); |
7092 |
04 Apr 23 |
nicklas |
1323 |
count += query.count(dc); |
7092 |
04 Apr 23 |
nicklas |
1324 |
json.put("bwamem2-aligned-sequences-not-confirmed", count); |
7092 |
04 Apr 23 |
nicklas |
1325 |
// --- |
5845 |
26 Feb 20 |
nicklas |
1326 |
|
4642 |
28 Nov 17 |
nicklas |
// Aligned sequences with VCF file that has not been checked |
4642 |
28 Nov 17 |
nicklas |
1328 |
query = DerivedBioAssay.getQuery(); |
4642 |
28 Nov 17 |
nicklas |
1329 |
Subtype.ALIGNED_SEQUENCES.addFilter(dc, query); |
7211 |
29 May 23 |
nicklas |
1330 |
Pipeline.createFilterParameter(dc, query); |
4642 |
28 Nov 17 |
nicklas |
1331 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4642 |
28 Nov 17 |
nicklas |
// Must have 'qc_genotype.vcf' FILE already |
4642 |
28 Nov 17 |
nicklas |
1333 |
query.restrict(AnyToAnyRestriction.exists("qc_genotype.vcf", Item.FILE)); |
4642 |
28 Nov 17 |
nicklas |
// Must NOT have a QC_GENOTYPE_STATUS annotation |
4642 |
28 Nov 17 |
nicklas |
1335 |
query.join(Annotations.leftJoin(null, Annotationtype.QC_GENOTYPE_STATUS.load(dc), "qc")); |
4642 |
28 Nov 17 |
nicklas |
1336 |
query.restrict(Restrictions.eq(Hql.alias("qc"), null)); |
4642 |
28 Nov 17 |
nicklas |
1337 |
query.setCacheResult(true); |
4642 |
28 Nov 17 |
nicklas |
1338 |
// --- |
7211 |
29 May 23 |
nicklas |
1339 |
query.setParameter("pipeline", Pipeline.RNASEQ_HISAT_STRINGTIE.getName(), Type.STRING); |
7211 |
29 May 23 |
nicklas |
1340 |
json.put("rnaseq-alignments-for-genotype-qc", query.count(dc)); |
7211 |
29 May 23 |
nicklas |
1341 |
// --- |
7211 |
29 May 23 |
nicklas |
1342 |
query.setParameter("pipeline", Pipeline.DNA_NORMAL_WGS.getName(), Type.STRING); |
7211 |
29 May 23 |
nicklas |
1343 |
json.put("wgs-normal-alignments-for-genotype-qc", query.count(dc)); |
7211 |
29 May 23 |
nicklas |
1344 |
// --- |
7217 |
30 May 23 |
nicklas |
1345 |
query.setParameter("pipeline", Pipeline.DNA_TUMOR_WGS.getName(), Type.STRING); |
7217 |
30 May 23 |
nicklas |
1346 |
json.put("wgs-tumor-alignments-for-genotype-qc", query.count(dc)); |
7217 |
30 May 23 |
nicklas |
1347 |
// --- |
7211 |
29 May 23 |
nicklas |
1348 |
|
7292 |
21 Aug 23 |
nicklas |
// Items in the ASCAT pipeline |
7292 |
21 Aug 23 |
nicklas |
1350 |
ItemList ascatPipeline = BiomaterialList.ASCAT_PIPELINE.load(dc); |
7292 |
21 Aug 23 |
nicklas |
1351 |
json.put("aligned-sequences-for-ascat", ascatPipeline.getSize()); |
7292 |
21 Aug 23 |
nicklas |
1352 |
|
7292 |
21 Aug 23 |
nicklas |
// ASCAT analysis not confirmed |
7392 |
03 Nov 23 |
nicklas |
1354 |
query = DerivedBioAssay.getQuery(); |
7292 |
21 Aug 23 |
nicklas |
1355 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
7292 |
21 Aug 23 |
nicklas |
1356 |
Subtype.COPY_NUMBER.addFilter(dc, query); |
7292 |
21 Aug 23 |
nicklas |
// The job must be an ASCAT job and it must be ended |
7292 |
21 Aug 23 |
nicklas |
1358 |
query.join(Hql.innerJoin("job", "jb")); |
7292 |
21 Aug 23 |
nicklas |
1359 |
Subtype.ASCAT_JOB.addFilter(dc, query, "jb"); |
7292 |
21 Aug 23 |
nicklas |
1360 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
7292 |
21 Aug 23 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
7292 |
21 Aug 23 |
nicklas |
1362 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
7292 |
21 Aug 23 |
nicklas |
1363 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
7292 |
21 Aug 23 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
7292 |
21 Aug 23 |
nicklas |
1365 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
7292 |
21 Aug 23 |
nicklas |
1366 |
query.restrict( |
7292 |
21 Aug 23 |
nicklas |
1367 |
Restrictions.or( |
7292 |
21 Aug 23 |
nicklas |
1368 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
7292 |
21 Aug 23 |
nicklas |
1369 |
Restrictions.eq(Hql.alias("ap"), null) |
7292 |
21 Aug 23 |
nicklas |
1370 |
)); |
7292 |
21 Aug 23 |
nicklas |
1371 |
json.put("ascat-not-confirmed", query.count(dc)); |
7292 |
21 Aug 23 |
nicklas |
1372 |
|
4663 |
29 Jan 18 |
nicklas |
// Items waiting in the StringTie pipeline |
4659 |
26 Jan 18 |
nicklas |
1374 |
ItemList stringtiePipeline = BiomaterialList.STRINGTIE_PIPELINE.load(dc); |
4659 |
26 Jan 18 |
nicklas |
1375 |
json.put("aligned-sequences-for-stringtie", stringtiePipeline.getSize()); |
4659 |
26 Jan 18 |
nicklas |
1376 |
|
6817 |
26 Aug 22 |
nicklas |
// Items waiting in the StringTie/2023 pipeline |
6817 |
26 Aug 22 |
nicklas |
1378 |
ItemList stringtie2023Pipeline = BiomaterialList.STRINGTIE_2023_PIPELINE.load(dc); |
6817 |
26 Aug 22 |
nicklas |
1379 |
json.put("aligned-sequences-for-stringtie2023", stringtie2023Pipeline.getSize()); |
6817 |
26 Aug 22 |
nicklas |
1380 |
|
6868 |
15 Nov 22 |
nicklas |
// Items waiting in the Methylation pipeline |
6868 |
15 Nov 22 |
nicklas |
1382 |
ItemList methylationPipeline = BiomaterialList.METHYLATION_PIPELINE.load(dc); |
6868 |
15 Nov 22 |
nicklas |
1383 |
json.put("methylation-for-beta-analysis", methylationPipeline.getSize()); |
6868 |
15 Nov 22 |
nicklas |
1384 |
|
6879 |
22 Nov 22 |
nicklas |
// Methylation items not confirmed sequences not confirmed |
6879 |
22 Nov 22 |
nicklas |
1386 |
query = DerivedBioAssay.getQuery(); |
6879 |
22 Nov 22 |
nicklas |
1387 |
Subtype.METHYLATION.addFilter(dc, query); |
6879 |
22 Nov 22 |
nicklas |
1388 |
Pipeline.DNA_METHYLATION.addFilter(dc, query); |
6879 |
22 Nov 22 |
nicklas |
1389 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6879 |
22 Nov 22 |
nicklas |
// The job must be ended |
6879 |
22 Nov 22 |
nicklas |
1391 |
query.join(Hql.innerJoin("job", "jb")); |
6879 |
22 Nov 22 |
nicklas |
1392 |
Subtype.METHYLATION_BETA_JOB.addFilter(dc, query, "jb"); |
6879 |
22 Nov 22 |
nicklas |
1393 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
6879 |
22 Nov 22 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
6879 |
22 Nov 22 |
nicklas |
1395 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
6879 |
22 Nov 22 |
nicklas |
1396 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
6880 |
22 Nov 22 |
nicklas |
// Must NOT have AutoProcess annotation |
6879 |
22 Nov 22 |
nicklas |
1398 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
6880 |
22 Nov 22 |
nicklas |
1399 |
query.restrict(Restrictions.eq(Hql.alias("ap"), null)); |
6879 |
22 Nov 22 |
nicklas |
1400 |
query.setCacheResult(true); |
6879 |
22 Nov 22 |
nicklas |
1401 |
json.put("methylation-beta-not-confirmed", query.count(dc)); |
6879 |
22 Nov 22 |
nicklas |
1402 |
|
7392 |
03 Nov 23 |
nicklas |
// PanelOfNormal items not confirmed |
7392 |
03 Nov 23 |
nicklas |
1404 |
query = DerivedBioAssay.getQuery(); |
7392 |
03 Nov 23 |
nicklas |
1405 |
Subtype.PANEL_OF_NORMAL.addFilter(dc, query); |
7392 |
03 Nov 23 |
nicklas |
1406 |
Pipeline.DNA_NORMAL_WGS.addFilter(dc, query); |
7392 |
03 Nov 23 |
nicklas |
1407 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
7392 |
03 Nov 23 |
nicklas |
// The job must be ended |
7392 |
03 Nov 23 |
nicklas |
1409 |
query.join(Hql.innerJoin("job", "jb")); |
7392 |
03 Nov 23 |
nicklas |
1410 |
Subtype.VARIANT_CALLING_JOB.addFilter(dc, query, "jb"); |
7392 |
03 Nov 23 |
nicklas |
1411 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
7392 |
03 Nov 23 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
7392 |
03 Nov 23 |
nicklas |
1413 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
7392 |
03 Nov 23 |
nicklas |
1414 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
7392 |
03 Nov 23 |
nicklas |
// Must NOT have AutoProcess annotation |
7392 |
03 Nov 23 |
nicklas |
1416 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
7392 |
03 Nov 23 |
nicklas |
1417 |
query.restrict(Restrictions.eq(Hql.alias("ap"), null)); |
7392 |
03 Nov 23 |
nicklas |
1418 |
query.setCacheResult(true); |
7392 |
03 Nov 23 |
nicklas |
1419 |
json.put("wgs-panel-of-normals-not-confirmed", query.count(dc)); |
7392 |
03 Nov 23 |
nicklas |
1420 |
|
5015 |
08 Oct 18 |
nicklas |
// Items waiting in the mBAF analysis pipeline |
5015 |
08 Oct 18 |
nicklas |
1422 |
ItemList mBafPipeline = BiomaterialList.MBAF_PIPELINE.load(dc); |
5015 |
08 Oct 18 |
nicklas |
1423 |
json.put("aligned-sequences-for-mbaf", mBafPipeline.getSize()); |
5015 |
08 Oct 18 |
nicklas |
1424 |
|
5683 |
22 Oct 19 |
nicklas |
// Items waiting in the Variant calling pipeline |
5683 |
22 Oct 19 |
nicklas |
1426 |
ItemList variantCallingPipeline = BiomaterialList.VARIANT_CALLING_PIPELINE.load(dc); |
5683 |
22 Oct 19 |
nicklas |
1427 |
json.put("aligned-sequences-for-variant-calling", variantCallingPipeline.getSize()); |
5683 |
22 Oct 19 |
nicklas |
1428 |
|
7398 |
07 Nov 23 |
nicklas |
// Items in the WGS variant calling pipeline |
7398 |
07 Nov 23 |
nicklas |
1430 |
ItemList wgsVariantCallingPipeline = BiomaterialList.WGS_VARIANT_CALLING_PIPELINE.load(dc); |
7400 |
07 Nov 23 |
nicklas |
1431 |
json.put("aligned-sequences-for-wgs-variant-calling", wgsVariantCallingPipeline.getSize()); |
7398 |
07 Nov 23 |
nicklas |
1432 |
|
4687 |
26 Feb 18 |
nicklas |
// Items marked for removal |
4687 |
26 Feb 18 |
nicklas |
1434 |
query = DerivedBioAssay.getQuery(); |
4687 |
26 Feb 18 |
nicklas |
1435 |
query.setIncludes(Arrays.asList(Include.IN_PROJECT, Include.REMOVED)); |
4687 |
26 Feb 18 |
nicklas |
1436 |
query.restrict(Restrictions.or( |
4687 |
26 Feb 18 |
nicklas |
1437 |
Subtype.DEMUXED_SEQUENCES.restriction(dc, null), |
4687 |
26 Feb 18 |
nicklas |
1438 |
Subtype.MERGED_SEQUENCES.restriction(dc, null), |
4687 |
26 Feb 18 |
nicklas |
1439 |
Subtype.MASKED_SEQUENCES.restriction(dc, null), |
7345 |
11 Sep 23 |
nicklas |
1440 |
Subtype.ALIGNED_SEQUENCES.restriction(dc, null), |
7345 |
11 Sep 23 |
nicklas |
1441 |
Subtype.COPY_NUMBER.restriction(dc, null), |
7345 |
11 Sep 23 |
nicklas |
1442 |
Subtype.METHYLATION.restriction(dc, null), |
7345 |
11 Sep 23 |
nicklas |
1443 |
Subtype.GENOTYPE_CALL.restriction(dc, null) |
4687 |
26 Feb 18 |
nicklas |
1444 |
)); |
4687 |
26 Feb 18 |
nicklas |
1445 |
|
4687 |
26 Feb 18 |
nicklas |
1446 |
json.put("analysis-cleanup-dba", query.count(dc)); |
4687 |
26 Feb 18 |
nicklas |
1447 |
|
4781 |
23 Apr 18 |
nicklas |
// Alignments in the Flagged alignments list |
4781 |
23 Apr 18 |
nicklas |
1449 |
ItemList flaggedAlignment = BiomaterialList.FLAGGED_ALIGNMENT.load(dc); |
4781 |
23 Apr 18 |
nicklas |
1450 |
json.put("flagged-alignment", flaggedAlignment.getSize()); |
4781 |
23 Apr 18 |
nicklas |
1451 |
// --- |
4781 |
23 Apr 18 |
nicklas |
1452 |
|
3059 |
19 Dec 14 |
nicklas |
1453 |
} |
3059 |
19 Dec 14 |
nicklas |
1454 |
|
3059 |
19 Dec 14 |
nicklas |
1455 |
private void countJobs(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
1456 |
{ |
5493 |
13 Jun 19 |
nicklas |
// Unconfirmed demux jobs (RNA-seq) |
3059 |
19 Dec 14 |
nicklas |
1458 |
ItemQuery<Job> query = Job.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1459 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
3059 |
19 Dec 14 |
nicklas |
// The job must be ended |
3059 |
19 Dec 14 |
nicklas |
1461 |
query.restrict(Restrictions.neq(Hql.property("ended"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Join jobs for DemuxedSequences |
3059 |
19 Dec 14 |
nicklas |
1463 |
query.join(Hql.innerJoin("derivedBioAssays", "dba")); |
3059 |
19 Dec 14 |
nicklas |
1464 |
Subtype.DEMUXED_SEQUENCES.addFilter(dc, query, "dba"); |
5493 |
13 Jun 19 |
nicklas |
1465 |
Pipeline.createFilterParameter(dc, query, "dba"); |
3723 |
25 Jan 16 |
nicklas |
// Must have a none or "Partial" ANALYSIS_RESULT annotation |
3059 |
19 Dec 14 |
nicklas |
1467 |
query.join(Annotations.leftJoin("dba", Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
3723 |
25 Jan 16 |
nicklas |
1468 |
query.restrict(Restrictions.or( |
3723 |
25 Jan 16 |
nicklas |
1469 |
Restrictions.eq(Hql.alias("ar"), Expressions.string(DemuxedSequences.DEMUX_PARTIAL)), |
3723 |
25 Jan 16 |
nicklas |
1470 |
Restrictions.eq(Hql.alias("ar"), null) |
3723 |
25 Jan 16 |
nicklas |
1471 |
)); |
3059 |
19 Dec 14 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
3059 |
19 Dec 14 |
nicklas |
1473 |
query.join(Annotations.leftJoin("dba", Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
1474 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
1475 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
1476 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
3059 |
19 Dec 14 |
nicklas |
1477 |
Restrictions.eq(Hql.alias("ap"), null) |
3059 |
19 Dec 14 |
nicklas |
1478 |
)); |
3059 |
19 Dec 14 |
nicklas |
1479 |
query.setDistinct(true); |
3059 |
19 Dec 14 |
nicklas |
1480 |
query.setCacheResult(true); |
5493 |
13 Jun 19 |
nicklas |
1481 |
query.setParameter("pipeline", Pipeline.RNA_SEQ.getName(), Type.STRING); |
5493 |
13 Jun 19 |
nicklas |
1482 |
json.put("demux-jobs-not-confirmed-rnaseq", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1483 |
// --- |
5493 |
13 Jun 19 |
nicklas |
1484 |
|
5493 |
13 Jun 19 |
nicklas |
// Unconfirmed demux jobs (MIPs) |
5493 |
13 Jun 19 |
nicklas |
1486 |
query.setParameter("pipeline", Pipeline.MIPS.getName(), Type.STRING); |
5493 |
13 Jun 19 |
nicklas |
1487 |
json.put("demux-jobs-not-confirmed-mips", query.count(dc)); |
5493 |
13 Jun 19 |
nicklas |
1488 |
// --- |
5493 |
13 Jun 19 |
nicklas |
1489 |
|
3059 |
19 Dec 14 |
nicklas |
1490 |
} |
3059 |
19 Dec 14 |
nicklas |
1491 |
|
3059 |
19 Dec 14 |
nicklas |
1492 |
|
3059 |
19 Dec 14 |
nicklas |
1493 |
private void countRawBioAssays(DbControl dc, JSONObject json) |
3059 |
19 Dec 14 |
nicklas |
1494 |
{ |
3506 |
23 Sep 15 |
nicklas |
1495 |
String geneReportPdfName = Reggie.getConfig().getConfig("rscript/gene-report/pdf-name", null, GeneReportWorker.DEFAULT_PDF_NAME); |
3059 |
19 Dec 14 |
nicklas |
1496 |
|
6817 |
26 Aug 22 |
nicklas |
// Raw bioassays not confirmed |
3059 |
19 Dec 14 |
nicklas |
1498 |
ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1499 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6817 |
26 Aug 22 |
nicklas |
1500 |
Rawdatatype.createFilterParameter(dc, query); |
6817 |
26 Aug 22 |
nicklas |
1501 |
Pipeline.createFilterParameter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
// The job must be ended |
3059 |
19 Dec 14 |
nicklas |
1503 |
query.join(Hql.innerJoin("job", "jb")); |
3059 |
19 Dec 14 |
nicklas |
1504 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
3059 |
19 Dec 14 |
nicklas |
1506 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
3059 |
19 Dec 14 |
nicklas |
1507 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
3059 |
19 Dec 14 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
3059 |
19 Dec 14 |
nicklas |
1509 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
3059 |
19 Dec 14 |
nicklas |
1510 |
query.restrict( |
3059 |
19 Dec 14 |
nicklas |
1511 |
Restrictions.or( |
3059 |
19 Dec 14 |
nicklas |
1512 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
3059 |
19 Dec 14 |
nicklas |
1513 |
Restrictions.eq(Hql.alias("ap"), null) |
3059 |
19 Dec 14 |
nicklas |
1514 |
)); |
3059 |
19 Dec 14 |
nicklas |
1515 |
query.setCacheResult(true); |
6817 |
26 Aug 22 |
nicklas |
1516 |
|
6817 |
26 Aug 22 |
nicklas |
// Cufflinks |
6817 |
26 Aug 22 |
nicklas |
1518 |
query.setParameter("pipeline", Pipeline.RNASEQ_LEGACY.getName(), Type.STRING); |
6817 |
26 Aug 22 |
nicklas |
1519 |
query.setParameter("rawDataType", Rawdatatype.CUFFLINKS.getId(), Type.STRING); |
3059 |
19 Dec 14 |
nicklas |
1520 |
json.put("cufflinks-not-confirmed", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1521 |
// --- |
4670 |
05 Feb 18 |
nicklas |
1522 |
|
6817 |
26 Aug 22 |
nicklas |
// StringTie |
6817 |
26 Aug 22 |
nicklas |
1524 |
query.setParameter("pipeline", Pipeline.RNASEQ_HISAT_STRINGTIE.getName(), Type.STRING); |
6817 |
26 Aug 22 |
nicklas |
1525 |
query.setParameter("rawDataType", Rawdatatype.STRINGTIE.getId(), Type.STRING); |
4670 |
05 Feb 18 |
nicklas |
1526 |
json.put("stringtie-not-confirmed", query.count(dc)); |
4670 |
05 Feb 18 |
nicklas |
1527 |
// --- |
6817 |
26 Aug 22 |
nicklas |
1528 |
|
6817 |
26 Aug 22 |
nicklas |
// StringTie/2023 |
6817 |
26 Aug 22 |
nicklas |
1530 |
query.setParameter("pipeline", Pipeline.RNASEQ_STRINGTIE_2023.getName(), Type.STRING); |
6817 |
26 Aug 22 |
nicklas |
1531 |
query.setParameter("rawDataType", Rawdatatype.STRINGTIE.getId(), Type.STRING); |
6817 |
26 Aug 22 |
nicklas |
1532 |
json.put("stringtie2023-not-confirmed", query.count(dc)); |
6817 |
26 Aug 22 |
nicklas |
1533 |
// --- |
6817 |
26 Aug 22 |
nicklas |
1534 |
|
6023 |
26 Oct 20 |
nicklas |
// Cufflinks raw bioassays ready for gene report creation |
6023 |
26 Oct 20 |
nicklas |
1536 |
ItemList geneReportList = BiomaterialList.GENE_REPORT_CREATE.load(dc); |
6023 |
26 Oct 20 |
nicklas |
1537 |
json.put("rawbioassys-without-genereport", geneReportList.getSize()); |
3059 |
19 Dec 14 |
nicklas |
1538 |
// --- |
3059 |
19 Dec 14 |
nicklas |
1539 |
|
4667 |
01 Feb 18 |
nicklas |
// Cufflinks raw bioassays without pilot report |
6023 |
26 Oct 20 |
nicklas |
1541 |
ItemList pilotReportList = BiomaterialList.PILOT_REPORT_CREATE.load(dc); |
6023 |
26 Oct 20 |
nicklas |
1542 |
json.put("rawbioassys-without-pilotreport", pilotReportList.getSize()); |
3492 |
18 Sep 15 |
nicklas |
1543 |
// --- |
3492 |
18 Sep 15 |
nicklas |
1544 |
|
5665 |
14 Oct 19 |
nicklas |
// StringTie raw bioassays without SCAN-B report |
6023 |
26 Oct 20 |
nicklas |
1546 |
ItemList scanbReportList = BiomaterialList.SCANB_REPORT_CREATE.load(dc); |
6023 |
26 Oct 20 |
nicklas |
1547 |
json.put("rawbioassys-without-scanbreport", scanbReportList.getSize()); |
5665 |
14 Oct 19 |
nicklas |
1548 |
// --- |
5665 |
14 Oct 19 |
nicklas |
1549 |
|
4667 |
01 Feb 18 |
nicklas |
// All Cufflinks raw bioassays with a gene report pdf |
3059 |
19 Dec 14 |
nicklas |
1551 |
query = RawBioAssay.getQuery(); |
3059 |
19 Dec 14 |
nicklas |
1552 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4667 |
01 Feb 18 |
nicklas |
1553 |
Rawdatatype.CUFFLINKS.addFilter(dc, query); |
3059 |
19 Dec 14 |
nicklas |
// Must have 'genereport.pdf' FILE already |
3492 |
18 Sep 15 |
nicklas |
1555 |
query.restrict(AnyToAnyRestriction.exists(geneReportPdfName, Item.FILE)); |
3059 |
19 Dec 14 |
nicklas |
1556 |
query.setCacheResult(true); |
3059 |
19 Dec 14 |
nicklas |
1557 |
json.put("rawbioassys-all-with-genereport", query.count(dc)); |
3059 |
19 Dec 14 |
nicklas |
1558 |
// --- |
4687 |
26 Feb 18 |
nicklas |
1559 |
|
5724 |
13 Nov 19 |
nicklas |
// VariantCall raw bioassays not confirmed |
5724 |
13 Nov 19 |
nicklas |
1561 |
query = RawBioAssay.getQuery(); |
5724 |
13 Nov 19 |
nicklas |
1562 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
5724 |
13 Nov 19 |
nicklas |
1563 |
Rawdatatype.VARIANT_CALL.addFilter(dc, query); |
7435 |
15 Nov 23 |
nicklas |
1564 |
Pipeline.createFilterParameter(dc, query); |
5724 |
13 Nov 19 |
nicklas |
// The job must be ended |
5724 |
13 Nov 19 |
nicklas |
1566 |
query.join(Hql.innerJoin("job", "jb")); |
5724 |
13 Nov 19 |
nicklas |
1567 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
5724 |
13 Nov 19 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
5724 |
13 Nov 19 |
nicklas |
1569 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
5724 |
13 Nov 19 |
nicklas |
1570 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
5724 |
13 Nov 19 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
5724 |
13 Nov 19 |
nicklas |
1572 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
5724 |
13 Nov 19 |
nicklas |
1573 |
query.restrict( |
5724 |
13 Nov 19 |
nicklas |
1574 |
Restrictions.or( |
5724 |
13 Nov 19 |
nicklas |
1575 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
5724 |
13 Nov 19 |
nicklas |
1576 |
Restrictions.eq(Hql.alias("ap"), null) |
5724 |
13 Nov 19 |
nicklas |
1577 |
)); |
5724 |
13 Nov 19 |
nicklas |
1578 |
query.setCacheResult(true); |
7435 |
15 Nov 23 |
nicklas |
1579 |
|
7435 |
15 Nov 23 |
nicklas |
// RNAseq |
7435 |
15 Nov 23 |
nicklas |
1581 |
query.setParameter("pipeline", Pipeline.RNASEQ_HISAT_VARIANTCALL.getName(), Type.STRING); |
5724 |
13 Nov 19 |
nicklas |
1582 |
json.put("variantcall-not-confirmed", query.count(dc)); |
7435 |
15 Nov 23 |
nicklas |
1583 |
|
7435 |
15 Nov 23 |
nicklas |
// WGS |
7435 |
15 Nov 23 |
nicklas |
1585 |
query.setParameter("pipeline", Pipeline.DNA_PAIRED_VARIANTCALL.getName(), Type.STRING); |
7435 |
15 Nov 23 |
nicklas |
1586 |
json.put("wgs-variantcall-not-confirmed", query.count(dc)); |
5724 |
13 Nov 19 |
nicklas |
1587 |
// --- |
5724 |
13 Nov 19 |
nicklas |
1588 |
|
5876 |
24 Mar 20 |
nicklas |
// Variant calls that need import of variants |
5876 |
24 Mar 20 |
nicklas |
1590 |
ItemList variantImport = BiomaterialList.VARIANT_IMPORT_TMP.load(dc); |
5876 |
24 Mar 20 |
nicklas |
1591 |
json.put("variant-calls-needing-import", variantImport.getSize()); |
5876 |
24 Mar 20 |
nicklas |
1592 |
|
6387 |
15 Sep 21 |
nicklas |
// Variant calls waiting for targeted genotyping |
6387 |
15 Sep 21 |
nicklas |
1594 |
ItemList tgtPipeline = BiomaterialList.TARGETED_GENOTYPE_PIPELINE.load(dc); |
6387 |
15 Sep 21 |
nicklas |
1595 |
json.put("variantcall-for-targeted-genotype", tgtPipeline.getSize()); |
6387 |
15 Sep 21 |
nicklas |
1596 |
|
5922 |
27 Apr 20 |
nicklas |
// Items waiting in the SSP pipeline |
5922 |
27 Apr 20 |
nicklas |
1598 |
ItemList sspPipeline = BiomaterialList.SSP_PIPELINE.load(dc); |
5922 |
27 Apr 20 |
nicklas |
1599 |
json.put("rawbioassays-for-ssp", sspPipeline.getSize()); |
5724 |
13 Nov 19 |
nicklas |
1600 |
|
4687 |
26 Feb 18 |
nicklas |
// Items marked for removal |
4687 |
26 Feb 18 |
nicklas |
1602 |
query = RawBioAssay.getQuery(); |
4687 |
26 Feb 18 |
nicklas |
1603 |
query.setIncludes(Arrays.asList(Include.IN_PROJECT, Include.REMOVED)); |
4687 |
26 Feb 18 |
nicklas |
1604 |
query.restrict(Restrictions.or( |
4687 |
26 Feb 18 |
nicklas |
1605 |
Rawdatatype.CUFFLINKS.restriction(dc, null), |
5722 |
13 Nov 19 |
nicklas |
1606 |
Rawdatatype.STRINGTIE.restriction(dc, null), |
5722 |
13 Nov 19 |
nicklas |
1607 |
Rawdatatype.VARIANT_CALL.restriction(dc, null) |
4687 |
26 Feb 18 |
nicklas |
1608 |
)); |
4687 |
26 Feb 18 |
nicklas |
1609 |
json.put("analysis-cleanup-rba", query.count(dc)); |
4687 |
26 Feb 18 |
nicklas |
1610 |
|
3059 |
19 Dec 14 |
nicklas |
1611 |
} |
3059 |
19 Dec 14 |
nicklas |
1612 |
|
3059 |
19 Dec 14 |
nicklas |
1613 |
/** |
3844 |
14 Apr 16 |
nicklas |
Count the stray folders in the project and external archives. |
3844 |
14 Apr 16 |
nicklas |
1615 |
*/ |
7076 |
27 Mar 23 |
nicklas |
1616 |
private int countStrayFolders(DbControl dc, JSONObject json) |
3844 |
14 Apr 16 |
nicklas |
1617 |
{ |
7076 |
27 Mar 23 |
nicklas |
1618 |
int numFolders = -1; |
4090 |
08 Sep 16 |
nicklas |
1619 |
try |
4090 |
08 Sep 16 |
nicklas |
1620 |
{ |
7372 |
06 Oct 23 |
nicklas |
1621 |
FastAnnotationLoader<String> dffLoader = Annotationtype.DATA_FILES_FOLDER.get(dc).getFastLoader(dc); |
4090 |
08 Sep 16 |
nicklas |
// Load known folders from the "DataFilesFolder" annotation |
4090 |
08 Sep 16 |
nicklas |
1623 |
Set<String> knownFolders = new HashSet<String>(); |
4090 |
08 Sep 16 |
nicklas |
1624 |
knownFolders.add("/debug"); |
7372 |
06 Oct 23 |
nicklas |
1625 |
knownFolders.add("/he-hiresscans"); |
7372 |
06 Oct 23 |
nicklas |
1626 |
AdminServlet.loadDataFileFolders(dc, dffLoader, DerivedBioAssay.getQuery(), knownFolders, null); |
7372 |
06 Oct 23 |
nicklas |
1627 |
AdminServlet.loadDataFileFolders(dc, dffLoader, RawBioAssay.getQuery(), knownFolders, null); |
4090 |
08 Sep 16 |
nicklas |
1628 |
|
4090 |
08 Sep 16 |
nicklas |
// List all folders in the file server archives |
4090 |
08 Sep 16 |
nicklas |
1630 |
Set<RemoteFolder> remoteFolders = new TreeSet<RemoteFolder>(); |
4090 |
08 Sep 16 |
nicklas |
1631 |
AdminServlet.loadRemoteFolders(dc, Fileserver.PROJECT_ARCHIVE, remoteFolders); |
7047 |
14 Feb 23 |
nicklas |
1632 |
AdminServlet.loadRemoteFolders(dc, Fileserver.PROJECT_ARCHIVE_DNA, remoteFolders); |
4090 |
08 Sep 16 |
nicklas |
1633 |
AdminServlet.loadRemoteFolders(dc, Fileserver.EXTERNAL_ARCHIVE, remoteFolders); |
4090 |
08 Sep 16 |
nicklas |
1634 |
|
4090 |
08 Sep 16 |
nicklas |
1635 |
List<RemoteFolder> strayFolders = AdminServlet.findStrayFolders(remoteFolders, knownFolders); |
7076 |
27 Mar 23 |
nicklas |
1636 |
numFolders = strayFolders.size(); |
7076 |
27 Mar 23 |
nicklas |
1637 |
json.put("stray-folders", numFolders); |
4090 |
08 Sep 16 |
nicklas |
1638 |
} |
4090 |
08 Sep 16 |
nicklas |
1639 |
catch (RuntimeException ex) |
4090 |
08 Sep 16 |
nicklas |
1640 |
{ |
4090 |
08 Sep 16 |
nicklas |
1641 |
logger.error("Exception when counting stray folders", ex); |
4090 |
08 Sep 16 |
nicklas |
1642 |
} |
7076 |
27 Mar 23 |
nicklas |
1643 |
return numFolders; |
3844 |
14 Apr 16 |
nicklas |
1644 |
} |
3844 |
14 Apr 16 |
nicklas |
1645 |
|
6177 |
23 Mar 21 |
nicklas |
1646 |
private void countImportFiles(DbControl dc, JSONObject json) |
6177 |
23 Mar 21 |
nicklas |
1647 |
{ |
6198 |
07 Apr 21 |
nicklas |
1648 |
List<JsonFile> importFiles = new ArrayList<>(); |
6671 |
07 Apr 22 |
nicklas |
1649 |
Set<String> fastqFiles = new HashSet<>(); |
6177 |
23 Mar 21 |
nicklas |
1650 |
try |
6177 |
23 Mar 21 |
nicklas |
1651 |
{ |
6929 |
02 Dec 22 |
nicklas |
1652 |
importFiles = JsonFile.findJsonFiles(dc, Fileserver.IMPORT_GATEWAY.load(dc), null, false, 0, null); |
6671 |
07 Apr 22 |
nicklas |
1653 |
fastqFiles = JsonFile.findFastqPairs(dc, Fileserver.IMPORT_GATEWAY.load(dc)); |
6177 |
23 Mar 21 |
nicklas |
1654 |
} |
6177 |
23 Mar 21 |
nicklas |
1655 |
catch (RuntimeException ex) |
6177 |
23 Mar 21 |
nicklas |
1656 |
{ |
6177 |
23 Mar 21 |
nicklas |
1657 |
logger.error("Exception when counting import files", ex); |
6177 |
23 Mar 21 |
nicklas |
1658 |
} |
6177 |
23 Mar 21 |
nicklas |
1659 |
|
6671 |
07 Apr 22 |
nicklas |
1660 |
json.put("import-files-json", importFiles.size()); |
6671 |
07 Apr 22 |
nicklas |
1661 |
json.put("import-files-fastq", fastqFiles.size()); |
6177 |
23 Mar 21 |
nicklas |
1662 |
} |
3844 |
14 Apr 16 |
nicklas |
1663 |
|
3844 |
14 Apr 16 |
nicklas |
1664 |
/** |
3059 |
19 Dec 14 |
nicklas |
Timer for auto-confirmation |
3059 |
19 Dec 14 |
nicklas |
1666 |
*/ |
3059 |
19 Dec 14 |
nicklas |
1667 |
static class CounterTimerTask |
3059 |
19 Dec 14 |
nicklas |
1668 |
extends TimerTask |
3059 |
19 Dec 14 |
nicklas |
1669 |
{ |
3059 |
19 Dec 14 |
nicklas |
1670 |
|
3059 |
19 Dec 14 |
nicklas |
1671 |
public CounterTimerTask() |
3059 |
19 Dec 14 |
nicklas |
1672 |
{} |
3059 |
19 Dec 14 |
nicklas |
1673 |
|
3059 |
19 Dec 14 |
nicklas |
1674 |
@Override |
3059 |
19 Dec 14 |
nicklas |
1675 |
public void run() |
3059 |
19 Dec 14 |
nicklas |
1676 |
{ |
3059 |
19 Dec 14 |
nicklas |
1677 |
try |
3059 |
19 Dec 14 |
nicklas |
1678 |
{ |
3059 |
19 Dec 14 |
nicklas |
1679 |
getInstance().count(); |
3059 |
19 Dec 14 |
nicklas |
1680 |
} |
3059 |
19 Dec 14 |
nicklas |
1681 |
catch (Exception ex) |
3059 |
19 Dec 14 |
nicklas |
1682 |
{ |
3059 |
19 Dec 14 |
nicklas |
1683 |
logger.error("Exception when performing count", ex); |
3059 |
19 Dec 14 |
nicklas |
1684 |
} |
3059 |
19 Dec 14 |
nicklas |
1685 |
} |
3059 |
19 Dec 14 |
nicklas |
1686 |
|
3059 |
19 Dec 14 |
nicklas |
1687 |
} |
3059 |
19 Dec 14 |
nicklas |
1688 |
|
3059 |
19 Dec 14 |
nicklas |
1689 |
} |