1821 |
06 Feb 13 |
nicklas |
1 |
package net.sf.basedb.reggie.servlet; |
1821 |
06 Feb 13 |
nicklas |
2 |
|
1821 |
06 Feb 13 |
nicklas |
3 |
import java.io.IOException; |
1836 |
13 Feb 13 |
nicklas |
4 |
import java.util.Date; |
5012 |
05 Oct 18 |
nicklas |
5 |
import java.util.HashSet; |
1821 |
06 Feb 13 |
nicklas |
6 |
import java.util.List; |
5012 |
05 Oct 18 |
nicklas |
7 |
import java.util.Set; |
2144 |
19 Nov 13 |
olle |
8 |
import java.util.regex.Matcher; |
2144 |
19 Nov 13 |
olle |
9 |
import java.util.regex.Pattern; |
1821 |
06 Feb 13 |
nicklas |
10 |
|
1821 |
06 Feb 13 |
nicklas |
11 |
import javax.servlet.ServletException; |
1821 |
06 Feb 13 |
nicklas |
12 |
import javax.servlet.http.HttpServlet; |
1821 |
06 Feb 13 |
nicklas |
13 |
import javax.servlet.http.HttpServletRequest; |
1821 |
06 Feb 13 |
nicklas |
14 |
import javax.servlet.http.HttpServletResponse; |
1821 |
06 Feb 13 |
nicklas |
15 |
|
1821 |
06 Feb 13 |
nicklas |
16 |
import org.json.simple.JSONArray; |
1821 |
06 Feb 13 |
nicklas |
17 |
import org.json.simple.JSONObject; |
1821 |
06 Feb 13 |
nicklas |
18 |
|
1832 |
08 Feb 13 |
nicklas |
19 |
import net.sf.basedb.core.AnyToAny; |
1826 |
07 Feb 13 |
nicklas |
20 |
import net.sf.basedb.core.BioMaterialEvent; |
1832 |
08 Feb 13 |
nicklas |
21 |
import net.sf.basedb.core.BioPlate; |
1821 |
06 Feb 13 |
nicklas |
22 |
import net.sf.basedb.core.BioSource; |
1832 |
08 Feb 13 |
nicklas |
23 |
import net.sf.basedb.core.BioWell; |
1821 |
06 Feb 13 |
nicklas |
24 |
import net.sf.basedb.core.DbControl; |
2232 |
17 Feb 14 |
nicklas |
25 |
import net.sf.basedb.core.DerivedBioAssay; |
1831 |
08 Feb 13 |
nicklas |
26 |
import net.sf.basedb.core.Extract; |
1832 |
08 Feb 13 |
nicklas |
27 |
import net.sf.basedb.core.File; |
3373 |
09 Jun 15 |
nicklas |
28 |
import net.sf.basedb.core.Item; |
2707 |
29 Sep 14 |
nicklas |
29 |
import net.sf.basedb.core.ItemNotFoundException; |
1826 |
07 Feb 13 |
nicklas |
30 |
import net.sf.basedb.core.ItemQuery; |
2914 |
11 Nov 14 |
nicklas |
31 |
import net.sf.basedb.core.Job; |
2103 |
25 Oct 13 |
nicklas |
32 |
import net.sf.basedb.core.MeasuredBioMaterial; |
1821 |
06 Feb 13 |
nicklas |
33 |
import net.sf.basedb.core.Permission; |
2144 |
19 Nov 13 |
olle |
34 |
import net.sf.basedb.core.PermissionDeniedException; |
2232 |
17 Feb 14 |
nicklas |
35 |
import net.sf.basedb.core.PhysicalBioAssay; |
2918 |
11 Nov 14 |
nicklas |
36 |
import net.sf.basedb.core.RawBioAssay; |
1821 |
06 Feb 13 |
nicklas |
37 |
import net.sf.basedb.core.Sample; |
1821 |
06 Feb 13 |
nicklas |
38 |
import net.sf.basedb.core.SessionControl; |
6393 |
16 Sep 21 |
nicklas |
39 |
import net.sf.basedb.core.query.Expressions; |
6393 |
16 Sep 21 |
nicklas |
40 |
import net.sf.basedb.core.query.Hql; |
6393 |
16 Sep 21 |
nicklas |
41 |
import net.sf.basedb.core.query.Orders; |
6393 |
16 Sep 21 |
nicklas |
42 |
import net.sf.basedb.core.query.Restrictions; |
1826 |
07 Feb 13 |
nicklas |
43 |
import net.sf.basedb.reggie.JsonUtil; |
1821 |
06 Feb 13 |
nicklas |
44 |
import net.sf.basedb.reggie.Reggie; |
1821 |
06 Feb 13 |
nicklas |
45 |
import net.sf.basedb.reggie.Site; |
3534 |
08 Oct 15 |
nicklas |
46 |
import net.sf.basedb.reggie.XmlConfig; |
2914 |
11 Nov 14 |
nicklas |
47 |
import net.sf.basedb.reggie.dao.AlignedSequences; |
1821 |
06 Feb 13 |
nicklas |
48 |
import net.sf.basedb.reggie.dao.Annotationtype; |
6479 |
09 Nov 21 |
nicklas |
49 |
import net.sf.basedb.reggie.dao.BeadChip; |
3321 |
11 May 15 |
nicklas |
50 |
import net.sf.basedb.reggie.dao.BioplateType; |
1821 |
06 Feb 13 |
nicklas |
51 |
import net.sf.basedb.reggie.dao.Blood; |
3356 |
28 May 15 |
nicklas |
52 |
import net.sf.basedb.reggie.dao.BloodDna; |
1821 |
06 Feb 13 |
nicklas |
53 |
import net.sf.basedb.reggie.dao.Case; |
2050 |
07 Oct 13 |
olle |
54 |
import net.sf.basedb.reggie.dao.CDna; |
1821 |
06 Feb 13 |
nicklas |
55 |
import net.sf.basedb.reggie.dao.Consent; |
7296 |
23 Aug 23 |
nicklas |
56 |
import net.sf.basedb.reggie.dao.CopyNumber; |
5731 |
19 Nov 19 |
nicklas |
57 |
import net.sf.basedb.reggie.dao.Datafiletype; |
2098 |
23 Oct 13 |
nicklas |
58 |
import net.sf.basedb.reggie.dao.Dna; |
2232 |
17 Feb 14 |
nicklas |
59 |
import net.sf.basedb.reggie.dao.FlowCell; |
2098 |
23 Oct 13 |
nicklas |
60 |
import net.sf.basedb.reggie.dao.FlowThrough; |
6479 |
09 Nov 21 |
nicklas |
61 |
import net.sf.basedb.reggie.dao.GenotypeCall; |
1826 |
07 Feb 13 |
nicklas |
62 |
import net.sf.basedb.reggie.dao.Histology; |
2050 |
07 Oct 13 |
olle |
63 |
import net.sf.basedb.reggie.dao.Library; |
1831 |
08 Feb 13 |
nicklas |
64 |
import net.sf.basedb.reggie.dao.Lysate; |
2050 |
07 Oct 13 |
olle |
65 |
import net.sf.basedb.reggie.dao.MRna; |
2914 |
11 Nov 14 |
nicklas |
66 |
import net.sf.basedb.reggie.dao.MergedSequences; |
6882 |
22 Nov 22 |
nicklas |
67 |
import net.sf.basedb.reggie.dao.Methylation; |
1821 |
06 Feb 13 |
nicklas |
68 |
import net.sf.basedb.reggie.dao.NoSpecimen; |
1821 |
06 Feb 13 |
nicklas |
69 |
import net.sf.basedb.reggie.dao.Patient; |
7308 |
28 Aug 23 |
nicklas |
70 |
import net.sf.basedb.reggie.dao.Pipeline; |
2052 |
09 Oct 13 |
olle |
71 |
import net.sf.basedb.reggie.dao.PooledLibrary; |
2918 |
11 Nov 14 |
nicklas |
72 |
import net.sf.basedb.reggie.dao.Rawbioassay; |
5731 |
19 Nov 19 |
nicklas |
73 |
import net.sf.basedb.reggie.dao.Rawdatatype; |
4075 |
05 Sep 16 |
nicklas |
74 |
import net.sf.basedb.reggie.dao.ReggieItem; |
1832 |
08 Feb 13 |
nicklas |
75 |
import net.sf.basedb.reggie.dao.Rna; |
3188 |
18 Mar 15 |
nicklas |
76 |
import net.sf.basedb.reggie.dao.RnaQc; |
6479 |
09 Nov 21 |
nicklas |
77 |
import net.sf.basedb.reggie.dao.Scan; |
2232 |
17 Feb 14 |
nicklas |
78 |
import net.sf.basedb.reggie.dao.SequencingRun; |
1821 |
06 Feb 13 |
nicklas |
79 |
import net.sf.basedb.reggie.dao.SpecimenTube; |
1826 |
07 Feb 13 |
nicklas |
80 |
import net.sf.basedb.reggie.dao.Subtype; |
6393 |
16 Sep 21 |
nicklas |
81 |
import net.sf.basedb.reggie.grid.TargetedGenotypeJobCreator; |
6393 |
16 Sep 21 |
nicklas |
82 |
import net.sf.basedb.reggie.grid.TargetedGenotypeJobCreator.TargetedGenotypeDefinition; |
3506 |
23 Sep 15 |
nicklas |
83 |
import net.sf.basedb.reggie.pdf.GeneReportWorker; |
3534 |
08 Oct 15 |
nicklas |
84 |
import net.sf.basedb.reggie.pdf.PilotReportWorker; |
6094 |
14 Dec 20 |
nicklas |
85 |
import net.sf.basedb.reggie.pdf.ScanBReportWorker; |
2100 |
24 Oct 13 |
nicklas |
86 |
import net.sf.basedb.util.Values; |
1821 |
06 Feb 13 |
nicklas |
87 |
import net.sf.basedb.util.error.ThrowableUtil; |
1821 |
06 Feb 13 |
nicklas |
88 |
|
1821 |
06 Feb 13 |
nicklas |
89 |
|
1839 |
13 Feb 13 |
nicklas |
90 |
public class CaseSummaryServlet |
1821 |
06 Feb 13 |
nicklas |
91 |
extends HttpServlet |
1821 |
06 Feb 13 |
nicklas |
92 |
{ |
1821 |
06 Feb 13 |
nicklas |
93 |
|
1821 |
06 Feb 13 |
nicklas |
94 |
|
1821 |
06 Feb 13 |
nicklas |
95 |
private static final long serialVersionUID = 856434104316596495L; |
1821 |
06 Feb 13 |
nicklas |
96 |
|
1839 |
13 Feb 13 |
nicklas |
97 |
public CaseSummaryServlet() |
1821 |
06 Feb 13 |
nicklas |
98 |
{} |
1821 |
06 Feb 13 |
nicklas |
99 |
|
1821 |
06 Feb 13 |
nicklas |
100 |
@Override |
1821 |
06 Feb 13 |
nicklas |
101 |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) |
1821 |
06 Feb 13 |
nicklas |
102 |
throws ServletException, IOException |
1821 |
06 Feb 13 |
nicklas |
103 |
{ |
1821 |
06 Feb 13 |
nicklas |
104 |
String cmd = req.getParameter("cmd"); |
2598 |
22 Aug 14 |
nicklas |
105 |
JsonUtil.setJsonResponseHeaders(resp); |
1821 |
06 Feb 13 |
nicklas |
106 |
|
1821 |
06 Feb 13 |
nicklas |
107 |
JSONObject json = new JSONObject(); |
1821 |
06 Feb 13 |
nicklas |
108 |
json.put("status", "ok"); |
1821 |
06 Feb 13 |
nicklas |
109 |
|
3975 |
26 May 16 |
nicklas |
110 |
final SessionControl sc = Reggie.getSessionControl(req); |
1821 |
06 Feb 13 |
nicklas |
111 |
DbControl dc = null; |
1821 |
06 Feb 13 |
nicklas |
112 |
try |
1821 |
06 Feb 13 |
nicklas |
113 |
{ |
1821 |
06 Feb 13 |
nicklas |
114 |
if ("GetCaseInfo".equals(cmd)) |
1821 |
06 Feb 13 |
nicklas |
115 |
{ |
1821 |
06 Feb 13 |
nicklas |
116 |
/* |
1821 |
06 Feb 13 |
nicklas |
Load information about a single case when given the case name/barcode |
1821 |
06 Feb 13 |
nicklas |
If a case is found we will load annotations, the patient it is associated with |
1821 |
06 Feb 13 |
nicklas |
and specimen tubes for the case. |
1821 |
06 Feb 13 |
nicklas |
120 |
*/ |
6337 |
16 Jun 21 |
nicklas |
121 |
dc = sc.newDbControl(":Case summary"); |
1821 |
06 Feb 13 |
nicklas |
122 |
|
1821 |
06 Feb 13 |
nicklas |
123 |
String caseName = req.getParameter("caseName"); |
7150 |
09 May 23 |
nicklas |
124 |
if (caseName != null) caseName = caseName.strip(); |
6801 |
11 Aug 22 |
nicklas |
125 |
String matchedBy = null; |
4075 |
05 Sep 16 |
nicklas |
// Try to determine if the 'caseName' is a |
4075 |
05 Sep 16 |
nicklas |
// SCANB ID, external id or personal number |
6565 |
01 Feb 22 |
nicklas |
128 |
String scanBId = getScanBId(caseName, true, true); |
4075 |
05 Sep 16 |
nicklas |
129 |
|
2144 |
19 Nov 13 |
olle |
130 |
Patient patient = null; |
2144 |
19 Nov 13 |
olle |
131 |
Case theCase = null; |
2144 |
19 Nov 13 |
olle |
132 |
List<Case> caseList = null; |
6565 |
01 Feb 22 |
nicklas |
133 |
if (scanBId != null) |
2144 |
19 Nov 13 |
olle |
134 |
{ |
6565 |
01 Feb 22 |
nicklas |
135 |
caseName = scanBId; |
6565 |
01 Feb 22 |
nicklas |
136 |
} |
6565 |
01 Feb 22 |
nicklas |
137 |
else |
6565 |
01 Feb 22 |
nicklas |
138 |
{ |
4075 |
05 Sep 16 |
nicklas |
// Try to find a sample-level item first |
4075 |
05 Sep 16 |
nicklas |
// Eg. a Specimen/NoSpecimen/Blood/Case |
4075 |
05 Sep 16 |
nicklas |
141 |
String specimenExternalId = getSpecimenExternalId(caseName); |
4075 |
05 Sep 16 |
nicklas |
142 |
String bloodExternalId = getBloodExternalId(caseName); |
4075 |
05 Sep 16 |
nicklas |
143 |
String caseExternalId = getCaseExternalId(caseName); |
4075 |
05 Sep 16 |
nicklas |
144 |
ReggieItem<Sample> sampleItem = null; |
4075 |
05 Sep 16 |
nicklas |
145 |
if (specimenExternalId != null) |
2144 |
19 Nov 13 |
olle |
146 |
{ |
4075 |
05 Sep 16 |
nicklas |
147 |
sampleItem = SpecimenTube.findByExternalId(dc, specimenExternalId); |
4075 |
05 Sep 16 |
nicklas |
148 |
if (sampleItem == null) sampleItem = NoSpecimen.findByExternalId(dc, specimenExternalId); |
6801 |
11 Aug 22 |
nicklas |
149 |
if (sampleItem != null) matchedBy = "Specimen external id: "+specimenExternalId; |
2144 |
19 Nov 13 |
olle |
150 |
} |
4075 |
05 Sep 16 |
nicklas |
151 |
else if (bloodExternalId != null) |
2144 |
19 Nov 13 |
olle |
152 |
{ |
4075 |
05 Sep 16 |
nicklas |
153 |
sampleItem = Blood.findByExternalId(dc, bloodExternalId); |
6801 |
11 Aug 22 |
nicklas |
154 |
if (sampleItem != null) matchedBy = "Blood external id: "+bloodExternalId; |
4075 |
05 Sep 16 |
nicklas |
155 |
} |
4075 |
05 Sep 16 |
nicklas |
156 |
else if (caseExternalId != null) |
4075 |
05 Sep 16 |
nicklas |
157 |
{ |
4075 |
05 Sep 16 |
nicklas |
158 |
sampleItem = Case.findByExternalId(dc, caseExternalId); |
6801 |
11 Aug 22 |
nicklas |
159 |
if (sampleItem != null) matchedBy = "Case external id: "+caseExternalId; |
4075 |
05 Sep 16 |
nicklas |
160 |
} |
4075 |
05 Sep 16 |
nicklas |
161 |
|
4964 |
03 Sep 18 |
nicklas |
162 |
if (sampleItem == null) |
4964 |
03 Sep 18 |
nicklas |
163 |
{ |
4964 |
03 Sep 18 |
nicklas |
// Try PAD (if logged in user has permission to access it) |
4964 |
03 Sep 18 |
nicklas |
165 |
try |
4964 |
03 Sep 18 |
nicklas |
166 |
{ |
7154 |
09 May 23 |
nicklas |
// In some cases, PAD from CMD have suffix with '-' as a |
7154 |
09 May 23 |
nicklas |
// separator from the "real" PAD, we remove the suffix before searching |
7154 |
09 May 23 |
nicklas |
169 |
int sep = caseName.indexOf('-'); |
7154 |
09 May 23 |
nicklas |
170 |
if (sep > 0) caseName = caseName.substring(0, sep); |
4964 |
03 Sep 18 |
nicklas |
171 |
List<SpecimenTube> tmp = SpecimenTube.findByPAD(dc, caseName); |
4964 |
03 Sep 18 |
nicklas |
172 |
if (tmp != null && tmp.size() > 0) sampleItem = tmp.get(0); |
4964 |
03 Sep 18 |
nicklas |
173 |
if (sampleItem == null) |
4964 |
03 Sep 18 |
nicklas |
174 |
{ |
4964 |
03 Sep 18 |
nicklas |
175 |
List<NoSpecimen> tmp2 = NoSpecimen.findByPAD(dc, caseName); |
4964 |
03 Sep 18 |
nicklas |
176 |
if (tmp2 != null && tmp2.size() > 0) sampleItem = tmp2.get(0); |
4964 |
03 Sep 18 |
nicklas |
177 |
} |
6801 |
11 Aug 22 |
nicklas |
178 |
if (sampleItem != null) matchedBy = "PAD"; |
4964 |
03 Sep 18 |
nicklas |
179 |
} |
4964 |
03 Sep 18 |
nicklas |
180 |
catch (PermissionDeniedException | ItemNotFoundException ex) |
4964 |
03 Sep 18 |
nicklas |
181 |
{} |
4964 |
03 Sep 18 |
nicklas |
182 |
} |
4964 |
03 Sep 18 |
nicklas |
183 |
|
4964 |
03 Sep 18 |
nicklas |
184 |
if (sampleItem == null) |
4964 |
03 Sep 18 |
nicklas |
185 |
{ |
7150 |
09 May 23 |
nicklas |
// Try ExternalRef on Specimen items |
7150 |
09 May 23 |
nicklas |
187 |
List<SpecimenTube> tmp = SpecimenTube.findByExternalRef(dc, caseName); |
7150 |
09 May 23 |
nicklas |
188 |
if (tmp != null && tmp.size() > 0) sampleItem = tmp.get(0); |
7150 |
09 May 23 |
nicklas |
189 |
if (sampleItem != null) matchedBy = "ExternalRef: "+caseName; |
7150 |
09 May 23 |
nicklas |
190 |
} |
7150 |
09 May 23 |
nicklas |
191 |
|
7150 |
09 May 23 |
nicklas |
192 |
if (sampleItem == null) |
7150 |
09 May 23 |
nicklas |
193 |
{ |
4964 |
03 Sep 18 |
nicklas |
// Try RCCID on blood items |
4964 |
03 Sep 18 |
nicklas |
195 |
List<Blood> tmp = Blood.findAllByBaseRccidNumber(dc, caseName); |
4964 |
03 Sep 18 |
nicklas |
196 |
if (tmp != null && tmp.size() > 0) sampleItem = tmp.get(0); |
6801 |
11 Aug 22 |
nicklas |
197 |
if (sampleItem != null) matchedBy = "RCC-ID: "+caseName; |
4964 |
03 Sep 18 |
nicklas |
198 |
} |
4964 |
03 Sep 18 |
nicklas |
199 |
|
6835 |
05 Sep 22 |
nicklas |
200 |
if (sampleItem == null) |
6835 |
05 Sep 22 |
nicklas |
201 |
{ |
6835 |
05 Sep 22 |
nicklas |
// Try BD47_ID on blood items |
6835 |
05 Sep 22 |
nicklas |
203 |
List<Blood> tmp = Blood.findAllByBD47Id(dc, caseName); |
6835 |
05 Sep 22 |
nicklas |
204 |
if (tmp != null && tmp.size() > 0) sampleItem = tmp.get(0); |
6835 |
05 Sep 22 |
nicklas |
205 |
if (sampleItem != null) matchedBy = "BD47-ID: "+caseName; |
6835 |
05 Sep 22 |
nicklas |
206 |
} |
6835 |
05 Sep 22 |
nicklas |
207 |
|
4075 |
05 Sep 16 |
nicklas |
208 |
if (sampleItem != null) |
4075 |
05 Sep 16 |
nicklas |
209 |
{ |
4075 |
05 Sep 16 |
nicklas |
// If an item is found we have an exact match for case name |
4075 |
05 Sep 16 |
nicklas |
// and use that from now on just as if that was entered in |
4075 |
05 Sep 16 |
nicklas |
// the search form |
6835 |
05 Sep 22 |
nicklas |
213 |
caseName = sampleItem.getName().substring(0, 7); |
4075 |
05 Sep 16 |
nicklas |
214 |
} |
4075 |
05 Sep 16 |
nicklas |
215 |
else |
4075 |
05 Sep 16 |
nicklas |
216 |
{ |
4075 |
05 Sep 16 |
nicklas |
217 |
String patientExternalId = getPatientExternalId(caseName); |
5278 |
05 Feb 19 |
nicklas |
218 |
String patientName = getPatientName(caseName); |
5278 |
05 Feb 19 |
nicklas |
219 |
if (patientName != null) |
2144 |
19 Nov 13 |
olle |
220 |
{ |
5278 |
05 Feb 19 |
nicklas |
221 |
patient = Patient.findByName(dc, patientName); |
6801 |
11 Aug 22 |
nicklas |
222 |
if (patient != null) matchedBy = "Patient name: " + patientName; |
5278 |
05 Feb 19 |
nicklas |
223 |
} |
5278 |
05 Feb 19 |
nicklas |
224 |
else if (patientExternalId != null) |
5278 |
05 Feb 19 |
nicklas |
225 |
{ |
4075 |
05 Sep 16 |
nicklas |
226 |
patient = Patient.findByExternalId(dc, patientExternalId); |
6835 |
05 Sep 22 |
nicklas |
227 |
if (patient != null) matchedBy = "Patient external id: " + patientExternalId; |
2144 |
19 Nov 13 |
olle |
228 |
} |
4075 |
05 Sep 16 |
nicklas |
229 |
else |
2144 |
19 Nov 13 |
olle |
230 |
{ |
4075 |
05 Sep 16 |
nicklas |
// Input 'caseName' may be personal number |
4075 |
05 Sep 16 |
nicklas |
232 |
String potentialPnr = caseName; |
4075 |
05 Sep 16 |
nicklas |
// Find cases by personal number if user has permission to do so |
4075 |
05 Sep 16 |
nicklas |
234 |
try |
4075 |
05 Sep 16 |
nicklas |
235 |
{ |
4075 |
05 Sep 16 |
nicklas |
236 |
patient = Patient.findByPersonalNumber(dc, potentialPnr); |
6801 |
11 Aug 22 |
nicklas |
237 |
if (patient != null) matchedBy = "Personal number"; |
4075 |
05 Sep 16 |
nicklas |
238 |
} |
4075 |
05 Sep 16 |
nicklas |
239 |
catch (PermissionDeniedException | ItemNotFoundException ex) |
4075 |
05 Sep 16 |
nicklas |
240 |
{} |
2144 |
19 Nov 13 |
olle |
241 |
} |
4075 |
05 Sep 16 |
nicklas |
242 |
if (patient != null) |
4075 |
05 Sep 16 |
nicklas |
243 |
{ |
4075 |
05 Sep 16 |
nicklas |
244 |
caseList = Case.findByPatient(dc, patient); |
4075 |
05 Sep 16 |
nicklas |
245 |
if (caseList != null && caseList.size() > 0) |
4075 |
05 Sep 16 |
nicklas |
246 |
{ |
4075 |
05 Sep 16 |
nicklas |
// Use lowest case name (a patient can have at most 2 cases) |
5415 |
09 May 19 |
nicklas |
248 |
theCase = caseList.get(0); |
4075 |
05 Sep 16 |
nicklas |
249 |
} |
4075 |
05 Sep 16 |
nicklas |
250 |
if (theCase != null) |
4075 |
05 Sep 16 |
nicklas |
251 |
{ |
4075 |
05 Sep 16 |
nicklas |
// Use case name found from personal number |
4075 |
05 Sep 16 |
nicklas |
253 |
caseName = theCase.getName(); |
4075 |
05 Sep 16 |
nicklas |
254 |
} |
4075 |
05 Sep 16 |
nicklas |
255 |
} |
2144 |
19 Nov 13 |
olle |
256 |
} |
2144 |
19 Nov 13 |
olle |
257 |
} |
2144 |
19 Nov 13 |
olle |
258 |
|
2100 |
24 Oct 13 |
nicklas |
259 |
JSONArray jsonSections = new JSONArray(); |
2100 |
24 Oct 13 |
nicklas |
260 |
json.put("sections", jsonSections); |
1821 |
06 Feb 13 |
nicklas |
261 |
|
1821 |
06 Feb 13 |
nicklas |
// Load site information |
1821 |
06 Feb 13 |
nicklas |
263 |
Site site = Site.findByCaseName(caseName); |
1821 |
06 Feb 13 |
nicklas |
264 |
if (site != null) |
1821 |
06 Feb 13 |
nicklas |
265 |
{ |
1821 |
06 Feb 13 |
nicklas |
266 |
json.put("site", site.asJSONObject()); |
1821 |
06 Feb 13 |
nicklas |
267 |
} |
1821 |
06 Feb 13 |
nicklas |
268 |
|
6835 |
05 Sep 22 |
nicklas |
269 |
if (matchedBy != null) json.put("matchedBy", matchedBy); |
6835 |
05 Sep 22 |
nicklas |
270 |
if (caseName != null) json.put("caseName", caseName); |
6835 |
05 Sep 22 |
nicklas |
271 |
|
1821 |
06 Feb 13 |
nicklas |
// Load case (null if not found) and patient |
2144 |
19 Nov 13 |
olle |
273 |
if (theCase == null) |
2144 |
19 Nov 13 |
olle |
274 |
{ |
2144 |
19 Nov 13 |
olle |
275 |
theCase = Case.findByName(dc, caseName); |
2144 |
19 Nov 13 |
olle |
276 |
} |
1821 |
06 Feb 13 |
nicklas |
277 |
if (theCase != null) |
1821 |
06 Feb 13 |
nicklas |
278 |
{ |
1821 |
06 Feb 13 |
nicklas |
279 |
loadCaseInfo(dc, theCase); |
2100 |
24 Oct 13 |
nicklas |
280 |
jsonSections.add(loadSectionInfo(sc, "case")); |
1821 |
06 Feb 13 |
nicklas |
281 |
json.put("caseInfo", theCase.asJSONObject()); |
2144 |
19 Nov 13 |
olle |
282 |
if (patient == null) |
2144 |
19 Nov 13 |
olle |
283 |
{ |
2144 |
19 Nov 13 |
olle |
284 |
patient = Patient.findByCase(dc, theCase); |
2144 |
19 Nov 13 |
olle |
285 |
} |
1821 |
06 Feb 13 |
nicklas |
286 |
} |
1821 |
06 Feb 13 |
nicklas |
287 |
|
1821 |
06 Feb 13 |
nicklas |
// Load blood (and patient if no case was found) |
1821 |
06 Feb 13 |
nicklas |
289 |
List<Blood> blood = null; |
1907 |
18 Mar 13 |
nicklas |
290 |
if (patient == null) |
1907 |
18 Mar 13 |
nicklas |
291 |
{ |
1907 |
18 Mar 13 |
nicklas |
292 |
blood = Blood.findAllByCaseName(dc, caseName); |
1907 |
18 Mar 13 |
nicklas |
293 |
if (blood.size() > 0) patient = Patient.findByBlood(dc, blood.get(0)); |
1907 |
18 Mar 13 |
nicklas |
294 |
} |
1821 |
06 Feb 13 |
nicklas |
295 |
if (patient != null) |
1821 |
06 Feb 13 |
nicklas |
296 |
{ |
1821 |
06 Feb 13 |
nicklas |
297 |
blood = Blood.findByPatient(dc, patient); |
1821 |
06 Feb 13 |
nicklas |
298 |
} |
1821 |
06 Feb 13 |
nicklas |
299 |
|
1821 |
06 Feb 13 |
nicklas |
300 |
if (blood.size() > 0) |
1821 |
06 Feb 13 |
nicklas |
301 |
{ |
1821 |
06 Feb 13 |
nicklas |
302 |
JSONArray jsonBlood = new JSONArray(); |
1821 |
06 Feb 13 |
nicklas |
303 |
for (Blood b: blood) |
1821 |
06 Feb 13 |
nicklas |
304 |
{ |
1821 |
06 Feb 13 |
nicklas |
305 |
loadBloodInfo(dc, b); |
1821 |
06 Feb 13 |
nicklas |
306 |
jsonBlood.add(b.asJSONObject()); |
1821 |
06 Feb 13 |
nicklas |
307 |
} |
2100 |
24 Oct 13 |
nicklas |
308 |
jsonSections.add(loadSectionInfo(sc, "blood")); |
1821 |
06 Feb 13 |
nicklas |
309 |
json.put("blood", jsonBlood); |
1821 |
06 Feb 13 |
nicklas |
310 |
} |
1821 |
06 Feb 13 |
nicklas |
311 |
|
1821 |
06 Feb 13 |
nicklas |
312 |
if (patient != null) |
1821 |
06 Feb 13 |
nicklas |
313 |
{ |
1821 |
06 Feb 13 |
nicklas |
314 |
loadPatientInfo(dc, patient); |
2592 |
19 Aug 14 |
nicklas |
315 |
List<String> allCases = Case.findAllCaseNumbersByPatient(dc, patient); |
1907 |
18 Mar 13 |
nicklas |
316 |
patient.setAnnotation("allCases", allCases); |
2100 |
24 Oct 13 |
nicklas |
317 |
jsonSections.add(loadSectionInfo(sc, "patient")); |
1821 |
06 Feb 13 |
nicklas |
318 |
json.put("patient", patient.asJSONObject()); |
1821 |
06 Feb 13 |
nicklas |
319 |
} |
1821 |
06 Feb 13 |
nicklas |
320 |
|
1821 |
06 Feb 13 |
nicklas |
// Load specimen tubes |
1821 |
06 Feb 13 |
nicklas |
322 |
List<SpecimenTube> specimen = SpecimenTube.findByCaseName(dc, caseName, false); |
1821 |
06 Feb 13 |
nicklas |
323 |
if (specimen.size() > 0) |
1821 |
06 Feb 13 |
nicklas |
324 |
{ |
1821 |
06 Feb 13 |
nicklas |
325 |
JSONArray jsonSpecimen = new JSONArray(); |
1821 |
06 Feb 13 |
nicklas |
326 |
for (SpecimenTube s : specimen) |
1821 |
06 Feb 13 |
nicklas |
327 |
{ |
1821 |
06 Feb 13 |
nicklas |
328 |
loadSpecimenInfo(dc, s); |
1821 |
06 Feb 13 |
nicklas |
329 |
jsonSpecimen.add(s.asJSONObject()); |
1821 |
06 Feb 13 |
nicklas |
330 |
} |
2100 |
24 Oct 13 |
nicklas |
331 |
jsonSections.add(loadSectionInfo(sc, "specimen")); |
1821 |
06 Feb 13 |
nicklas |
332 |
json.put("specimen", jsonSpecimen); |
1821 |
06 Feb 13 |
nicklas |
333 |
} |
1821 |
06 Feb 13 |
nicklas |
334 |
|
1821 |
06 Feb 13 |
nicklas |
335 |
List<NoSpecimen> noSpecimen = NoSpecimen.findByCaseName(dc, caseName, false); |
1821 |
06 Feb 13 |
nicklas |
336 |
if (noSpecimen.size() > 0) |
1821 |
06 Feb 13 |
nicklas |
337 |
{ |
1821 |
06 Feb 13 |
nicklas |
338 |
JSONArray jsonNoSpecimen = new JSONArray(); |
1821 |
06 Feb 13 |
nicklas |
339 |
for (NoSpecimen ns : noSpecimen) |
1821 |
06 Feb 13 |
nicklas |
340 |
{ |
1821 |
06 Feb 13 |
nicklas |
341 |
loadNoSpecimenInfo(dc, ns); |
1821 |
06 Feb 13 |
nicklas |
342 |
jsonNoSpecimen.add(ns.asJSONObject()); |
1821 |
06 Feb 13 |
nicklas |
343 |
} |
2100 |
24 Oct 13 |
nicklas |
344 |
jsonSections.add(loadSectionInfo(sc, "nospecimen")); |
1821 |
06 Feb 13 |
nicklas |
345 |
json.put("noSpecimen", jsonNoSpecimen); |
1821 |
06 Feb 13 |
nicklas |
346 |
} |
1821 |
06 Feb 13 |
nicklas |
347 |
|
1826 |
07 Feb 13 |
nicklas |
348 |
List<Histology> histology = Histology.findByCaseName(dc, caseName); |
1826 |
07 Feb 13 |
nicklas |
349 |
if (histology.size() > 0) |
1826 |
07 Feb 13 |
nicklas |
350 |
{ |
1826 |
07 Feb 13 |
nicklas |
351 |
JSONArray jsonHistology = new JSONArray(); |
1826 |
07 Feb 13 |
nicklas |
352 |
for (Histology his : histology) |
1826 |
07 Feb 13 |
nicklas |
353 |
{ |
1826 |
07 Feb 13 |
nicklas |
354 |
loadHistologyInfo(dc, his); |
1826 |
07 Feb 13 |
nicklas |
355 |
jsonHistology.add(his.asJSONObject()); |
1826 |
07 Feb 13 |
nicklas |
356 |
} |
2100 |
24 Oct 13 |
nicklas |
357 |
jsonSections.add(loadSectionInfo(sc, "histology")); |
1826 |
07 Feb 13 |
nicklas |
358 |
json.put("histology", jsonHistology); |
1826 |
07 Feb 13 |
nicklas |
359 |
} |
1831 |
08 Feb 13 |
nicklas |
360 |
|
6479 |
09 Nov 21 |
nicklas |
361 |
List<GenotypeCall> genotypeCalls = GenotypeCall.findByCaseName(dc, caseName); |
6479 |
09 Nov 21 |
nicklas |
362 |
if (genotypeCalls.size() > 0) |
6479 |
09 Nov 21 |
nicklas |
363 |
{ |
6479 |
09 Nov 21 |
nicklas |
364 |
JSONArray jsonGtc = new JSONArray(); |
6479 |
09 Nov 21 |
nicklas |
365 |
for (GenotypeCall gtc : genotypeCalls) |
6479 |
09 Nov 21 |
nicklas |
366 |
{ |
6479 |
09 Nov 21 |
nicklas |
367 |
loadGenotypeCallInfo(dc, gtc); |
6479 |
09 Nov 21 |
nicklas |
368 |
jsonGtc.add(gtc.asJSONObject()); |
6479 |
09 Nov 21 |
nicklas |
369 |
} |
6479 |
09 Nov 21 |
nicklas |
370 |
jsonSections.add(loadSectionInfo(sc, "genotypecall")); |
6479 |
09 Nov 21 |
nicklas |
371 |
json.put("genotypecall", jsonGtc); |
6479 |
09 Nov 21 |
nicklas |
372 |
} |
6479 |
09 Nov 21 |
nicklas |
373 |
|
6882 |
22 Nov 22 |
nicklas |
374 |
List<Methylation> methylation = Methylation.findByCaseName(dc, caseName); |
6882 |
22 Nov 22 |
nicklas |
375 |
if (methylation.size() > 0) |
6882 |
22 Nov 22 |
nicklas |
376 |
{ |
6882 |
22 Nov 22 |
nicklas |
377 |
JSONArray jsonMeth = new JSONArray(); |
6882 |
22 Nov 22 |
nicklas |
378 |
for (Methylation m : methylation) |
6882 |
22 Nov 22 |
nicklas |
379 |
{ |
6882 |
22 Nov 22 |
nicklas |
380 |
loadMethylationInfo(dc, m); |
6882 |
22 Nov 22 |
nicklas |
381 |
jsonMeth.add(m.asJSONObject()); |
6882 |
22 Nov 22 |
nicklas |
382 |
} |
6882 |
22 Nov 22 |
nicklas |
383 |
jsonSections.add(loadSectionInfo(sc, "methylation")); |
6882 |
22 Nov 22 |
nicklas |
384 |
json.put("methylation", jsonMeth); |
6882 |
22 Nov 22 |
nicklas |
385 |
} |
6882 |
22 Nov 22 |
nicklas |
386 |
|
1831 |
08 Feb 13 |
nicklas |
387 |
List<Lysate> lysate = Lysate.findByCaseName(dc, caseName); |
1831 |
08 Feb 13 |
nicklas |
388 |
if (lysate.size() > 0) |
1831 |
08 Feb 13 |
nicklas |
389 |
{ |
1831 |
08 Feb 13 |
nicklas |
390 |
JSONArray jsonLysate = new JSONArray(); |
1831 |
08 Feb 13 |
nicklas |
391 |
for (Lysate lys : lysate) |
1831 |
08 Feb 13 |
nicklas |
392 |
{ |
1831 |
08 Feb 13 |
nicklas |
393 |
loadLysateInfo(dc, lys); |
1831 |
08 Feb 13 |
nicklas |
394 |
jsonLysate.add(lys.asJSONObject()); |
1831 |
08 Feb 13 |
nicklas |
395 |
} |
2100 |
24 Oct 13 |
nicklas |
396 |
jsonSections.add(loadSectionInfo(sc, "lysate")); |
1831 |
08 Feb 13 |
nicklas |
397 |
json.put("lysate", jsonLysate); |
1831 |
08 Feb 13 |
nicklas |
398 |
} |
1832 |
08 Feb 13 |
nicklas |
399 |
|
1832 |
08 Feb 13 |
nicklas |
400 |
List<Rna> rna = Rna.findByCaseName(dc, caseName); |
1832 |
08 Feb 13 |
nicklas |
401 |
if (rna.size() > 0) |
1832 |
08 Feb 13 |
nicklas |
402 |
{ |
1832 |
08 Feb 13 |
nicklas |
403 |
JSONArray jsonRna = new JSONArray(); |
1832 |
08 Feb 13 |
nicklas |
404 |
for (Rna r : rna) |
1832 |
08 Feb 13 |
nicklas |
405 |
{ |
1832 |
08 Feb 13 |
nicklas |
406 |
loadRnaInfo(dc, r); |
1832 |
08 Feb 13 |
nicklas |
407 |
jsonRna.add(r.asJSONObject()); |
1832 |
08 Feb 13 |
nicklas |
408 |
} |
2100 |
24 Oct 13 |
nicklas |
409 |
jsonSections.add(loadSectionInfo(sc, "rna")); |
1832 |
08 Feb 13 |
nicklas |
410 |
json.put("rna", jsonRna); |
1832 |
08 Feb 13 |
nicklas |
411 |
} |
2050 |
07 Oct 13 |
olle |
412 |
|
2098 |
23 Oct 13 |
nicklas |
413 |
List<Dna> dna = Dna.findByCaseName(dc, caseName); |
2098 |
23 Oct 13 |
nicklas |
414 |
if (dna.size() > 0) |
2098 |
23 Oct 13 |
nicklas |
415 |
{ |
2098 |
23 Oct 13 |
nicklas |
416 |
JSONArray jsonDna = new JSONArray(); |
2098 |
23 Oct 13 |
nicklas |
417 |
for (Dna d : dna) |
2098 |
23 Oct 13 |
nicklas |
418 |
{ |
2098 |
23 Oct 13 |
nicklas |
419 |
loadDnaInfo(dc, d); |
2098 |
23 Oct 13 |
nicklas |
420 |
jsonDna.add(d.asJSONObject()); |
2098 |
23 Oct 13 |
nicklas |
421 |
} |
2100 |
24 Oct 13 |
nicklas |
422 |
jsonSections.add(loadSectionInfo(sc, "dna")); |
2098 |
23 Oct 13 |
nicklas |
423 |
json.put("dna", jsonDna); |
2098 |
23 Oct 13 |
nicklas |
424 |
} |
2098 |
23 Oct 13 |
nicklas |
425 |
|
3356 |
28 May 15 |
nicklas |
426 |
List<BloodDna> bdna = BloodDna.findByCaseName(dc, caseName); |
3356 |
28 May 15 |
nicklas |
427 |
if (bdna.size() > 0) |
3356 |
28 May 15 |
nicklas |
428 |
{ |
3356 |
28 May 15 |
nicklas |
429 |
JSONArray jsonBloodDna = new JSONArray(); |
3356 |
28 May 15 |
nicklas |
430 |
for (BloodDna d : bdna) |
3356 |
28 May 15 |
nicklas |
431 |
{ |
3356 |
28 May 15 |
nicklas |
432 |
loadBloodDnaInfo(dc, d); |
3356 |
28 May 15 |
nicklas |
433 |
jsonBloodDna.add(d.asJSONObject()); |
3356 |
28 May 15 |
nicklas |
434 |
} |
3356 |
28 May 15 |
nicklas |
435 |
jsonSections.add(loadSectionInfo(sc, "bdna")); |
3356 |
28 May 15 |
nicklas |
436 |
json.put("bdna", jsonBloodDna); |
3356 |
28 May 15 |
nicklas |
437 |
} |
3356 |
28 May 15 |
nicklas |
438 |
|
2098 |
23 Oct 13 |
nicklas |
439 |
List<FlowThrough> ft = FlowThrough.findByCaseName(dc, caseName); |
2098 |
23 Oct 13 |
nicklas |
440 |
if (ft.size() > 0) |
2098 |
23 Oct 13 |
nicklas |
441 |
{ |
2098 |
23 Oct 13 |
nicklas |
442 |
JSONArray jsonFlowThrough = new JSONArray(); |
2098 |
23 Oct 13 |
nicklas |
443 |
for (FlowThrough f : ft) |
2098 |
23 Oct 13 |
nicklas |
444 |
{ |
2098 |
23 Oct 13 |
nicklas |
445 |
loadFlowThroughInfo(dc, f); |
2098 |
23 Oct 13 |
nicklas |
446 |
jsonFlowThrough.add(f.asJSONObject()); |
2098 |
23 Oct 13 |
nicklas |
447 |
} |
2100 |
24 Oct 13 |
nicklas |
448 |
jsonSections.add(loadSectionInfo(sc, "ft")); |
2098 |
23 Oct 13 |
nicklas |
449 |
json.put("flowThrough", jsonFlowThrough); |
2098 |
23 Oct 13 |
nicklas |
450 |
} |
2098 |
23 Oct 13 |
nicklas |
451 |
|
2050 |
07 Oct 13 |
olle |
452 |
List<MRna> mrna = MRna.findByCaseName(dc, caseName); |
2050 |
07 Oct 13 |
olle |
453 |
if (mrna.size() > 0) |
2050 |
07 Oct 13 |
olle |
454 |
{ |
2050 |
07 Oct 13 |
olle |
455 |
JSONArray jsonMRna = new JSONArray(); |
2050 |
07 Oct 13 |
olle |
456 |
for (MRna r : mrna) |
2050 |
07 Oct 13 |
olle |
457 |
{ |
2050 |
07 Oct 13 |
olle |
458 |
loadMRnaInfo(dc, r); |
2050 |
07 Oct 13 |
olle |
459 |
jsonMRna.add(r.asJSONObject()); |
2050 |
07 Oct 13 |
olle |
460 |
} |
2100 |
24 Oct 13 |
nicklas |
461 |
jsonSections.add(loadSectionInfo(sc, "mrna")); |
2050 |
07 Oct 13 |
olle |
462 |
json.put("mrna", jsonMRna); |
2050 |
07 Oct 13 |
olle |
463 |
} |
1831 |
08 Feb 13 |
nicklas |
464 |
|
2050 |
07 Oct 13 |
olle |
465 |
List<CDna> cdna = CDna.findByCaseName(dc, caseName); |
2050 |
07 Oct 13 |
olle |
466 |
if (cdna.size() > 0) |
2050 |
07 Oct 13 |
olle |
467 |
{ |
2050 |
07 Oct 13 |
olle |
468 |
JSONArray jsonCDna = new JSONArray(); |
2050 |
07 Oct 13 |
olle |
469 |
for (CDna r : cdna) |
2050 |
07 Oct 13 |
olle |
470 |
{ |
2050 |
07 Oct 13 |
olle |
471 |
loadCDnaInfo(dc, r); |
2050 |
07 Oct 13 |
olle |
472 |
jsonCDna.add(r.asJSONObject()); |
2050 |
07 Oct 13 |
olle |
473 |
} |
2100 |
24 Oct 13 |
nicklas |
474 |
jsonSections.add(loadSectionInfo(sc, "cdna")); |
2050 |
07 Oct 13 |
olle |
475 |
json.put("cdna", jsonCDna); |
2050 |
07 Oct 13 |
olle |
476 |
} |
2050 |
07 Oct 13 |
olle |
477 |
|
2050 |
07 Oct 13 |
olle |
478 |
List<Library> lib = Library.findByCaseName(dc, caseName); |
2050 |
07 Oct 13 |
olle |
479 |
if (lib.size() > 0) |
2050 |
07 Oct 13 |
olle |
480 |
{ |
2050 |
07 Oct 13 |
olle |
481 |
JSONArray jsonLib = new JSONArray(); |
2050 |
07 Oct 13 |
olle |
482 |
for (Library r : lib) |
2050 |
07 Oct 13 |
olle |
483 |
{ |
2185 |
09 Jan 14 |
nicklas |
// Ignore *.dil items with '0' remaining quantity |
4886 |
04 Jul 18 |
nicklas |
485 |
if (r.getName().indexOf(".dil") == -1 || r.getExtract().getRemainingQuantity() > 0) |
2185 |
09 Jan 14 |
nicklas |
486 |
{ |
2185 |
09 Jan 14 |
nicklas |
487 |
loadLibraryInfo(dc, r); |
2185 |
09 Jan 14 |
nicklas |
488 |
jsonLib.add(r.asJSONObject()); |
2185 |
09 Jan 14 |
nicklas |
489 |
} |
2050 |
07 Oct 13 |
olle |
490 |
} |
2100 |
24 Oct 13 |
nicklas |
491 |
jsonSections.add(loadSectionInfo(sc, "lib")); |
2050 |
07 Oct 13 |
olle |
492 |
json.put("lib", jsonLib); |
2050 |
07 Oct 13 |
olle |
493 |
} |
2052 |
09 Oct 13 |
olle |
494 |
|
2052 |
09 Oct 13 |
olle |
495 |
List<PooledLibrary> pooledLib = PooledLibrary.findByCaseName(dc, caseName); |
2052 |
09 Oct 13 |
olle |
496 |
if (pooledLib.size() > 0) |
2052 |
09 Oct 13 |
olle |
497 |
{ |
2052 |
09 Oct 13 |
olle |
498 |
JSONArray jsonPooledLib = new JSONArray(); |
2052 |
09 Oct 13 |
olle |
499 |
for (PooledLibrary r : pooledLib) |
2052 |
09 Oct 13 |
olle |
500 |
{ |
5012 |
05 Oct 18 |
nicklas |
501 |
loadPooledLibraryInfo(dc, r, caseName); |
2052 |
09 Oct 13 |
olle |
502 |
jsonPooledLib.add(r.asJSONObject()); |
2052 |
09 Oct 13 |
olle |
503 |
} |
2100 |
24 Oct 13 |
nicklas |
504 |
jsonSections.add(loadSectionInfo(sc, "pooledlib")); |
2052 |
09 Oct 13 |
olle |
505 |
json.put("pooledlib", jsonPooledLib); |
2052 |
09 Oct 13 |
olle |
506 |
} |
2232 |
17 Feb 14 |
nicklas |
507 |
|
2232 |
17 Feb 14 |
nicklas |
508 |
List<SequencingRun> sequencingRuns = SequencingRun.findByCaseName(dc, caseName); |
2232 |
17 Feb 14 |
nicklas |
509 |
if (sequencingRuns.size() > 0) |
2232 |
17 Feb 14 |
nicklas |
510 |
{ |
2232 |
17 Feb 14 |
nicklas |
511 |
JSONArray jsonSequencingRun = new JSONArray(); |
2232 |
17 Feb 14 |
nicklas |
512 |
for (SequencingRun sr : sequencingRuns) |
2232 |
17 Feb 14 |
nicklas |
513 |
{ |
5012 |
05 Oct 18 |
nicklas |
514 |
loadSequencingRunInfo(dc, sr, caseName); |
2232 |
17 Feb 14 |
nicklas |
515 |
jsonSequencingRun.add(sr.asJSONObject()); |
2232 |
17 Feb 14 |
nicklas |
516 |
} |
2232 |
17 Feb 14 |
nicklas |
517 |
jsonSections.add(loadSectionInfo(sc, "sequencingRun")); |
2232 |
17 Feb 14 |
nicklas |
518 |
json.put("sequencingRun", jsonSequencingRun); |
2232 |
17 Feb 14 |
nicklas |
519 |
} |
2232 |
17 Feb 14 |
nicklas |
520 |
|
2914 |
11 Nov 14 |
nicklas |
521 |
List<MergedSequences> merged = MergedSequences.findByCaseName(dc, caseName); |
2914 |
11 Nov 14 |
nicklas |
522 |
if (merged.size() > 0) |
2914 |
11 Nov 14 |
nicklas |
523 |
{ |
7308 |
28 Aug 23 |
nicklas |
524 |
JSONArray jsonMergedRNA = new JSONArray(); |
7308 |
28 Aug 23 |
nicklas |
525 |
JSONArray jsonMergedDNA = new JSONArray(); |
2914 |
11 Nov 14 |
nicklas |
526 |
for (MergedSequences m : merged) |
2914 |
11 Nov 14 |
nicklas |
527 |
{ |
7308 |
28 Aug 23 |
nicklas |
528 |
|
7308 |
28 Aug 23 |
nicklas |
529 |
Pipeline p = loadMergedInfo(dc, m); |
7308 |
28 Aug 23 |
nicklas |
530 |
if (p == null || p.isRnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
531 |
{ |
7308 |
28 Aug 23 |
nicklas |
532 |
jsonMergedRNA.add(m.asJSONObject()); |
7308 |
28 Aug 23 |
nicklas |
533 |
} |
7308 |
28 Aug 23 |
nicklas |
534 |
else if (p.isDnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
535 |
{ |
7308 |
28 Aug 23 |
nicklas |
536 |
jsonMergedDNA.add(m.asJSONObject()); |
7308 |
28 Aug 23 |
nicklas |
537 |
} |
2914 |
11 Nov 14 |
nicklas |
538 |
} |
7308 |
28 Aug 23 |
nicklas |
539 |
jsonSections.add(loadSectionInfo(sc, "mergedSequencesRNA")); |
7308 |
28 Aug 23 |
nicklas |
540 |
jsonSections.add(loadSectionInfo(sc, "mergedSequencesDNA")); |
7308 |
28 Aug 23 |
nicklas |
541 |
json.put("mergedSequencesRNA", jsonMergedRNA); |
7308 |
28 Aug 23 |
nicklas |
542 |
json.put("mergedSequencesDNA", jsonMergedDNA); |
2914 |
11 Nov 14 |
nicklas |
543 |
} |
2914 |
11 Nov 14 |
nicklas |
544 |
|
2914 |
11 Nov 14 |
nicklas |
545 |
List<AlignedSequences> aligned = AlignedSequences.findByCaseName(dc, caseName); |
2914 |
11 Nov 14 |
nicklas |
546 |
if (aligned.size() > 0) |
2914 |
11 Nov 14 |
nicklas |
547 |
{ |
7308 |
28 Aug 23 |
nicklas |
548 |
JSONArray jsonAlignedRNA = new JSONArray(); |
7308 |
28 Aug 23 |
nicklas |
549 |
JSONArray jsonAlignedDNA = new JSONArray(); |
2914 |
11 Nov 14 |
nicklas |
550 |
for (AlignedSequences a : aligned) |
2914 |
11 Nov 14 |
nicklas |
551 |
{ |
7308 |
28 Aug 23 |
nicklas |
552 |
Pipeline p = loadAlignedInfo(dc, a); |
7308 |
28 Aug 23 |
nicklas |
553 |
if (p == null || p.isRnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
554 |
{ |
7308 |
28 Aug 23 |
nicklas |
555 |
jsonAlignedRNA.add(a.asJSONObject()); |
7308 |
28 Aug 23 |
nicklas |
556 |
} |
7308 |
28 Aug 23 |
nicklas |
557 |
else |
7308 |
28 Aug 23 |
nicklas |
558 |
{ |
7308 |
28 Aug 23 |
nicklas |
559 |
jsonAlignedDNA.add(a.asJSONObject()); |
7308 |
28 Aug 23 |
nicklas |
560 |
} |
2914 |
11 Nov 14 |
nicklas |
561 |
} |
7308 |
28 Aug 23 |
nicklas |
562 |
jsonSections.add(loadSectionInfo(sc, "alignedSequencesRNA")); |
7308 |
28 Aug 23 |
nicklas |
563 |
jsonSections.add(loadSectionInfo(sc, "alignedSequencesDNA")); |
7308 |
28 Aug 23 |
nicklas |
564 |
json.put("alignedSequencesRNA", jsonAlignedRNA); |
7308 |
28 Aug 23 |
nicklas |
565 |
json.put("alignedSequencesDNA", jsonAlignedDNA); |
2914 |
11 Nov 14 |
nicklas |
566 |
} |
2914 |
11 Nov 14 |
nicklas |
567 |
|
7296 |
23 Aug 23 |
nicklas |
568 |
List<CopyNumber> copyNumber = CopyNumber.findByCaseName(dc, caseName); |
7296 |
23 Aug 23 |
nicklas |
569 |
if (copyNumber.size() > 0) |
7296 |
23 Aug 23 |
nicklas |
570 |
{ |
7296 |
23 Aug 23 |
nicklas |
571 |
JSONArray jsonCopyNumber = new JSONArray(); |
7296 |
23 Aug 23 |
nicklas |
572 |
for (CopyNumber cn : copyNumber) |
7296 |
23 Aug 23 |
nicklas |
573 |
{ |
7296 |
23 Aug 23 |
nicklas |
574 |
loadCopyNumberInfo(dc, cn); |
7296 |
23 Aug 23 |
nicklas |
575 |
jsonCopyNumber.add(cn.asJSONObject()); |
7296 |
23 Aug 23 |
nicklas |
576 |
} |
7296 |
23 Aug 23 |
nicklas |
577 |
jsonSections.add(loadSectionInfo(sc, "copyNumber")); |
7296 |
23 Aug 23 |
nicklas |
578 |
json.put("copyNumber", jsonCopyNumber); |
7296 |
23 Aug 23 |
nicklas |
579 |
} |
7296 |
23 Aug 23 |
nicklas |
580 |
|
7296 |
23 Aug 23 |
nicklas |
581 |
|
2918 |
11 Nov 14 |
nicklas |
582 |
List<Rawbioassay> raw = Rawbioassay.findByCaseName(dc, caseName); |
2918 |
11 Nov 14 |
nicklas |
583 |
if (raw.size() > 0) |
2918 |
11 Nov 14 |
nicklas |
584 |
{ |
2918 |
11 Nov 14 |
nicklas |
585 |
JSONArray jsonRaw = new JSONArray(); |
7411 |
10 Nov 23 |
nicklas |
586 |
JSONArray jsonRNAVarCall = new JSONArray(); |
7411 |
10 Nov 23 |
nicklas |
587 |
JSONArray jsonDNAVarCall = new JSONArray(); |
2918 |
11 Nov 14 |
nicklas |
588 |
for (Rawbioassay r : raw) |
2918 |
11 Nov 14 |
nicklas |
589 |
{ |
5731 |
19 Nov 19 |
nicklas |
590 |
if (Rawdatatype.VARIANT_CALL.getRawDataType().equals(r.getItem().getRawDataType())) |
5731 |
19 Nov 19 |
nicklas |
591 |
{ |
7411 |
10 Nov 23 |
nicklas |
592 |
Pipeline p = loadVariantCallingInfo(dc, r); |
7411 |
10 Nov 23 |
nicklas |
593 |
if (p == null || p.isRnaPipeline()) |
7411 |
10 Nov 23 |
nicklas |
594 |
{ |
7411 |
10 Nov 23 |
nicklas |
595 |
jsonRNAVarCall.add(r.asJSONObject()); |
7411 |
10 Nov 23 |
nicklas |
596 |
} |
7411 |
10 Nov 23 |
nicklas |
597 |
else |
7411 |
10 Nov 23 |
nicklas |
598 |
{ |
7411 |
10 Nov 23 |
nicklas |
599 |
jsonDNAVarCall.add(r.asJSONObject()); |
7411 |
10 Nov 23 |
nicklas |
600 |
} |
5731 |
19 Nov 19 |
nicklas |
601 |
} |
5731 |
19 Nov 19 |
nicklas |
602 |
else |
5731 |
19 Nov 19 |
nicklas |
603 |
{ |
5731 |
19 Nov 19 |
nicklas |
604 |
loadRawBioAssayInfo(dc, r); |
5731 |
19 Nov 19 |
nicklas |
605 |
jsonRaw.add(r.asJSONObject()); |
5731 |
19 Nov 19 |
nicklas |
606 |
} |
2918 |
11 Nov 14 |
nicklas |
607 |
} |
2918 |
11 Nov 14 |
nicklas |
608 |
jsonSections.add(loadSectionInfo(sc, "rawBioAssays")); |
2918 |
11 Nov 14 |
nicklas |
609 |
json.put("rawBioAssays", jsonRaw); |
7411 |
10 Nov 23 |
nicklas |
610 |
jsonSections.add(loadSectionInfo(sc, "variantCallingRNA")); |
7411 |
10 Nov 23 |
nicklas |
611 |
json.put("variantCallingRNA", jsonRNAVarCall); |
7411 |
10 Nov 23 |
nicklas |
612 |
jsonSections.add(loadSectionInfo(sc, "variantCallingDNA")); |
7411 |
10 Nov 23 |
nicklas |
613 |
json.put("variantCallingDNA", jsonDNAVarCall); |
2918 |
11 Nov 14 |
nicklas |
614 |
} |
1821 |
06 Feb 13 |
nicklas |
615 |
} |
1821 |
06 Feb 13 |
nicklas |
616 |
} |
1821 |
06 Feb 13 |
nicklas |
617 |
catch (Throwable t) |
1821 |
06 Feb 13 |
nicklas |
618 |
{ |
1821 |
06 Feb 13 |
nicklas |
619 |
t.printStackTrace(); |
1821 |
06 Feb 13 |
nicklas |
620 |
json.clear(); |
1821 |
06 Feb 13 |
nicklas |
621 |
json.put("status", "error"); |
1821 |
06 Feb 13 |
nicklas |
622 |
json.put("message", t.getMessage()); |
1821 |
06 Feb 13 |
nicklas |
623 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
1821 |
06 Feb 13 |
nicklas |
624 |
} |
1821 |
06 Feb 13 |
nicklas |
625 |
finally |
1821 |
06 Feb 13 |
nicklas |
626 |
{ |
1821 |
06 Feb 13 |
nicklas |
627 |
if (dc != null) dc.close(); |
1821 |
06 Feb 13 |
nicklas |
628 |
json.writeJSONString(resp.getWriter()); |
1821 |
06 Feb 13 |
nicklas |
629 |
} |
1821 |
06 Feb 13 |
nicklas |
630 |
} |
1821 |
06 Feb 13 |
nicklas |
631 |
|
2100 |
24 Oct 13 |
nicklas |
632 |
@Override |
2100 |
24 Oct 13 |
nicklas |
633 |
protected void doPost(HttpServletRequest req, HttpServletResponse resp) |
2100 |
24 Oct 13 |
nicklas |
634 |
throws ServletException, IOException |
2100 |
24 Oct 13 |
nicklas |
635 |
{ |
2100 |
24 Oct 13 |
nicklas |
636 |
String cmd = req.getParameter("cmd"); |
2598 |
22 Aug 14 |
nicklas |
637 |
JsonUtil.setJsonResponseHeaders(resp); |
2100 |
24 Oct 13 |
nicklas |
638 |
|
2100 |
24 Oct 13 |
nicklas |
639 |
JSONObject json = new JSONObject(); |
2100 |
24 Oct 13 |
nicklas |
640 |
json.put("status", "ok"); |
2100 |
24 Oct 13 |
nicklas |
641 |
|
2100 |
24 Oct 13 |
nicklas |
642 |
JSONArray jsonMessages = new JSONArray(); |
3975 |
26 May 16 |
nicklas |
643 |
final SessionControl sc = Reggie.getSessionControl(req); |
2100 |
24 Oct 13 |
nicklas |
644 |
DbControl dc = null; |
2100 |
24 Oct 13 |
nicklas |
645 |
|
2100 |
24 Oct 13 |
nicklas |
646 |
try |
2100 |
24 Oct 13 |
nicklas |
647 |
{ |
2100 |
24 Oct 13 |
nicklas |
648 |
if ("SetSectionVisibility".equals(cmd)) |
2100 |
24 Oct 13 |
nicklas |
649 |
{ |
2100 |
24 Oct 13 |
nicklas |
650 |
String section = req.getParameter("section"); |
2100 |
24 Oct 13 |
nicklas |
651 |
boolean isHidden = Values.getBoolean(req.getParameter("hidden")); |
2100 |
24 Oct 13 |
nicklas |
652 |
String key = "net.sf.basedb.reggie.case-summary."+section+".hidden-details"; |
2100 |
24 Oct 13 |
nicklas |
653 |
sc.setUserClientSetting(key, isHidden ? "1" : "0"); |
2100 |
24 Oct 13 |
nicklas |
654 |
jsonMessages.add(key + "=" + sc.getUserClientSetting(key)); |
2100 |
24 Oct 13 |
nicklas |
655 |
} |
2100 |
24 Oct 13 |
nicklas |
656 |
json.put("messages", jsonMessages); |
2100 |
24 Oct 13 |
nicklas |
657 |
} |
2100 |
24 Oct 13 |
nicklas |
658 |
catch (Throwable t) |
2100 |
24 Oct 13 |
nicklas |
659 |
{ |
2100 |
24 Oct 13 |
nicklas |
660 |
t.printStackTrace(); |
2100 |
24 Oct 13 |
nicklas |
661 |
json.clear(); |
2100 |
24 Oct 13 |
nicklas |
662 |
json.put("status", "error"); |
2100 |
24 Oct 13 |
nicklas |
663 |
json.put("message", t.getMessage()); |
2100 |
24 Oct 13 |
nicklas |
664 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
2100 |
24 Oct 13 |
nicklas |
665 |
} |
2100 |
24 Oct 13 |
nicklas |
666 |
finally |
2100 |
24 Oct 13 |
nicklas |
667 |
{ |
2100 |
24 Oct 13 |
nicklas |
668 |
if (dc != null) dc.close(); |
2100 |
24 Oct 13 |
nicklas |
669 |
json.writeJSONString(resp.getWriter()); |
2100 |
24 Oct 13 |
nicklas |
670 |
} |
2100 |
24 Oct 13 |
nicklas |
671 |
} |
2100 |
24 Oct 13 |
nicklas |
672 |
|
4075 |
05 Sep 16 |
nicklas |
673 |
/** |
7150 |
09 May 23 |
nicklas |
Check if the 'case' name is a 7-digit value + optional 'C' suffix or 'K' prefix |
7150 |
09 May 23 |
nicklas |
or the name of a SCAN-B item starting with 7 digits, a dot and then optionally more |
7150 |
09 May 23 |
nicklas |
characters. |
2144 |
19 Nov 13 |
olle |
677 |
|
2144 |
19 Nov 13 |
olle |
@param caseName String Input case name to check. |
2144 |
19 Nov 13 |
olle |
@param allowSuffix boolean Flag indicating if optional 'C' suffix is allowed. |
6565 |
01 Feb 22 |
nicklas |
@param allowPrefix boolean flag indicating if optional 'K' prefix is allowed. |
6565 |
01 Feb 22 |
nicklas |
@return The 7-digit SCANB ID or null |
2144 |
19 Nov 13 |
olle |
682 |
*/ |
6565 |
01 Feb 22 |
nicklas |
683 |
private String getScanBId(String caseName, boolean allowSuffix, boolean allowPrefix) |
2144 |
19 Nov 13 |
olle |
684 |
{ |
2144 |
19 Nov 13 |
olle |
685 |
if (caseName != null) |
2144 |
19 Nov 13 |
olle |
686 |
{ |
7150 |
09 May 23 |
nicklas |
687 |
for (String regex : new String[] { |
7150 |
09 May 23 |
nicklas |
688 |
"^"+(allowPrefix ? "K?":"")+"(\\d{7})"+(allowSuffix ? "C?":"")+"$" , |
7150 |
09 May 23 |
nicklas |
689 |
"^(\\d{7})\\.[a-z0-9.]+"} ) |
7150 |
09 May 23 |
nicklas |
690 |
{ |
7150 |
09 May 23 |
nicklas |
691 |
Pattern pattern = Pattern.compile(regex); |
7150 |
09 May 23 |
nicklas |
692 |
Matcher matcher = pattern.matcher(caseName); |
7150 |
09 May 23 |
nicklas |
693 |
if (matcher.matches()) return matcher.group(1); |
7150 |
09 May 23 |
nicklas |
694 |
} |
2144 |
19 Nov 13 |
olle |
695 |
} |
6565 |
01 Feb 22 |
nicklas |
696 |
return null; |
2144 |
19 Nov 13 |
olle |
697 |
} |
4075 |
05 Sep 16 |
nicklas |
698 |
|
4075 |
05 Sep 16 |
nicklas |
699 |
/** |
4075 |
05 Sep 16 |
nicklas |
Check if the 'case' name is an external id for a specimen. |
4075 |
05 Sep 16 |
nicklas |
It should contain 'S' + 6 digits |
4075 |
05 Sep 16 |
nicklas |
702 |
|
4075 |
05 Sep 16 |
nicklas |
@param caseName |
4075 |
05 Sep 16 |
nicklas |
@return The specimen external id or null if no match is found |
4075 |
05 Sep 16 |
nicklas |
705 |
*/ |
4075 |
05 Sep 16 |
nicklas |
706 |
private String getSpecimenExternalId(String caseName) |
4075 |
05 Sep 16 |
nicklas |
707 |
{ |
4075 |
05 Sep 16 |
nicklas |
708 |
if (caseName == null) return null; |
4075 |
05 Sep 16 |
nicklas |
709 |
Pattern pattern = Pattern.compile("S\\d{6}"); |
4075 |
05 Sep 16 |
nicklas |
710 |
Matcher matcher = pattern.matcher(caseName); |
4075 |
05 Sep 16 |
nicklas |
711 |
return matcher.find() ? matcher.group() : null; |
4075 |
05 Sep 16 |
nicklas |
712 |
} |
4075 |
05 Sep 16 |
nicklas |
713 |
|
4075 |
05 Sep 16 |
nicklas |
714 |
/** |
4075 |
05 Sep 16 |
nicklas |
Check if the 'case' name is an external id for blood. |
4075 |
05 Sep 16 |
nicklas |
It should contain 'B' + 6 digits |
4075 |
05 Sep 16 |
nicklas |
717 |
|
4075 |
05 Sep 16 |
nicklas |
@param caseName |
4075 |
05 Sep 16 |
nicklas |
@return The blood external id or null if no match is found |
4075 |
05 Sep 16 |
nicklas |
720 |
*/ |
4075 |
05 Sep 16 |
nicklas |
721 |
private String getBloodExternalId(String caseName) |
4075 |
05 Sep 16 |
nicklas |
722 |
{ |
4075 |
05 Sep 16 |
nicklas |
723 |
if (caseName == null) return null; |
4075 |
05 Sep 16 |
nicklas |
724 |
Pattern pattern = Pattern.compile("B\\d{6}"); |
4075 |
05 Sep 16 |
nicklas |
725 |
Matcher matcher = pattern.matcher(caseName); |
4075 |
05 Sep 16 |
nicklas |
726 |
return matcher.find() ? matcher.group() : null; |
4075 |
05 Sep 16 |
nicklas |
727 |
} |
4075 |
05 Sep 16 |
nicklas |
728 |
|
4075 |
05 Sep 16 |
nicklas |
729 |
/** |
4075 |
05 Sep 16 |
nicklas |
Check if the 'case' name is an external id for a case. |
4075 |
05 Sep 16 |
nicklas |
It should contain 'C' + 6 digits |
4075 |
05 Sep 16 |
nicklas |
732 |
|
4075 |
05 Sep 16 |
nicklas |
@param caseName |
4075 |
05 Sep 16 |
nicklas |
@return The case external id or null if no match is found |
4075 |
05 Sep 16 |
nicklas |
735 |
*/ |
4075 |
05 Sep 16 |
nicklas |
736 |
private String getCaseExternalId(String caseName) |
4075 |
05 Sep 16 |
nicklas |
737 |
{ |
4075 |
05 Sep 16 |
nicklas |
738 |
if (caseName == null) return null; |
4075 |
05 Sep 16 |
nicklas |
739 |
Pattern pattern = Pattern.compile("C\\d{6}"); |
4075 |
05 Sep 16 |
nicklas |
740 |
Matcher matcher = pattern.matcher(caseName); |
4075 |
05 Sep 16 |
nicklas |
741 |
return matcher.find() ? matcher.group() : null; |
4075 |
05 Sep 16 |
nicklas |
742 |
} |
4075 |
05 Sep 16 |
nicklas |
743 |
|
4075 |
05 Sep 16 |
nicklas |
744 |
/** |
4075 |
05 Sep 16 |
nicklas |
Check if the 'case' name is an external id for a patient. |
4076 |
05 Sep 16 |
nicklas |
It should contain 'Q' + 6 digits |
4075 |
05 Sep 16 |
nicklas |
747 |
|
4075 |
05 Sep 16 |
nicklas |
@param caseName |
4075 |
05 Sep 16 |
nicklas |
@return The patient external id or null if no match is found |
4075 |
05 Sep 16 |
nicklas |
750 |
*/ |
4075 |
05 Sep 16 |
nicklas |
751 |
private String getPatientExternalId(String caseName) |
4075 |
05 Sep 16 |
nicklas |
752 |
{ |
4075 |
05 Sep 16 |
nicklas |
753 |
if (caseName == null) return null; |
4076 |
05 Sep 16 |
nicklas |
754 |
Pattern pattern = Pattern.compile("Q\\d{6}"); |
4075 |
05 Sep 16 |
nicklas |
755 |
Matcher matcher = pattern.matcher(caseName); |
4075 |
05 Sep 16 |
nicklas |
756 |
return matcher.find() ? matcher.group() : null; |
4075 |
05 Sep 16 |
nicklas |
757 |
} |
5278 |
05 Feb 19 |
nicklas |
758 |
|
5278 |
05 Feb 19 |
nicklas |
759 |
/** |
5278 |
05 Feb 19 |
nicklas |
Check if the 'case' name is an PATnnnn name for a patient. |
5278 |
05 Feb 19 |
nicklas |
It should contain 'PAT' + 6 digits |
5278 |
05 Feb 19 |
nicklas |
762 |
|
5278 |
05 Feb 19 |
nicklas |
@param caseName |
5278 |
05 Feb 19 |
nicklas |
@return The patient 'name' or null if no match is found |
5278 |
05 Feb 19 |
nicklas |
@since 4.21 |
5278 |
05 Feb 19 |
nicklas |
766 |
*/ |
5278 |
05 Feb 19 |
nicklas |
767 |
private String getPatientName(String caseName) |
5278 |
05 Feb 19 |
nicklas |
768 |
{ |
5278 |
05 Feb 19 |
nicklas |
769 |
if (caseName == null) return null; |
5278 |
05 Feb 19 |
nicklas |
770 |
Pattern pattern = Pattern.compile("PAT\\d{6}"); |
5278 |
05 Feb 19 |
nicklas |
771 |
Matcher matcher = pattern.matcher(caseName); |
5278 |
05 Feb 19 |
nicklas |
772 |
return matcher.find() ? matcher.group() : null; |
5278 |
05 Feb 19 |
nicklas |
773 |
} |
2144 |
19 Nov 13 |
olle |
774 |
|
2100 |
24 Oct 13 |
nicklas |
775 |
private JSONObject loadSectionInfo(SessionControl sc, String section) |
2100 |
24 Oct 13 |
nicklas |
776 |
{ |
2100 |
24 Oct 13 |
nicklas |
777 |
String keyBase = "net.sf.basedb.reggie.case-summary."+section; |
2100 |
24 Oct 13 |
nicklas |
778 |
JSONObject json = new JSONObject(); |
2100 |
24 Oct 13 |
nicklas |
779 |
json.put("id", section); |
2100 |
24 Oct 13 |
nicklas |
780 |
json.put("hiddenDetails", Values.getInt(sc.getUserClientSetting(keyBase+".hidden-details"))); |
2100 |
24 Oct 13 |
nicklas |
781 |
return json; |
2100 |
24 Oct 13 |
nicklas |
782 |
} |
2100 |
24 Oct 13 |
nicklas |
783 |
|
1821 |
06 Feb 13 |
nicklas |
784 |
private void loadCaseInfo(DbControl dc, Case theCase) |
1821 |
06 Feb 13 |
nicklas |
785 |
{ |
1821 |
06 Feb 13 |
nicklas |
786 |
Sample s = theCase.getItem(); |
1821 |
06 Feb 13 |
nicklas |
// Properties |
1821 |
06 Feb 13 |
nicklas |
788 |
theCase.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(s.getEntryDate())); |
1821 |
06 Feb 13 |
nicklas |
789 |
theCase.setAnnotation("editable", s.hasPermission(Permission.WRITE)); |
1821 |
06 Feb 13 |
nicklas |
790 |
|
1821 |
06 Feb 13 |
nicklas |
// Annotations and consent |
1821 |
06 Feb 13 |
nicklas |
792 |
Consent.loadConsentAnnotations(dc, theCase); |
1821 |
06 Feb 13 |
nicklas |
793 |
theCase.loadAnnotations(dc, "laterality", Annotationtype.LATERALITY, null); |
4798 |
08 May 18 |
nicklas |
794 |
theCase.loadAnnotations(dc, "frozenTissueDate", Annotationtype.FROZEN_TISSUE_DATE, Reggie.CONVERTER_DATE_TO_STRING); |
1844 |
15 Feb 13 |
nicklas |
795 |
theCase.setAnnotation("comment", s.getDescription()); |
1821 |
06 Feb 13 |
nicklas |
796 |
} |
1821 |
06 Feb 13 |
nicklas |
797 |
|
1821 |
06 Feb 13 |
nicklas |
798 |
private void loadBloodInfo(DbControl dc, Blood blood) |
1821 |
06 Feb 13 |
nicklas |
799 |
{ |
1821 |
06 Feb 13 |
nicklas |
800 |
Sample s = blood.getItem(); |
1821 |
06 Feb 13 |
nicklas |
801 |
|
1821 |
06 Feb 13 |
nicklas |
802 |
blood.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(s.getEntryDate())); |
1821 |
06 Feb 13 |
nicklas |
803 |
blood.setAnnotation("editable", s.hasPermission(Permission.WRITE)); |
1821 |
06 Feb 13 |
nicklas |
804 |
|
1821 |
06 Feb 13 |
nicklas |
805 |
Consent.loadConsentAnnotations(dc, blood); |
1821 |
06 Feb 13 |
nicklas |
806 |
blood.loadAnnotations(dc, "samplingDate", Annotationtype.BLOOD_SAMPLING_DATETIME, Reggie.CONVERTER_DATETIME_TO_STRING); |
1821 |
06 Feb 13 |
nicklas |
807 |
blood.loadAnnotations(dc, "freezerDate", Annotationtype.BLOOD_FREEZER_DATETIME, Reggie.CONVERTER_DATETIME_TO_STRING); |
1821 |
06 Feb 13 |
nicklas |
808 |
blood.loadAnnotations(dc, "serum", Annotationtype.BLOOD_SERUM, null); |
1821 |
06 Feb 13 |
nicklas |
809 |
blood.loadAnnotations(dc, "bloodSample", Annotationtype.BLOOD_SAMPLE, null); |
1844 |
15 Feb 13 |
nicklas |
810 |
blood.setAnnotation("comment", s.getDescription()); |
1821 |
06 Feb 13 |
nicklas |
811 |
} |
1821 |
06 Feb 13 |
nicklas |
812 |
|
1821 |
06 Feb 13 |
nicklas |
813 |
private void loadPatientInfo(DbControl dc, Patient patient) |
1821 |
06 Feb 13 |
nicklas |
814 |
{ |
1821 |
06 Feb 13 |
nicklas |
815 |
BioSource b = patient.getBioSource(); |
1821 |
06 Feb 13 |
nicklas |
816 |
|
1821 |
06 Feb 13 |
nicklas |
817 |
patient.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(b.getEntryDate())); |
1821 |
06 Feb 13 |
nicklas |
818 |
patient.setAnnotation("editable", b.hasPermission(Permission.WRITE)); |
1821 |
06 Feb 13 |
nicklas |
819 |
|
1821 |
06 Feb 13 |
nicklas |
820 |
patient.loadDefaultAnnotations(dc); |
1821 |
06 Feb 13 |
nicklas |
821 |
} |
1821 |
06 Feb 13 |
nicklas |
822 |
|
1821 |
06 Feb 13 |
nicklas |
823 |
private void loadSpecimenInfo(DbControl dc, SpecimenTube specimen) |
1821 |
06 Feb 13 |
nicklas |
824 |
{ |
1821 |
06 Feb 13 |
nicklas |
825 |
Sample s = specimen.getSample(); |
1821 |
06 Feb 13 |
nicklas |
826 |
specimen.loadBioPlateLocation(); |
1821 |
06 Feb 13 |
nicklas |
827 |
specimen.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(s.getEntryDate())); |
1821 |
06 Feb 13 |
nicklas |
828 |
specimen.setAnnotation("editable", s.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
829 |
specimen.loadDoNotUseAnnotations(dc, null); |
1821 |
06 Feb 13 |
nicklas |
830 |
|
1821 |
06 Feb 13 |
nicklas |
831 |
specimen.setAnnotation("originalQuantity", s.getOriginalQuantity()); |
1821 |
06 Feb 13 |
nicklas |
832 |
specimen.setAnnotation("remainingQuantity", s.getRemainingQuantity()); |
1821 |
06 Feb 13 |
nicklas |
833 |
|
1821 |
06 Feb 13 |
nicklas |
834 |
specimen.loadAnnotations(dc, "laterality", Annotationtype.LATERALITY, null); |
1821 |
06 Feb 13 |
nicklas |
835 |
specimen.loadAnnotations(dc, "arrivalDate", Annotationtype.ARRIVAL_DATE, Reggie.CONVERTER_DATE_TO_STRING); |
1821 |
06 Feb 13 |
nicklas |
836 |
specimen.loadAnnotations(dc, "pad", Annotationtype.PAD, null); |
1821 |
06 Feb 13 |
nicklas |
837 |
specimen.loadAnnotations(dc, "samplingDate", Annotationtype.SAMPLING_DATETIME, Reggie.CONVERTER_DATETIME_TO_STRING); |
1821 |
06 Feb 13 |
nicklas |
838 |
specimen.loadAnnotations(dc, "rnaLaterDate", Annotationtype.RNALATER_DATETIME, Reggie.CONVERTER_DATETIME_TO_STRING); |
1821 |
06 Feb 13 |
nicklas |
839 |
specimen.loadAnnotations(dc, "biopsyType", Annotationtype.BIOPSY_TYPE, null); |
1828 |
07 Feb 13 |
nicklas |
840 |
specimen.loadAnnotations(dc, "partitionComment", Annotationtype.OPERATOR_PARTITION_COMMENT, null); |
1828 |
07 Feb 13 |
nicklas |
841 |
specimen.loadAnnotations(dc, "nofPieces", Annotationtype.NOF_PIECES, null); |
3758 |
19 Feb 16 |
nicklas |
842 |
specimen.loadAnnotations(dc, "YellowLabel", Annotationtype.YELLOW_LABEL, null); |
7146 |
08 May 23 |
nicklas |
843 |
specimen.loadAnnotations(dc, "ExternalRef", Annotationtype.EXTERNAL_REF, null); |
7146 |
08 May 23 |
nicklas |
844 |
specimen.loadAnnotations(dc, "OtherPathNote", Annotationtype.OTHER_PATH_NOTE, null); |
1844 |
15 Feb 13 |
nicklas |
845 |
specimen.setAnnotation("comment", s.getDescription()); |
7151 |
09 May 23 |
nicklas |
846 |
|
7172 |
16 May 23 |
nicklas |
847 |
try |
7172 |
16 May 23 |
nicklas |
848 |
{ |
7172 |
16 May 23 |
nicklas |
849 |
File json = specimen.getLinkedFile(dc, "Imported from"); |
7172 |
16 May 23 |
nicklas |
850 |
if (json != null) specimen.setAnnotation("importFile", JsonUtil.getFileAsJSON(json)); |
7172 |
16 May 23 |
nicklas |
851 |
} |
7172 |
16 May 23 |
nicklas |
852 |
catch (RuntimeException ex) |
7172 |
16 May 23 |
nicklas |
853 |
{} // The user may not have access to the file |
1821 |
06 Feb 13 |
nicklas |
854 |
} |
1821 |
06 Feb 13 |
nicklas |
855 |
|
1821 |
06 Feb 13 |
nicklas |
856 |
private void loadNoSpecimenInfo(DbControl dc, NoSpecimen noSpecimen) |
1821 |
06 Feb 13 |
nicklas |
857 |
{ |
1821 |
06 Feb 13 |
nicklas |
858 |
Sample s = noSpecimen.getSample(); |
1821 |
06 Feb 13 |
nicklas |
859 |
noSpecimen.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(s.getEntryDate())); |
1821 |
06 Feb 13 |
nicklas |
860 |
noSpecimen.setAnnotation("editable", s.hasPermission(Permission.WRITE)); |
1821 |
06 Feb 13 |
nicklas |
861 |
|
1821 |
06 Feb 13 |
nicklas |
862 |
noSpecimen.loadAnnotations(dc, "laterality", Annotationtype.LATERALITY, null); |
1821 |
06 Feb 13 |
nicklas |
863 |
noSpecimen.loadAnnotations(dc, "pad", Annotationtype.PAD, null); |
1821 |
06 Feb 13 |
nicklas |
864 |
noSpecimen.loadAnnotations(dc, "samplingDate", Annotationtype.SAMPLING_DATETIME, Reggie.CONVERTER_DATE_TO_STRING); |
6579 |
10 Feb 22 |
nicklas |
865 |
noSpecimen.loadAnnotations(dc, "reasonIfNoSpecimen", Annotationtype.REASON_IF_NO_SPECIMEN, null); |
6579 |
10 Feb 22 |
nicklas |
866 |
|
6579 |
10 Feb 22 |
nicklas |
867 |
noSpecimen.loadAnnotations(dc, "externalSpecimenExists", Annotationtype.EXTERNAL_SPECIMEN_EXISTS, null); |
6579 |
10 Feb 22 |
nicklas |
868 |
noSpecimen.loadAnnotations(dc, "externalOperator", Annotationtype.EXTERNAL_OPERATOR, null); |
6579 |
10 Feb 22 |
nicklas |
869 |
noSpecimen.loadAnnotations(dc, "liasonComment", Annotationtype.LIASON_COMMENT, null); |
7146 |
08 May 23 |
nicklas |
870 |
noSpecimen.loadAnnotations(dc, "ExternalRef", Annotationtype.EXTERNAL_REF, null); |
7146 |
08 May 23 |
nicklas |
871 |
noSpecimen.loadAnnotations(dc, "OtherPathNote", Annotationtype.OTHER_PATH_NOTE, null); |
6579 |
10 Feb 22 |
nicklas |
872 |
|
1844 |
15 Feb 13 |
nicklas |
873 |
noSpecimen.setAnnotation("comment", s.getDescription()); |
1821 |
06 Feb 13 |
nicklas |
874 |
} |
1821 |
06 Feb 13 |
nicklas |
875 |
|
6479 |
09 Nov 21 |
nicklas |
876 |
private void loadGenotypeCallInfo(DbControl dc, GenotypeCall gtc) |
6479 |
09 Nov 21 |
nicklas |
877 |
{ |
6479 |
09 Nov 21 |
nicklas |
878 |
DerivedBioAssay dba = gtc.getDerivedBioAssay(); |
6479 |
09 Nov 21 |
nicklas |
879 |
gtc.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
6479 |
09 Nov 21 |
nicklas |
880 |
gtc.loadAnnotations(dc, "callDate", Annotationtype.CALL_DATE, Reggie.CONVERTER_DATETIME_TO_STRING); |
6479 |
09 Nov 21 |
nicklas |
881 |
gtc.loadAnnotations(dc, "numCalls", Annotationtype.NUM_CALLS, null); |
6479 |
09 Nov 21 |
nicklas |
882 |
gtc.loadAnnotations(dc, "callRate", Annotationtype.CALL_RATE, null); |
6479 |
09 Nov 21 |
nicklas |
883 |
gtc.loadAnnotations(dc, "gc50", Annotationtype.GC50, null); |
6479 |
09 Nov 21 |
nicklas |
884 |
gtc.loadAnnotations(dc, "gc10", Annotationtype.GC10, null); |
6517 |
07 Dec 21 |
nicklas |
885 |
gtc.loadAnnotations(dc, "QC_GENOTYPE_COUNT", Annotationtype.QC_GENOTYPE_COUNT, null); |
6517 |
07 Dec 21 |
nicklas |
886 |
gtc.loadAnnotations(dc, "QC_GENOTYPE_HET_PCT", Annotationtype.QC_GENOTYPE_HET_PCT, null); |
6517 |
07 Dec 21 |
nicklas |
887 |
gtc.setAnnotation("qcVcf", JsonUtil.loadLinkedItem(dc, dba, "qc_genotype.vcf", Item.FILE, null)); |
6479 |
09 Nov 21 |
nicklas |
888 |
|
6479 |
09 Nov 21 |
nicklas |
889 |
BloodDna dna = gtc.getBloodDna(dc); |
6479 |
09 Nov 21 |
nicklas |
890 |
if (dna != null) |
6479 |
09 Nov 21 |
nicklas |
891 |
{ |
6479 |
09 Nov 21 |
nicklas |
892 |
gtc.setAnnotation("bloodDna", dna.asJSONObject()); |
6479 |
09 Nov 21 |
nicklas |
893 |
} |
6479 |
09 Nov 21 |
nicklas |
894 |
|
6479 |
09 Nov 21 |
nicklas |
895 |
Scan sc = gtc.getScan(dc); |
6479 |
09 Nov 21 |
nicklas |
896 |
if (sc != null) |
6479 |
09 Nov 21 |
nicklas |
897 |
{ |
6479 |
09 Nov 21 |
nicklas |
898 |
sc.setAnnotation("editable", sc.getItem().hasPermission(Permission.WRITE)); |
6479 |
09 Nov 21 |
nicklas |
899 |
sc.loadAnnotations(dc, "scanDate", Annotationtype.SCAN_DATE, Reggie.CONVERTER_DATETIME_TO_STRING); |
6479 |
09 Nov 21 |
nicklas |
900 |
gtc.setAnnotation("scan", sc.asJSONObject()); |
6479 |
09 Nov 21 |
nicklas |
901 |
} |
6479 |
09 Nov 21 |
nicklas |
902 |
|
6479 |
09 Nov 21 |
nicklas |
903 |
BeadChip chip = gtc.getBeadChip(dc); |
6479 |
09 Nov 21 |
nicklas |
904 |
if (chip != null) |
6479 |
09 Nov 21 |
nicklas |
905 |
{ |
6479 |
09 Nov 21 |
nicklas |
906 |
chip.setAnnotation("editable", chip.getItem().hasPermission(Permission.WRITE)); |
6479 |
09 Nov 21 |
nicklas |
907 |
chip.loadAnnotations(dc, "chipType", Annotationtype.BEADCHIP_TYPE, null); |
6479 |
09 Nov 21 |
nicklas |
908 |
gtc.setAnnotation("beadChip", chip.asJSONObject()); |
6479 |
09 Nov 21 |
nicklas |
909 |
} |
6479 |
09 Nov 21 |
nicklas |
910 |
|
6479 |
09 Nov 21 |
nicklas |
911 |
gtc.setAnnotation("comment", dba.getDescription()); |
6479 |
09 Nov 21 |
nicklas |
912 |
} |
6479 |
09 Nov 21 |
nicklas |
913 |
|
6882 |
22 Nov 22 |
nicklas |
914 |
private void loadMethylationInfo(DbControl dc, Methylation meth) |
6882 |
22 Nov 22 |
nicklas |
915 |
{ |
6882 |
22 Nov 22 |
nicklas |
916 |
DerivedBioAssay dba = meth.getDerivedBioAssay(); |
6882 |
22 Nov 22 |
nicklas |
917 |
Job job = dba.getJob(); |
6882 |
22 Nov 22 |
nicklas |
918 |
if (!Subtype.METHYLATION_BETA_JOB.get(dc).equals(job.getItemSubtype())) |
6882 |
22 Nov 22 |
nicklas |
919 |
{ |
6882 |
22 Nov 22 |
nicklas |
920 |
job = null; // We only care about beta-analysis jobs |
6882 |
22 Nov 22 |
nicklas |
921 |
} |
6882 |
22 Nov 22 |
nicklas |
922 |
meth.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
6882 |
22 Nov 22 |
nicklas |
923 |
meth.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
6882 |
22 Nov 22 |
nicklas |
924 |
meth.loadDoNotUseAnnotations(dc, null); |
6882 |
22 Nov 22 |
nicklas |
925 |
if (job == null || job.getEnded() != null) |
6882 |
22 Nov 22 |
nicklas |
926 |
{ |
6882 |
22 Nov 22 |
nicklas |
927 |
meth.loadAnnotations(dc, "AnalysisFlag", Annotationtype.ANALYSIS_FLAG, null); |
6882 |
22 Nov 22 |
nicklas |
928 |
meth.loadAnnotations(dc, "ProbesI", Annotationtype.NUM_PROBES_I, null); |
6882 |
22 Nov 22 |
nicklas |
929 |
meth.loadAnnotations(dc, "ProbesII", Annotationtype.NUM_PROBES_II, null); |
6882 |
22 Nov 22 |
nicklas |
930 |
meth.setAnnotation("adjustmentPlots", JsonUtil.loadLinkedItem(dc, dba, "adjustmentPlots.pdf", Item.FILE, null)); |
6882 |
22 Nov 22 |
nicklas |
931 |
} |
6882 |
22 Nov 22 |
nicklas |
932 |
|
6882 |
22 Nov 22 |
nicklas |
933 |
Dna dna = meth.getDnaAliquot(dc); |
6882 |
22 Nov 22 |
nicklas |
934 |
if (dna != null) |
6882 |
22 Nov 22 |
nicklas |
935 |
{ |
6882 |
22 Nov 22 |
nicklas |
936 |
meth.setAnnotation("dna", dna.asJSONObject()); |
6882 |
22 Nov 22 |
nicklas |
937 |
} |
6882 |
22 Nov 22 |
nicklas |
938 |
|
6882 |
22 Nov 22 |
nicklas |
939 |
Scan sc = meth.getScan(dc); |
6882 |
22 Nov 22 |
nicklas |
940 |
if (sc != null) |
6882 |
22 Nov 22 |
nicklas |
941 |
{ |
6882 |
22 Nov 22 |
nicklas |
942 |
sc.setAnnotation("editable", sc.getItem().hasPermission(Permission.WRITE)); |
6882 |
22 Nov 22 |
nicklas |
943 |
sc.loadAnnotations(dc, "scanDate", Annotationtype.SCAN_DATE, Reggie.CONVERTER_DATETIME_TO_STRING); |
6882 |
22 Nov 22 |
nicklas |
944 |
meth.setAnnotation("scan", sc.asJSONObject()); |
6882 |
22 Nov 22 |
nicklas |
945 |
} |
6882 |
22 Nov 22 |
nicklas |
946 |
|
6882 |
22 Nov 22 |
nicklas |
947 |
BeadChip chip = meth.getBeadChip(dc); |
6882 |
22 Nov 22 |
nicklas |
948 |
if (chip != null) |
6882 |
22 Nov 22 |
nicklas |
949 |
{ |
6882 |
22 Nov 22 |
nicklas |
950 |
chip.setAnnotation("editable", chip.getItem().hasPermission(Permission.WRITE)); |
6882 |
22 Nov 22 |
nicklas |
951 |
chip.loadAnnotations(dc, "chipType", Annotationtype.BEADCHIP_TYPE, null); |
6882 |
22 Nov 22 |
nicklas |
952 |
meth.setAnnotation("beadChip", chip.asJSONObject()); |
6882 |
22 Nov 22 |
nicklas |
953 |
} |
6882 |
22 Nov 22 |
nicklas |
954 |
|
6882 |
22 Nov 22 |
nicklas |
955 |
meth.setAnnotation("comment", dba.getDescription()); |
6882 |
22 Nov 22 |
nicklas |
956 |
} |
6882 |
22 Nov 22 |
nicklas |
957 |
|
6882 |
22 Nov 22 |
nicklas |
958 |
|
1826 |
07 Feb 13 |
nicklas |
959 |
private void loadHistologyInfo(DbControl dc, Histology his) |
1826 |
07 Feb 13 |
nicklas |
960 |
{ |
1826 |
07 Feb 13 |
nicklas |
961 |
Sample s = his.getSample(); |
1826 |
07 Feb 13 |
nicklas |
962 |
BioMaterialEvent created = s.getCreationEvent(); |
1826 |
07 Feb 13 |
nicklas |
963 |
|
1826 |
07 Feb 13 |
nicklas |
964 |
his.loadBioPlateLocation(); |
1826 |
07 Feb 13 |
nicklas |
965 |
his.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(s.getEntryDate())); |
1826 |
07 Feb 13 |
nicklas |
966 |
his.setAnnotation("editable", s.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
967 |
his.loadDoNotUseAnnotations(dc, null); |
5009 |
04 Oct 18 |
nicklas |
968 |
|
1826 |
07 Feb 13 |
nicklas |
969 |
his.loadAnnotations(dc, "partitionDate", Annotationtype.PARTITION_DATE, Reggie.CONVERTER_DATE_TO_STRING); |
1826 |
07 Feb 13 |
nicklas |
970 |
his.setAnnotation("originalQuantity", s.getOriginalQuantity()); |
1826 |
07 Feb 13 |
nicklas |
971 |
his.setAnnotation("remainingQuantity", s.getRemainingQuantity()); |
1826 |
07 Feb 13 |
nicklas |
972 |
|
1826 |
07 Feb 13 |
nicklas |
973 |
if (created.getEventDate() != null) |
1826 |
07 Feb 13 |
nicklas |
974 |
{ |
1826 |
07 Feb 13 |
nicklas |
975 |
his.setAnnotation("embedDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
1826 |
07 Feb 13 |
nicklas |
976 |
his.setAnnotation("embedProtocol", JsonUtil.getProtocolAsJSON(created.getProtocol())); |
1826 |
07 Feb 13 |
nicklas |
977 |
} |
1826 |
07 Feb 13 |
nicklas |
978 |
|
1826 |
07 Feb 13 |
nicklas |
979 |
ItemQuery<Sample> stainedQuery = s.getChildSamples(); |
1826 |
07 Feb 13 |
nicklas |
980 |
Subtype.STAINED.addFilter(dc, stainedQuery); |
1826 |
07 Feb 13 |
nicklas |
981 |
stainedQuery.include(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
1826 |
07 Feb 13 |
nicklas |
982 |
List<Sample> stained = stainedQuery.list(dc); |
1826 |
07 Feb 13 |
nicklas |
983 |
if (stained.size() > 0) |
1826 |
07 Feb 13 |
nicklas |
984 |
{ |
1826 |
07 Feb 13 |
nicklas |
985 |
Sample good = stained.get(0); |
1826 |
07 Feb 13 |
nicklas |
986 |
boolean goodIsGood = false; |
1826 |
07 Feb 13 |
nicklas |
987 |
for (Sample he : stained) |
1826 |
07 Feb 13 |
nicklas |
988 |
{ |
1826 |
07 Feb 13 |
nicklas |
989 |
if (Boolean.TRUE.equals(Annotationtype.GOOD_STAIN.getAnnotationValue(dc, he))) |
1826 |
07 Feb 13 |
nicklas |
990 |
{ |
1826 |
07 Feb 13 |
nicklas |
991 |
good = he; |
1826 |
07 Feb 13 |
nicklas |
992 |
goodIsGood = true; |
1826 |
07 Feb 13 |
nicklas |
993 |
break; |
1826 |
07 Feb 13 |
nicklas |
994 |
} |
1826 |
07 Feb 13 |
nicklas |
995 |
} |
1826 |
07 Feb 13 |
nicklas |
996 |
BioMaterialEvent heCreated = good.getCreationEvent(); |
1826 |
07 Feb 13 |
nicklas |
997 |
his.setAnnotation("stainDate", Reggie.CONVERTER_DATE_TO_STRING.convert(heCreated.getEventDate())); |
1826 |
07 Feb 13 |
nicklas |
998 |
his.setAnnotation("stainProtocol", JsonUtil.getProtocolAsJSON(good.getProtocol())); |
1826 |
07 Feb 13 |
nicklas |
999 |
his.setAnnotation("numStains", stained.size()); |
1826 |
07 Feb 13 |
nicklas |
1000 |
if (goodIsGood) |
1826 |
07 Feb 13 |
nicklas |
1001 |
{ |
3373 |
09 Jun 15 |
nicklas |
// Image |
3373 |
09 Jun 15 |
nicklas |
1003 |
File imageFile = null; |
3373 |
09 Jun 15 |
nicklas |
1004 |
AnyToAny imageLink = null; |
3373 |
09 Jun 15 |
nicklas |
1005 |
try |
3373 |
09 Jun 15 |
nicklas |
1006 |
{ |
3373 |
09 Jun 15 |
nicklas |
1007 |
imageLink = AnyToAny.getByName(dc, good, "image"); |
3373 |
09 Jun 15 |
nicklas |
1008 |
if (imageLink.getToType() == Item.FILE) |
3373 |
09 Jun 15 |
nicklas |
1009 |
{ |
3373 |
09 Jun 15 |
nicklas |
// This is linked to an existing file already, replace it |
3373 |
09 Jun 15 |
nicklas |
1011 |
imageFile = (File)imageLink.getTo(); |
3373 |
09 Jun 15 |
nicklas |
1012 |
} |
3373 |
09 Jun 15 |
nicklas |
1013 |
} |
3373 |
09 Jun 15 |
nicklas |
1014 |
catch (RuntimeException ex) |
3373 |
09 Jun 15 |
nicklas |
1015 |
{} |
3373 |
09 Jun 15 |
nicklas |
1016 |
|
2134 |
11 Nov 13 |
nicklas |
1017 |
JSONObject jsonGood = new JSONObject(); |
2134 |
11 Nov 13 |
nicklas |
1018 |
jsonGood.put("id", good.getId()); |
2134 |
11 Nov 13 |
nicklas |
1019 |
jsonGood.put("name", good.getName()); |
6018 |
09 Oct 20 |
nicklas |
1020 |
BioWell well = good.getBioWell(); |
6018 |
09 Oct 20 |
nicklas |
1021 |
if (well != null) |
6018 |
09 Oct 20 |
nicklas |
1022 |
{ |
6018 |
09 Oct 20 |
nicklas |
1023 |
JSONObject jsonWell = JsonUtil.getBioWellAsJSON(well, true); |
6018 |
09 Oct 20 |
nicklas |
1024 |
jsonGood.put("bioWell", jsonWell); |
6018 |
09 Oct 20 |
nicklas |
1025 |
jsonGood.put("ndpiImage", JsonUtil.loadLinkedItem(dc, well.getPlate(), "NDPI Image", Item.FILE, null)); |
6018 |
09 Oct 20 |
nicklas |
1026 |
} |
2134 |
11 Nov 13 |
nicklas |
1027 |
jsonGood.put("comments", good.getDescription()); |
2134 |
11 Nov 13 |
nicklas |
1028 |
|
2134 |
11 Nov 13 |
nicklas |
1029 |
jsonGood.put("ScoreComplete", Annotationtype.SCORE_COMPLETE.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1030 |
jsonGood.put("ScoreInvasiveCancer", Annotationtype.SCORE_INVASIVE_CANCER.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1031 |
jsonGood.put("ScoreInsituCancer", Annotationtype.SCORE_INSITU_CANCER.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1032 |
jsonGood.put("ScoreLymphocytes", Annotationtype.SCORE_LYMPHOCYTES.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1033 |
jsonGood.put("ScoreNormal", Annotationtype.SCORE_NORMAL.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1034 |
jsonGood.put("ScoreStroma", Annotationtype.SCORE_STROMA.getAnnotationValue(dc, good)); |
2134 |
11 Nov 13 |
nicklas |
1035 |
jsonGood.put("ScoreFat", Annotationtype.SCORE_FAT.getAnnotationValue(dc, good)); |
3373 |
09 Jun 15 |
nicklas |
1036 |
if (imageFile != null) |
3373 |
09 Jun 15 |
nicklas |
1037 |
{ |
3373 |
09 Jun 15 |
nicklas |
1038 |
JSONObject jsonImage = new JSONObject(); |
3373 |
09 Jun 15 |
nicklas |
1039 |
jsonImage.put("id", imageFile.getId()); |
3373 |
09 Jun 15 |
nicklas |
1040 |
jsonImage.put("path", imageFile.getPath().toString()); |
3373 |
09 Jun 15 |
nicklas |
1041 |
jsonGood.put("image", jsonImage); |
3373 |
09 Jun 15 |
nicklas |
1042 |
} |
2134 |
11 Nov 13 |
nicklas |
1043 |
|
2134 |
11 Nov 13 |
nicklas |
1044 |
his.setAnnotation("bestStain", jsonGood); |
1826 |
07 Feb 13 |
nicklas |
1045 |
} |
1826 |
07 Feb 13 |
nicklas |
1046 |
} |
1826 |
07 Feb 13 |
nicklas |
1047 |
|
1826 |
07 Feb 13 |
nicklas |
1048 |
} |
1826 |
07 Feb 13 |
nicklas |
1049 |
|
1831 |
08 Feb 13 |
nicklas |
1050 |
private void loadLysateInfo(DbControl dc, Lysate lys) |
1831 |
08 Feb 13 |
nicklas |
1051 |
{ |
1831 |
08 Feb 13 |
nicklas |
1052 |
Extract e = lys.getExtract(); |
1831 |
08 Feb 13 |
nicklas |
1053 |
BioMaterialEvent created = e.getCreationEvent(); |
1831 |
08 Feb 13 |
nicklas |
1054 |
|
1831 |
08 Feb 13 |
nicklas |
1055 |
lys.loadBioPlateLocation(); |
1831 |
08 Feb 13 |
nicklas |
1056 |
lys.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
1831 |
08 Feb 13 |
nicklas |
1057 |
lys.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1058 |
lys.loadDoNotUseAnnotations(dc, null); |
1831 |
08 Feb 13 |
nicklas |
1059 |
lys.loadAnnotations(dc, "partitionDate", Annotationtype.PARTITION_DATE, Reggie.CONVERTER_DATE_TO_STRING); |
1833 |
08 Feb 13 |
nicklas |
1060 |
lys.loadAnnotations(dc, "multiplePieces", Annotationtype.MULTIPLE_PIECES, null); |
1831 |
08 Feb 13 |
nicklas |
1061 |
lys.setAnnotation("usedQuantity", created.getUsedQuantity((Sample)e.getParent())); |
1844 |
15 Feb 13 |
nicklas |
1062 |
lys.setAnnotation("comment", e.getDescription()); |
1831 |
08 Feb 13 |
nicklas |
1063 |
|
1831 |
08 Feb 13 |
nicklas |
1064 |
if (created.getEventDate() != null) |
1831 |
08 Feb 13 |
nicklas |
1065 |
{ |
1831 |
08 Feb 13 |
nicklas |
1066 |
lys.setAnnotation("lysisDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
1831 |
08 Feb 13 |
nicklas |
1067 |
lys.setAnnotation("lysisProtocol", JsonUtil.getProtocolAsJSON(created.getProtocol())); |
1831 |
08 Feb 13 |
nicklas |
1068 |
lys.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
1831 |
08 Feb 13 |
nicklas |
1069 |
lys.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
1831 |
08 Feb 13 |
nicklas |
1070 |
} |
1831 |
08 Feb 13 |
nicklas |
1071 |
|
1831 |
08 Feb 13 |
nicklas |
1072 |
} |
1831 |
08 Feb 13 |
nicklas |
1073 |
|
1832 |
08 Feb 13 |
nicklas |
1074 |
private void loadRnaInfo(DbControl dc, Rna rna) |
1832 |
08 Feb 13 |
nicklas |
1075 |
{ |
1832 |
08 Feb 13 |
nicklas |
1076 |
Extract e = rna.getExtract(); |
1832 |
08 Feb 13 |
nicklas |
1077 |
BioMaterialEvent created = e.getCreationEvent(); |
1832 |
08 Feb 13 |
nicklas |
1078 |
|
1832 |
08 Feb 13 |
nicklas |
1079 |
rna.loadBioPlateLocation(); |
1832 |
08 Feb 13 |
nicklas |
1080 |
rna.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
2081 |
17 Oct 13 |
olle |
1081 |
rna.setAnnotation("flag", (String) Annotationtype.FLAG.getAnnotationValue(dc, e)); |
1832 |
08 Feb 13 |
nicklas |
1082 |
rna.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1083 |
rna.loadDoNotUseAnnotations(dc, null); |
1832 |
08 Feb 13 |
nicklas |
1084 |
rna.setAnnotation("usedQuantity", created.getUsedQuantity((Extract)e.getParent())); |
1832 |
08 Feb 13 |
nicklas |
1085 |
rna.setAnnotation("extractionDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
1832 |
08 Feb 13 |
nicklas |
1086 |
rna.setAnnotation("extractionProtocol", JsonUtil.getProtocolAsJSON(created.getProtocol())); |
1832 |
08 Feb 13 |
nicklas |
1087 |
rna.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
1832 |
08 Feb 13 |
nicklas |
1088 |
rna.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
1844 |
15 Feb 13 |
nicklas |
1089 |
rna.setAnnotation("comment", e.getDescription()); |
1832 |
08 Feb 13 |
nicklas |
1090 |
rna.loadAnnotations(dc, "ndConc", Annotationtype.ND_CONC, null); |
6220 |
20 Apr 21 |
nicklas |
1091 |
rna.loadAnnotations(dc, "QubitConc", Annotationtype.QUBIT_CONC, null); |
6220 |
20 Apr 21 |
nicklas |
1092 |
rna.coalesceInto("conc", "ndConc", "QubitConc"); |
1832 |
08 Feb 13 |
nicklas |
1093 |
|
3188 |
18 Mar 15 |
nicklas |
1094 |
List<RnaQc> rnaqc = RnaQc.findByRna(dc, rna); |
3188 |
18 Mar 15 |
nicklas |
1095 |
RnaQc lastRnaQc = RnaQc.findLast(dc, null, rnaqc); |
3188 |
18 Mar 15 |
nicklas |
1096 |
if (lastRnaQc != null) |
1832 |
08 Feb 13 |
nicklas |
1097 |
{ |
3188 |
18 Mar 15 |
nicklas |
1098 |
Extract lastQc = lastRnaQc.getExtract(); |
3188 |
18 Mar 15 |
nicklas |
1099 |
Date qcRunDate = lastRnaQc.getQcRunDate(dc, null); |
3188 |
18 Mar 15 |
nicklas |
1100 |
BioWell well = lastQc.getBioWell(); |
3188 |
18 Mar 15 |
nicklas |
1101 |
BioPlate plate = well == null ? null : well.getPlate(); |
1844 |
15 Feb 13 |
nicklas |
1102 |
|
1832 |
08 Feb 13 |
nicklas |
1103 |
rna.setAnnotation("nofQc", rnaqc.size()); |
3188 |
18 Mar 15 |
nicklas |
1104 |
rna.setAnnotation("qcDate", Reggie.CONVERTER_DATE_TO_STRING.convert(qcRunDate)); |
1832 |
08 Feb 13 |
nicklas |
1105 |
rna.setAnnotation("qcProtocol", JsonUtil.getProtocolAsJSON(lastQc.getProtocol())); |
3188 |
18 Mar 15 |
nicklas |
1106 |
rna.setAnnotation("qcPlate", JsonUtil.getBioWellAsJSON(well, true)); |
1844 |
15 Feb 13 |
nicklas |
1107 |
rna.setAnnotation("qcComment", lastQc.getDescription()); |
3188 |
18 Mar 15 |
nicklas |
1108 |
rna.setAnnotation("qcRqs", Annotationtype.CA_RQS.getAnnotationValue(dc, lastQc)); |
3188 |
18 Mar 15 |
nicklas |
1109 |
rna.setAnnotation("qcRin", Annotationtype.BA_RIN.getAnnotationValue(dc, lastQc)); |
1844 |
15 Feb 13 |
nicklas |
1110 |
|
3188 |
18 Mar 15 |
nicklas |
1111 |
if (plate != null) |
1832 |
08 Feb 13 |
nicklas |
1112 |
{ |
1833 |
08 Feb 13 |
nicklas |
1113 |
try |
1832 |
08 Feb 13 |
nicklas |
1114 |
{ |
3188 |
18 Mar 15 |
nicklas |
1115 |
AnyToAny pdf = AnyToAny.getByName(dc, plate, "PDF printout"); |
1832 |
08 Feb 13 |
nicklas |
1116 |
File pdfFile = File.getById(dc, pdf.getToId()); |
1832 |
08 Feb 13 |
nicklas |
1117 |
JSONObject jsonPdf = new JSONObject(); |
1832 |
08 Feb 13 |
nicklas |
1118 |
jsonPdf.put("id", pdfFile.getId()); |
1832 |
08 Feb 13 |
nicklas |
1119 |
jsonPdf.put("name", pdfFile.getName()); |
1832 |
08 Feb 13 |
nicklas |
1120 |
rna.setAnnotation("qcPdf", jsonPdf); |
1832 |
08 Feb 13 |
nicklas |
1121 |
} |
1833 |
08 Feb 13 |
nicklas |
1122 |
catch (RuntimeException ex) |
1833 |
08 Feb 13 |
nicklas |
1123 |
{} // Typically, ItemNotFound if no PDF exists |
1832 |
08 Feb 13 |
nicklas |
1124 |
} |
1832 |
08 Feb 13 |
nicklas |
1125 |
} |
1832 |
08 Feb 13 |
nicklas |
1126 |
} |
1832 |
08 Feb 13 |
nicklas |
1127 |
|
2098 |
23 Oct 13 |
nicklas |
1128 |
private void loadDnaInfo(DbControl dc, Dna dna) |
2098 |
23 Oct 13 |
nicklas |
1129 |
{ |
2098 |
23 Oct 13 |
nicklas |
1130 |
Extract e = dna.getExtract(); |
2098 |
23 Oct 13 |
nicklas |
1131 |
BioMaterialEvent created = e.getCreationEvent(); |
2098 |
23 Oct 13 |
nicklas |
1132 |
|
2098 |
23 Oct 13 |
nicklas |
1133 |
dna.loadBioPlateLocation(); |
2098 |
23 Oct 13 |
nicklas |
1134 |
dna.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
2098 |
23 Oct 13 |
nicklas |
1135 |
dna.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1136 |
dna.loadDoNotUseAnnotations(dc, null); |
3356 |
28 May 15 |
nicklas |
1137 |
dna.setAnnotation("usedQuantity", created.getUsedQuantity((MeasuredBioMaterial)e.getParent())); |
2098 |
23 Oct 13 |
nicklas |
1138 |
dna.setAnnotation("extractionDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
2098 |
23 Oct 13 |
nicklas |
1139 |
dna.setAnnotation("extractionProtocol", JsonUtil.getProtocolAsJSON(created.getProtocol())); |
2098 |
23 Oct 13 |
nicklas |
1140 |
dna.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
2098 |
23 Oct 13 |
nicklas |
1141 |
dna.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
2098 |
23 Oct 13 |
nicklas |
1142 |
dna.setAnnotation("comment", e.getDescription()); |
2098 |
23 Oct 13 |
nicklas |
1143 |
dna.loadAnnotations(dc, "ndConc", Annotationtype.ND_CONC, null); |
6220 |
20 Apr 21 |
nicklas |
1144 |
dna.loadAnnotations(dc, "QubitConc", Annotationtype.QUBIT_CONC, null); |
6220 |
20 Apr 21 |
nicklas |
1145 |
dna.coalesceInto("conc", "ndConc", "QubitConc"); |
2098 |
23 Oct 13 |
nicklas |
1146 |
} |
2098 |
23 Oct 13 |
nicklas |
1147 |
|
3356 |
28 May 15 |
nicklas |
1148 |
private void loadBloodDnaInfo(DbControl dc, BloodDna dna) |
3356 |
28 May 15 |
nicklas |
1149 |
{ |
3356 |
28 May 15 |
nicklas |
1150 |
Extract e = dna.getExtract(); |
3356 |
28 May 15 |
nicklas |
1151 |
BioMaterialEvent created = e.getCreationEvent(); |
3356 |
28 May 15 |
nicklas |
1152 |
|
3356 |
28 May 15 |
nicklas |
1153 |
dna.loadBioPlateLocation(); |
3356 |
28 May 15 |
nicklas |
1154 |
dna.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
3356 |
28 May 15 |
nicklas |
1155 |
dna.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
3356 |
28 May 15 |
nicklas |
1156 |
dna.setAnnotation("usedQuantity", created.getUsedQuantity((MeasuredBioMaterial)e.getParent())); |
3356 |
28 May 15 |
nicklas |
1157 |
dna.setAnnotation("extractionDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
3356 |
28 May 15 |
nicklas |
1158 |
dna.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
3356 |
28 May 15 |
nicklas |
1159 |
dna.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
3356 |
28 May 15 |
nicklas |
1160 |
dna.setAnnotation("comment", e.getDescription()); |
3356 |
28 May 15 |
nicklas |
1161 |
dna.loadAnnotations(dc, "ndConc", Annotationtype.ND_CONC, null); |
3356 |
28 May 15 |
nicklas |
1162 |
} |
3356 |
28 May 15 |
nicklas |
1163 |
|
3356 |
28 May 15 |
nicklas |
1164 |
|
2098 |
23 Oct 13 |
nicklas |
1165 |
private void loadFlowThroughInfo(DbControl dc, FlowThrough ft) |
2098 |
23 Oct 13 |
nicklas |
1166 |
{ |
2098 |
23 Oct 13 |
nicklas |
1167 |
Extract e = ft.getExtract(); |
2098 |
23 Oct 13 |
nicklas |
1168 |
BioMaterialEvent created = e.getCreationEvent(); |
2098 |
23 Oct 13 |
nicklas |
1169 |
|
2098 |
23 Oct 13 |
nicklas |
1170 |
ft.loadBioPlateLocation(); |
2098 |
23 Oct 13 |
nicklas |
1171 |
ft.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
2098 |
23 Oct 13 |
nicklas |
1172 |
ft.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1173 |
ft.loadDoNotUseAnnotations(dc, null); |
2098 |
23 Oct 13 |
nicklas |
1174 |
ft.setAnnotation("usedQuantity", created.getUsedQuantity((Extract)e.getParent())); |
2098 |
23 Oct 13 |
nicklas |
1175 |
ft.setAnnotation("extractionDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
2098 |
23 Oct 13 |
nicklas |
1176 |
ft.setAnnotation("extractionProtocol", JsonUtil.getProtocolAsJSON(created.getProtocol())); |
2098 |
23 Oct 13 |
nicklas |
1177 |
ft.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
2098 |
23 Oct 13 |
nicklas |
1178 |
ft.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
2098 |
23 Oct 13 |
nicklas |
1179 |
ft.setAnnotation("comment", e.getDescription()); |
2098 |
23 Oct 13 |
nicklas |
1180 |
} |
2098 |
23 Oct 13 |
nicklas |
1181 |
|
2050 |
07 Oct 13 |
olle |
1182 |
private void loadMRnaInfo(DbControl dc, MRna mrna) |
2050 |
07 Oct 13 |
olle |
1183 |
{ |
2050 |
07 Oct 13 |
olle |
1184 |
Extract e = mrna.getExtract(); |
2050 |
07 Oct 13 |
olle |
1185 |
BioMaterialEvent created = e.getCreationEvent(); |
2050 |
07 Oct 13 |
olle |
1186 |
|
2050 |
07 Oct 13 |
olle |
1187 |
mrna.loadBioPlateLocation(); |
2050 |
07 Oct 13 |
olle |
1188 |
JSONObject jsonPdf = mrna.loadBioPlatePdf(dc); |
2050 |
07 Oct 13 |
olle |
1189 |
if (jsonPdf != null) |
2050 |
07 Oct 13 |
olle |
1190 |
{ |
2050 |
07 Oct 13 |
olle |
1191 |
mrna.setAnnotation("platePdf", jsonPdf); |
2050 |
07 Oct 13 |
olle |
1192 |
} |
2050 |
07 Oct 13 |
olle |
1193 |
mrna.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
2050 |
07 Oct 13 |
olle |
1194 |
mrna.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1195 |
mrna.loadDoNotUseAnnotations(dc, null); |
2050 |
07 Oct 13 |
olle |
1196 |
mrna.setAnnotation("usedQuantity", created.getUsedQuantity((Extract)e.getParent())); |
2101 |
25 Oct 13 |
nicklas |
1197 |
mrna.setAnnotation("comment", e.getDescription()); |
2101 |
25 Oct 13 |
nicklas |
1198 |
|
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate annotations |
2103 |
25 Oct 13 |
nicklas |
1200 |
BioPlate plate = getBioPlate(e); |
2103 |
25 Oct 13 |
nicklas |
1201 |
if (plate != null) |
2103 |
25 Oct 13 |
nicklas |
1202 |
{ |
2103 |
25 Oct 13 |
nicklas |
1203 |
Date cleanupDate = (Date) Annotationtype.CLEANUP_DATE.getAnnotationValue(dc, plate); |
2103 |
25 Oct 13 |
nicklas |
1204 |
mrna.setAnnotation("cleanupDate", Reggie.CONVERTER_DATE_TO_STRING.convert(cleanupDate)); |
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate PlateProcessResult annotation |
2103 |
25 Oct 13 |
nicklas |
1206 |
String result = (String) Annotationtype.PLATE_PROCESS_RESULT.getAnnotationValue(dc, plate); |
2103 |
25 Oct 13 |
nicklas |
1207 |
mrna.setAnnotation("result", result); |
2103 |
25 Oct 13 |
nicklas |
1208 |
} |
2050 |
07 Oct 13 |
olle |
1209 |
} |
2050 |
07 Oct 13 |
olle |
1210 |
|
2050 |
07 Oct 13 |
olle |
1211 |
private void loadCDnaInfo(DbControl dc, CDna cdna) |
2050 |
07 Oct 13 |
olle |
1212 |
{ |
2050 |
07 Oct 13 |
olle |
1213 |
Extract e = cdna.getExtract(); |
2050 |
07 Oct 13 |
olle |
1214 |
|
2050 |
07 Oct 13 |
olle |
1215 |
cdna.loadBioPlateLocation(); |
2050 |
07 Oct 13 |
olle |
1216 |
cdna.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
2050 |
07 Oct 13 |
olle |
1217 |
cdna.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1218 |
cdna.loadDoNotUseAnnotations(dc, null); |
2101 |
25 Oct 13 |
nicklas |
1219 |
cdna.setAnnotation("comment", e.getDescription()); |
2103 |
25 Oct 13 |
nicklas |
1220 |
|
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate annotations |
2103 |
25 Oct 13 |
nicklas |
1222 |
BioPlate plate = getBioPlate(e); |
2103 |
25 Oct 13 |
nicklas |
1223 |
if (plate != null) |
2103 |
25 Oct 13 |
nicklas |
1224 |
{ |
2103 |
25 Oct 13 |
nicklas |
1225 |
Date synthesisDate = (Date) Annotationtype.SYNTHESIS_DATE.getAnnotationValue(dc, plate); |
2103 |
25 Oct 13 |
nicklas |
1226 |
cdna.setAnnotation("synthesisDate", Reggie.CONVERTER_DATE_TO_STRING.convert(synthesisDate)); |
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate PlateProcessResult annotation |
2103 |
25 Oct 13 |
nicklas |
1228 |
String result = (String) Annotationtype.PLATE_PROCESS_RESULT.getAnnotationValue(dc, plate); |
2103 |
25 Oct 13 |
nicklas |
1229 |
cdna.setAnnotation("result", result); |
2103 |
25 Oct 13 |
nicklas |
1230 |
} |
2050 |
07 Oct 13 |
olle |
1231 |
} |
2050 |
07 Oct 13 |
olle |
1232 |
|
2050 |
07 Oct 13 |
olle |
1233 |
private void loadLibraryInfo(DbControl dc, Library lib) |
2050 |
07 Oct 13 |
olle |
1234 |
{ |
2050 |
07 Oct 13 |
olle |
1235 |
Extract e = lib.getExtract(); |
5895 |
14 Apr 20 |
nicklas |
1236 |
BioMaterialEvent createEvent = e.getCreationEvent(); |
2050 |
07 Oct 13 |
olle |
1237 |
|
2050 |
07 Oct 13 |
olle |
1238 |
lib.loadBioPlateLocation(); |
5895 |
14 Apr 20 |
nicklas |
1239 |
lib.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(createEvent.getEntryDate())); |
5895 |
14 Apr 20 |
nicklas |
1240 |
lib.setAnnotation("creationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(createEvent.getEventDate())); |
2050 |
07 Oct 13 |
olle |
1241 |
lib.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1242 |
lib.loadDoNotUseAnnotations(dc, null); |
2050 |
07 Oct 13 |
olle |
1243 |
lib.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
2050 |
07 Oct 13 |
olle |
1244 |
lib.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
5522 |
24 Jun 19 |
nicklas |
1245 |
lib.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
2050 |
07 Oct 13 |
olle |
1246 |
lib.loadAnnotations(dc, "ca_size", Annotationtype.CA_SIZE, null); |
3320 |
11 May 15 |
nicklas |
1247 |
lib.loadAnnotations(dc, "qubitconc", Annotationtype.QUBIT_CONC, null); |
7286 |
15 Aug 23 |
nicklas |
1248 |
lib.loadAnnotations(dc, "quantitconc", Annotationtype.QUANTIT_CONC, null); |
2454 |
23 May 14 |
nicklas |
1249 |
lib.loadAnnotations(dc, "library_molarity_est", Annotationtype.LIBRARY_MOLARITY_EST, null); |
3320 |
11 May 15 |
nicklas |
1250 |
lib.loadAnnotations(dc, "library_size_est", Annotationtype.LIBRARY_SIZE_EST, null); |
2454 |
23 May 14 |
nicklas |
1251 |
lib.loadAnnotations(dc, "library_frac_adpt", Annotationtype.LIBRARY_FRAC_ADPT, null); |
3320 |
11 May 15 |
nicklas |
1252 |
lib.loadAnnotations(dc, "library_conc_est", Annotationtype.LIBRARY_CONC_EST, null); |
7286 |
15 Aug 23 |
nicklas |
1253 |
lib.coalesceInto("conc", "qubitconc", "quantitconc", "library_conc_est"); |
2101 |
25 Oct 13 |
nicklas |
1254 |
lib.setAnnotation("comment", e.getDescription()); |
2103 |
25 Oct 13 |
nicklas |
1255 |
|
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate annotations |
2103 |
25 Oct 13 |
nicklas |
1257 |
BioPlate plate = getBioPlate(e); |
2103 |
25 Oct 13 |
nicklas |
1258 |
if (plate != null) |
2103 |
25 Oct 13 |
nicklas |
1259 |
{ |
3321 |
11 May 15 |
nicklas |
1260 |
boolean isNeoPrep = BioplateType.NEOPREP.load(dc).equals(plate.getBioPlateType()); |
3321 |
11 May 15 |
nicklas |
1261 |
lib.setAnnotation("isNeoPrep", isNeoPrep); |
3321 |
11 May 15 |
nicklas |
1262 |
if (isNeoPrep) |
3321 |
11 May 15 |
nicklas |
1263 |
{ |
3321 |
11 May 15 |
nicklas |
1264 |
Date neoPrepDate = (Date) Annotationtype.NEOPREP_DATE.getAnnotationValue(dc, plate); |
3321 |
11 May 15 |
nicklas |
1265 |
lib.setAnnotation("neoPrepDate", Reggie.CONVERTER_DATE_TO_STRING.convert(neoPrepDate)); |
3321 |
11 May 15 |
nicklas |
1266 |
} |
3321 |
11 May 15 |
nicklas |
1267 |
else |
3321 |
11 May 15 |
nicklas |
1268 |
{ |
3321 |
11 May 15 |
nicklas |
1269 |
Date cleanupDate = (Date) Annotationtype.CLEANUP_DATE.getAnnotationValue(dc, plate); |
3321 |
11 May 15 |
nicklas |
1270 |
lib.setAnnotation("cleanupDate", Reggie.CONVERTER_DATE_TO_STRING.convert(cleanupDate)); |
3321 |
11 May 15 |
nicklas |
1271 |
} |
2103 |
25 Oct 13 |
nicklas |
// Get BioPlate PlateProcessResult annotation |
2103 |
25 Oct 13 |
nicklas |
1273 |
String result = (String) Annotationtype.PLATE_PROCESS_RESULT.getAnnotationValue(dc, plate); |
2103 |
25 Oct 13 |
nicklas |
1274 |
lib.setAnnotation("result", result); |
2103 |
25 Oct 13 |
nicklas |
1275 |
} |
2050 |
07 Oct 13 |
olle |
1276 |
} |
2052 |
09 Oct 13 |
olle |
1277 |
|
5012 |
05 Oct 18 |
nicklas |
1278 |
private void loadPooledLibraryInfo(DbControl dc, PooledLibrary pool, String caseName) |
2052 |
09 Oct 13 |
olle |
1279 |
{ |
5012 |
05 Oct 18 |
nicklas |
1280 |
Extract e = pool.getExtract(); |
2052 |
09 Oct 13 |
olle |
1281 |
BioMaterialEvent created = e.getCreationEvent(); |
2052 |
09 Oct 13 |
olle |
1282 |
|
5012 |
05 Oct 18 |
nicklas |
1283 |
List<Library> libs = Library.getByPool(dc, pool); |
5012 |
05 Oct 18 |
nicklas |
1284 |
JSONArray jsonLibs = new JSONArray(); |
5012 |
05 Oct 18 |
nicklas |
1285 |
for (Library l : libs) |
5012 |
05 Oct 18 |
nicklas |
1286 |
{ |
5012 |
05 Oct 18 |
nicklas |
1287 |
if (l.getName().startsWith(caseName)) jsonLibs.add(l.getName()); |
5012 |
05 Oct 18 |
nicklas |
1288 |
} |
5012 |
05 Oct 18 |
nicklas |
1289 |
pool.setAnnotation("libNames", jsonLibs); |
5012 |
05 Oct 18 |
nicklas |
1290 |
|
5012 |
05 Oct 18 |
nicklas |
1291 |
pool.setAnnotation("registrationDate", Reggie.CONVERTER_DATE_TO_STRING.convert(e.getEntryDate())); |
5012 |
05 Oct 18 |
nicklas |
1292 |
pool.setAnnotation("editable", e.hasPermission(Permission.WRITE)); |
5012 |
05 Oct 18 |
nicklas |
1293 |
pool.setAnnotation("poolDate", Reggie.CONVERTER_DATE_TO_STRING.convert(created.getEventDate())); |
5012 |
05 Oct 18 |
nicklas |
1294 |
pool.setAnnotation("originalQuantity", e.getOriginalQuantity()); |
5012 |
05 Oct 18 |
nicklas |
1295 |
pool.setAnnotation("remainingQuantity", e.getRemainingQuantity()); |
5522 |
24 Jun 19 |
nicklas |
1296 |
pool.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
5012 |
05 Oct 18 |
nicklas |
1297 |
pool.loadAnnotations(dc, "poolMolarity", Annotationtype.POOL_MOLARITY, null); |
5012 |
05 Oct 18 |
nicklas |
1298 |
pool.loadAnnotations(dc, "poolConc", Annotationtype.POOL_CONC, null); |
5012 |
05 Oct 18 |
nicklas |
1299 |
pool.setAnnotation("comment", e.getDescription()); |
2052 |
09 Oct 13 |
olle |
1300 |
} |
2103 |
25 Oct 13 |
nicklas |
1301 |
|
5012 |
05 Oct 18 |
nicklas |
1302 |
private void loadSequencingRunInfo(DbControl dc, SequencingRun sr, String caseName) |
2232 |
17 Feb 14 |
nicklas |
1303 |
{ |
2232 |
17 Feb 14 |
nicklas |
1304 |
DerivedBioAssay dba = sr.getDerivedBioAssay(); |
2232 |
17 Feb 14 |
nicklas |
1305 |
|
2232 |
17 Feb 14 |
nicklas |
1306 |
sr.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
5522 |
24 Jun 19 |
nicklas |
1307 |
sr.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
2232 |
17 Feb 14 |
nicklas |
1308 |
sr.loadAnnotations(dc, "startDate", Annotationtype.SEQUENCING_START, Reggie.CONVERTER_DATE_TO_STRING); |
2232 |
17 Feb 14 |
nicklas |
1309 |
sr.loadAnnotations(dc, "endDate", Annotationtype.SEQUENCING_END, Reggie.CONVERTER_DATE_TO_STRING); |
2232 |
17 Feb 14 |
nicklas |
1310 |
sr.loadAnnotations(dc, "result", Annotationtype.SEQUENCING_RESULT, null); |
2232 |
17 Feb 14 |
nicklas |
1311 |
sr.setAnnotation("comment", dba.getDescription()); |
2232 |
17 Feb 14 |
nicklas |
1312 |
|
2232 |
17 Feb 14 |
nicklas |
1313 |
FlowCell fc = FlowCell.getBySequencingRun(dc, sr); |
2232 |
17 Feb 14 |
nicklas |
1314 |
PhysicalBioAssay pba = fc.getPhysicalBioAssay(); |
2232 |
17 Feb 14 |
nicklas |
1315 |
|
5012 |
05 Oct 18 |
nicklas |
1316 |
Set<String> libNames = new HashSet<>(); |
5012 |
05 Oct 18 |
nicklas |
1317 |
for (PooledLibrary pool : PooledLibrary.getByFlowCell(dc, fc)) |
5012 |
05 Oct 18 |
nicklas |
1318 |
{ |
5012 |
05 Oct 18 |
nicklas |
1319 |
for (Library l : Library.getByPool(dc, pool)) |
5012 |
05 Oct 18 |
nicklas |
1320 |
{ |
5012 |
05 Oct 18 |
nicklas |
1321 |
if (l.getName().startsWith(caseName)) libNames.add(l.getName()); |
5012 |
05 Oct 18 |
nicklas |
1322 |
} |
5012 |
05 Oct 18 |
nicklas |
1323 |
} |
5012 |
05 Oct 18 |
nicklas |
1324 |
JSONArray jsonLibs = new JSONArray(); |
5012 |
05 Oct 18 |
nicklas |
1325 |
jsonLibs.addAll(libNames); |
5012 |
05 Oct 18 |
nicklas |
1326 |
sr.setAnnotation("libNames", jsonLibs); |
5012 |
05 Oct 18 |
nicklas |
1327 |
|
2232 |
17 Feb 14 |
nicklas |
1328 |
fc.setAnnotation("editable", pba.hasPermission(Permission.WRITE)); |
2232 |
17 Feb 14 |
nicklas |
1329 |
fc.loadAnnotations(dc, "clusterDate", Annotationtype.CLUSTER_START, Reggie.CONVERTER_DATE_TO_STRING); |
2232 |
17 Feb 14 |
nicklas |
1330 |
sr.setAnnotation("flowCell", fc.asJSONObject()); |
2232 |
17 Feb 14 |
nicklas |
1331 |
} |
2232 |
17 Feb 14 |
nicklas |
1332 |
|
7308 |
28 Aug 23 |
nicklas |
1333 |
private Pipeline loadMergedInfo(DbControl dc, MergedSequences m) |
2914 |
11 Nov 14 |
nicklas |
1334 |
{ |
2914 |
11 Nov 14 |
nicklas |
1335 |
DerivedBioAssay dba = m.getDerivedBioAssay(); |
2914 |
11 Nov 14 |
nicklas |
1336 |
Job job = dba.getJob(); |
2914 |
11 Nov 14 |
nicklas |
1337 |
m.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
2914 |
11 Nov 14 |
nicklas |
1338 |
m.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1339 |
m.loadDoNotUseAnnotations(dc, null); |
7308 |
28 Aug 23 |
nicklas |
1340 |
Pipeline pipeline = Pipeline.getFromItem(dc, m); |
7308 |
28 Aug 23 |
nicklas |
1341 |
m.setAnnotation("pipeline", pipeline == null ? null : pipeline.getName()); |
6453 |
22 Oct 21 |
nicklas |
1342 |
if (job == null || job.getEnded() != null) |
2914 |
11 Nov 14 |
nicklas |
1343 |
{ |
7308 |
28 Aug 23 |
nicklas |
1344 |
if (pipeline == null || pipeline.isRnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
1345 |
{ |
7308 |
28 Aug 23 |
nicklas |
1346 |
m.loadAnnotations(dc, "PF_READS", Annotationtype.PF_READS, null); |
7308 |
28 Aug 23 |
nicklas |
1347 |
m.loadAnnotations(dc, "PT_READS", Annotationtype.PT_READS, null); |
7308 |
28 Aug 23 |
nicklas |
1348 |
m.loadAnnotations(dc, "ADAPTER_READS", Annotationtype.ADAPTER_READS, null); |
7308 |
28 Aug 23 |
nicklas |
1349 |
} |
7308 |
28 Aug 23 |
nicklas |
1350 |
else if (pipeline.isDnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
1351 |
{ |
7308 |
28 Aug 23 |
nicklas |
1352 |
m.loadAnnotations(dc, "READS", Annotationtype.READS, null); |
7308 |
28 Aug 23 |
nicklas |
1353 |
} |
2914 |
11 Nov 14 |
nicklas |
1354 |
m.loadAnnotations(dc, "result", Annotationtype.ANALYSIS_RESULT, null); |
2914 |
11 Nov 14 |
nicklas |
1355 |
} |
2914 |
11 Nov 14 |
nicklas |
1356 |
m.setAnnotation("comment", dba.getDescription()); |
7308 |
28 Aug 23 |
nicklas |
1357 |
return pipeline; |
2914 |
11 Nov 14 |
nicklas |
1358 |
} |
2914 |
11 Nov 14 |
nicklas |
1359 |
|
7308 |
28 Aug 23 |
nicklas |
1360 |
private Pipeline loadAlignedInfo(DbControl dc, AlignedSequences a) |
2914 |
11 Nov 14 |
nicklas |
1361 |
{ |
2914 |
11 Nov 14 |
nicklas |
1362 |
DerivedBioAssay dba = a.getDerivedBioAssay(); |
2914 |
11 Nov 14 |
nicklas |
1363 |
Job job = dba.getJob(); |
2914 |
11 Nov 14 |
nicklas |
1364 |
a.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
2914 |
11 Nov 14 |
nicklas |
1365 |
a.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1366 |
a.loadDoNotUseAnnotations(dc, null); |
7308 |
28 Aug 23 |
nicklas |
1367 |
Pipeline pipeline = Pipeline.getFromItem(dc, a); |
7308 |
28 Aug 23 |
nicklas |
1368 |
a.setAnnotation("pipeline", pipeline == null ? null : pipeline.getName()); |
4603 |
02 Oct 17 |
nicklas |
1369 |
a.setAnnotation("software", JsonUtil.getSoftwareAsJSON(dba.getSoftware())); |
6453 |
22 Oct 21 |
nicklas |
1370 |
if (job == null || job.getEnded() != null) |
2914 |
11 Nov 14 |
nicklas |
1371 |
{ |
2914 |
11 Nov 14 |
nicklas |
1372 |
a.loadAnnotations(dc, "ALIGNED_PAIRS", Annotationtype.ALIGNED_PAIRS, null); |
2914 |
11 Nov 14 |
nicklas |
1373 |
a.loadAnnotations(dc, "FRACTION_DUPLICATION", Annotationtype.FRACTION_DUPLICATION, null); |
4621 |
16 Nov 17 |
nicklas |
1374 |
a.loadAnnotations(dc, "QC_GENOTYPE_COUNT", Annotationtype.QC_GENOTYPE_COUNT, null); |
4658 |
26 Jan 18 |
nicklas |
1375 |
a.loadAnnotations(dc, "QC_GENOTYPE_HET_PCT", Annotationtype.QC_GENOTYPE_HET_PCT, null); |
2914 |
11 Nov 14 |
nicklas |
1376 |
a.loadAnnotations(dc, "result", Annotationtype.ANALYSIS_RESULT, null); |
4621 |
16 Nov 17 |
nicklas |
1377 |
a.setAnnotation("qcVcf", JsonUtil.loadLinkedItem(dc, dba, "qc_genotype.vcf", Item.FILE, null)); |
7308 |
28 Aug 23 |
nicklas |
1378 |
if (pipeline != null && pipeline.isDnaPipeline()) |
7308 |
28 Aug 23 |
nicklas |
1379 |
{ |
7308 |
28 Aug 23 |
nicklas |
1380 |
a.loadAnnotations(dc, "MEAN_COVERAGE", Annotationtype.MEAN_COVERAGE, null); |
7308 |
28 Aug 23 |
nicklas |
1381 |
a.loadAnnotations(dc, "SD_COVERAGE", Annotationtype.SD_COVERAGE, null); |
7308 |
28 Aug 23 |
nicklas |
1382 |
a.loadAnnotations(dc, "FRACTION_OPTICAL_DUPLICATION", Annotationtype.FRACTION_OPTICAL_DUPLICATION, null); |
7308 |
28 Aug 23 |
nicklas |
1383 |
} |
2914 |
11 Nov 14 |
nicklas |
1384 |
} |
2914 |
11 Nov 14 |
nicklas |
1385 |
a.setAnnotation("comment", dba.getDescription()); |
7308 |
28 Aug 23 |
nicklas |
1386 |
return pipeline; |
2914 |
11 Nov 14 |
nicklas |
1387 |
} |
2914 |
11 Nov 14 |
nicklas |
1388 |
|
7296 |
23 Aug 23 |
nicklas |
1389 |
private void loadCopyNumberInfo(DbControl dc, CopyNumber cn) |
7296 |
23 Aug 23 |
nicklas |
1390 |
{ |
7296 |
23 Aug 23 |
nicklas |
1391 |
DerivedBioAssay dba = cn.getDerivedBioAssay(); |
7296 |
23 Aug 23 |
nicklas |
1392 |
Job job = dba.getJob(); |
7296 |
23 Aug 23 |
nicklas |
1393 |
cn.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
7296 |
23 Aug 23 |
nicklas |
1394 |
cn.setAnnotation("editable", dba.hasPermission(Permission.WRITE)); |
7296 |
23 Aug 23 |
nicklas |
1395 |
cn.loadDoNotUseAnnotations(dc, null); |
7296 |
23 Aug 23 |
nicklas |
1396 |
cn.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
7296 |
23 Aug 23 |
nicklas |
1397 |
cn.setAnnotation("software", JsonUtil.getSoftwareAsJSON(dba.getSoftware())); |
7341 |
11 Sep 23 |
nicklas |
1398 |
cn.loadAnnotations(dc, "ImbalanceTest", Annotationtype.IMBALANCE_TEST, null); |
7341 |
11 Sep 23 |
nicklas |
1399 |
cn.loadAnnotations(dc, "Penalty", Annotationtype.PENALTY, null); |
7341 |
11 Sep 23 |
nicklas |
1400 |
cn.loadAnnotations(dc, "MinDepth", Annotationtype.MIN_DEPTH, null); |
7341 |
11 Sep 23 |
nicklas |
1401 |
cn.loadAnnotations(dc, "TauManual", Annotationtype.TAU_MANUAL, null); |
7341 |
11 Sep 23 |
nicklas |
1402 |
cn.loadAnnotations(dc, "RhoManual", Annotationtype.RHO_MANUAL, null); |
7341 |
11 Sep 23 |
nicklas |
1403 |
cn.loadAnnotations(dc, "PsiManual", Annotationtype.PSI_MANUAL, null); |
7296 |
23 Aug 23 |
nicklas |
1404 |
if (job == null || job.getEnded() != null) |
7296 |
23 Aug 23 |
nicklas |
1405 |
{ |
7296 |
23 Aug 23 |
nicklas |
1406 |
cn.loadAnnotations(dc, "Ploidy", Annotationtype.PLOIDY, null); |
7296 |
23 Aug 23 |
nicklas |
1407 |
cn.loadAnnotations(dc, "Purity", Annotationtype.PURITY, null); |
7296 |
23 Aug 23 |
nicklas |
1408 |
cn.loadAnnotations(dc, "GoodnessOfFit", Annotationtype.GOODNESS_OF_FIT, null); |
7296 |
23 Aug 23 |
nicklas |
1409 |
cn.loadAnnotations(dc, "NormalContamination", Annotationtype.NORMAL_CONTAMINATION, null); |
7341 |
11 Sep 23 |
nicklas |
1410 |
cn.loadAnnotations(dc, "NonAberrant", Annotationtype.NON_ABERRANT, null); |
7296 |
23 Aug 23 |
nicklas |
1411 |
cn.loadAnnotations(dc, "AscatResult", Annotationtype.ASCAT_RESULT, null); |
7296 |
23 Aug 23 |
nicklas |
1412 |
cn.loadAnnotations(dc, "result", Annotationtype.ANALYSIS_RESULT, null); |
7296 |
23 Aug 23 |
nicklas |
1413 |
cn.setAnnotation("sunrisePlot", JsonUtil.loadLinkedItem(dc, dba, "sunrise.png", Item.FILE, null)); |
7296 |
23 Aug 23 |
nicklas |
1414 |
cn.setAnnotation("ascatProfile", JsonUtil.loadLinkedItem(dc, dba, "ASCATprofile.png", Item.FILE, null)); |
7296 |
23 Aug 23 |
nicklas |
1415 |
cn.setAnnotation("segmentationPlot", JsonUtil.loadLinkedItem(dc, dba, "ASPCF.png", Item.FILE, null)); |
7296 |
23 Aug 23 |
nicklas |
1416 |
} |
7296 |
23 Aug 23 |
nicklas |
1417 |
cn.setAnnotation("comment", dba.getDescription()); |
7296 |
23 Aug 23 |
nicklas |
1418 |
} |
7296 |
23 Aug 23 |
nicklas |
1419 |
|
7296 |
23 Aug 23 |
nicklas |
1420 |
|
2918 |
11 Nov 14 |
nicklas |
1421 |
private void loadRawBioAssayInfo(DbControl dc, Rawbioassay raw) |
2918 |
11 Nov 14 |
nicklas |
1422 |
{ |
2918 |
11 Nov 14 |
nicklas |
1423 |
RawBioAssay rba = raw.getRawBioAssay(); |
2918 |
11 Nov 14 |
nicklas |
1424 |
Job job = rba.getJob(); |
4674 |
08 Feb 18 |
nicklas |
1425 |
raw.setAnnotation("rawDataType", rba.getRawDataType().getName()); |
5548 |
08 Aug 19 |
nicklas |
1426 |
raw.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
2918 |
11 Nov 14 |
nicklas |
1427 |
raw.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
2918 |
11 Nov 14 |
nicklas |
1428 |
raw.setAnnotation("editable", rba.hasPermission(Permission.WRITE)); |
5009 |
04 Oct 18 |
nicklas |
1429 |
raw.loadDoNotUseAnnotations(dc, null); |
6453 |
22 Oct 21 |
nicklas |
1430 |
if (job == null || job.getEnded() != null) |
2918 |
11 Nov 14 |
nicklas |
1431 |
{ |
2918 |
11 Nov 14 |
nicklas |
1432 |
raw.loadAnnotations(dc, "result", Annotationtype.ANALYSIS_RESULT, null); |
3534 |
08 Oct 15 |
nicklas |
1433 |
XmlConfig cfg = Reggie.getConfig(); |
3810 |
23 Mar 16 |
nicklas |
1434 |
raw.setAnnotation("geneReport", JsonUtil.loadLinkedItem(dc, rba, cfg.getConfig("rscript/gene-report/pdf-name", null, GeneReportWorker.DEFAULT_PDF_NAME), Item.FILE, null)); |
3810 |
23 Mar 16 |
nicklas |
1435 |
raw.setAnnotation("pilotReport", JsonUtil.loadLinkedItem(dc, rba, cfg.getConfig("rscript/pilot-report/pdf-name", null, PilotReportWorker.DEFAULT_PDF_NAME), Item.FILE, null)); |
6094 |
14 Dec 20 |
nicklas |
1436 |
raw.setAnnotation("scanbReport", JsonUtil.loadLinkedItem(dc, rba, cfg.getConfig("rscript/scanb-report/pdf-name", null, ScanBReportWorker.DEFAULT_PDF_NAME), Item.FILE, null)); |
2918 |
11 Nov 14 |
nicklas |
1437 |
} |
2918 |
11 Nov 14 |
nicklas |
1438 |
raw.setAnnotation("comment", rba.getDescription()); |
2918 |
11 Nov 14 |
nicklas |
1439 |
} |
2918 |
11 Nov 14 |
nicklas |
1440 |
|
2918 |
11 Nov 14 |
nicklas |
1441 |
|
7411 |
10 Nov 23 |
nicklas |
1442 |
private Pipeline loadVariantCallingInfo(DbControl dc, Rawbioassay raw) |
5731 |
19 Nov 19 |
nicklas |
1443 |
{ |
5731 |
19 Nov 19 |
nicklas |
1444 |
RawBioAssay rba = raw.getRawBioAssay(); |
5731 |
19 Nov 19 |
nicklas |
1445 |
Job job = rba.getJob(); |
5731 |
19 Nov 19 |
nicklas |
1446 |
raw.setAnnotation("rawDataType", rba.getRawDataType().getName()); |
5731 |
19 Nov 19 |
nicklas |
1447 |
raw.setAnnotation("job", JsonUtil.getJobAsJSON(job)); |
5731 |
19 Nov 19 |
nicklas |
1448 |
raw.setAnnotation("editable", rba.hasPermission(Permission.WRITE)); |
5731 |
19 Nov 19 |
nicklas |
1449 |
raw.loadDoNotUseAnnotations(dc, null); |
7411 |
10 Nov 23 |
nicklas |
1450 |
Pipeline pipeline = Pipeline.getFromItem(dc, raw); |
7411 |
10 Nov 23 |
nicklas |
1451 |
raw.setAnnotation("pipeline", pipeline == null ? null : pipeline.getName()); |
7440 |
16 Nov 23 |
nicklas |
1452 |
raw.loadAnnotations(dc, "PanelOfNormals", Annotationtype.PANEL_OF_NORMALS, null); |
6453 |
22 Oct 21 |
nicklas |
1453 |
if (job == null || job.getEnded() != null) |
5731 |
19 Nov 19 |
nicklas |
1454 |
{ |
5731 |
19 Nov 19 |
nicklas |
1455 |
raw.loadAnnotations(dc, "result", Annotationtype.ANALYSIS_RESULT, null); |
5731 |
19 Nov 19 |
nicklas |
1456 |
raw.loadAnnotations(dc, "VariantsPassedFilter", Annotationtype.VARIANTS_PASSED_FILTER, null); |
7411 |
10 Nov 23 |
nicklas |
1457 |
raw.loadAnnotations(dc, "CallableBases", Annotationtype.CALLABLE_BASES, null); |
5731 |
19 Nov 19 |
nicklas |
1458 |
File vcf = raw.getFile(dc, Datafiletype.VCF); |
5731 |
19 Nov 19 |
nicklas |
1459 |
if (vcf != null) raw.setAnnotation("vcfFile", JsonUtil.getFileAsJSON(vcf)); |
6393 |
16 Sep 21 |
nicklas |
1460 |
|
7411 |
10 Nov 23 |
nicklas |
1461 |
if (pipeline != null && pipeline.isRnaPipeline()) |
6393 |
16 Sep 21 |
nicklas |
1462 |
{ |
7411 |
10 Nov 23 |
nicklas |
1463 |
ItemQuery<AnyToAny> query = AnyToAny.getLinksFrom(raw.getItem()); |
7411 |
10 Nov 23 |
nicklas |
1464 |
query.restrict(Restrictions.like(Hql.property("name"), Expressions.string("genotype_%.vcf"))); |
7411 |
10 Nov 23 |
nicklas |
1465 |
query.restrict(Restrictions.eq(Hql.property("toType"), Expressions.integer(Item.FILE.getValue()))); |
7411 |
10 Nov 23 |
nicklas |
1466 |
query.order(Orders.asc(Hql.property("name"))); |
7411 |
10 Nov 23 |
nicklas |
1467 |
JSONArray jsonTargeted = new JSONArray(); |
7411 |
10 Nov 23 |
nicklas |
1468 |
for (AnyToAny vcfLink : query.list(dc)) |
6393 |
16 Sep 21 |
nicklas |
1469 |
{ |
7411 |
10 Nov 23 |
nicklas |
1470 |
File gtVcf = (File)vcfLink.getTo(); |
7411 |
10 Nov 23 |
nicklas |
1471 |
String target = (String)Annotationtype.TARGETED_GENOTYPE.getAnnotationValue(dc, gtVcf); |
7411 |
10 Nov 23 |
nicklas |
1472 |
TargetedGenotypeDefinition targetDef = TargetedGenotypeJobCreator.getTargetByName(target); |
7411 |
10 Nov 23 |
nicklas |
1473 |
JSONObject jsonGtVcf = JsonUtil.getFileAsJSON(gtVcf); |
7411 |
10 Nov 23 |
nicklas |
1474 |
jsonGtVcf.put("TargetedGenotype", target); |
7411 |
10 Nov 23 |
nicklas |
1475 |
if (targetDef != null) |
7411 |
10 Nov 23 |
nicklas |
1476 |
{ |
7411 |
10 Nov 23 |
nicklas |
1477 |
jsonGtVcf.put("TargetedGenotypeDescription", targetDef.getDescription()); |
7411 |
10 Nov 23 |
nicklas |
1478 |
} |
7411 |
10 Nov 23 |
nicklas |
1479 |
jsonGtVcf.put("NumTargetedGenotypes", Annotationtype.NUM_TARGETED_GENOTYPES.getAnnotationValue(dc, gtVcf)); |
7411 |
10 Nov 23 |
nicklas |
1480 |
jsonGtVcf.put("NumTargetedVariants", Annotationtype.NUM_TARGETED_VARIANTS.getAnnotationValue(dc, gtVcf)); |
7411 |
10 Nov 23 |
nicklas |
1481 |
jsonTargeted.add(jsonGtVcf); |
6393 |
16 Sep 21 |
nicklas |
1482 |
} |
7411 |
10 Nov 23 |
nicklas |
1483 |
raw.setAnnotation("targetedGenotyping", jsonTargeted); |
6393 |
16 Sep 21 |
nicklas |
1484 |
} |
5731 |
19 Nov 19 |
nicklas |
1485 |
} |
5731 |
19 Nov 19 |
nicklas |
1486 |
raw.setAnnotation("comment", rba.getDescription()); |
7411 |
10 Nov 23 |
nicklas |
1487 |
return pipeline; |
5731 |
19 Nov 19 |
nicklas |
1488 |
} |
5731 |
19 Nov 19 |
nicklas |
1489 |
|
2918 |
11 Nov 14 |
nicklas |
1490 |
|
2103 |
25 Oct 13 |
nicklas |
1491 |
private BioPlate getBioPlate(MeasuredBioMaterial bioMaterial) |
2103 |
25 Oct 13 |
nicklas |
1492 |
{ |
2103 |
25 Oct 13 |
nicklas |
1493 |
BioWell well = bioMaterial.getBioWell(); |
2103 |
25 Oct 13 |
nicklas |
1494 |
return well == null ? null : well.getPlate(); |
2103 |
25 Oct 13 |
nicklas |
1495 |
} |
2103 |
25 Oct 13 |
nicklas |
1496 |
|
1821 |
06 Feb 13 |
nicklas |
1497 |
} |