6813 |
25 Aug 22 |
nicklas |
1 |
package net.sf.basedb.reggie.servlet; |
6813 |
25 Aug 22 |
nicklas |
2 |
|
6813 |
25 Aug 22 |
nicklas |
3 |
import java.io.IOException; |
6813 |
25 Aug 22 |
nicklas |
4 |
import java.util.ArrayList; |
6813 |
25 Aug 22 |
nicklas |
5 |
import java.util.List; |
6813 |
25 Aug 22 |
nicklas |
6 |
|
6813 |
25 Aug 22 |
nicklas |
7 |
import javax.servlet.ServletException; |
6813 |
25 Aug 22 |
nicklas |
8 |
import javax.servlet.http.HttpServlet; |
6813 |
25 Aug 22 |
nicklas |
9 |
import javax.servlet.http.HttpServletRequest; |
6813 |
25 Aug 22 |
nicklas |
10 |
import javax.servlet.http.HttpServletResponse; |
6813 |
25 Aug 22 |
nicklas |
11 |
|
6813 |
25 Aug 22 |
nicklas |
12 |
import org.json.simple.JSONArray; |
6813 |
25 Aug 22 |
nicklas |
13 |
import org.json.simple.JSONObject; |
6813 |
25 Aug 22 |
nicklas |
14 |
|
6813 |
25 Aug 22 |
nicklas |
15 |
import net.sf.basedb.core.ItemList; |
6814 |
26 Aug 22 |
nicklas |
16 |
import net.sf.basedb.core.ItemNotFoundException; |
6815 |
26 Aug 22 |
nicklas |
17 |
import net.sf.basedb.core.BasicItem; |
6813 |
25 Aug 22 |
nicklas |
18 |
import net.sf.basedb.core.DbControl; |
6813 |
25 Aug 22 |
nicklas |
19 |
import net.sf.basedb.core.DerivedBioAssay; |
6815 |
26 Aug 22 |
nicklas |
20 |
import net.sf.basedb.core.Extract; |
6815 |
26 Aug 22 |
nicklas |
21 |
import net.sf.basedb.core.Item; |
6813 |
25 Aug 22 |
nicklas |
22 |
import net.sf.basedb.core.ItemQuery; |
6814 |
26 Aug 22 |
nicklas |
23 |
import net.sf.basedb.core.Job; |
6814 |
26 Aug 22 |
nicklas |
24 |
import net.sf.basedb.core.Protocol; |
6813 |
25 Aug 22 |
nicklas |
25 |
import net.sf.basedb.core.SessionControl; |
6814 |
26 Aug 22 |
nicklas |
26 |
import net.sf.basedb.core.Software; |
6815 |
26 Aug 22 |
nicklas |
27 |
import net.sf.basedb.core.Trashcan; |
6815 |
26 Aug 22 |
nicklas |
28 |
import net.sf.basedb.core.query.Annotations; |
6815 |
26 Aug 22 |
nicklas |
29 |
import net.sf.basedb.core.query.Expressions; |
6813 |
25 Aug 22 |
nicklas |
30 |
import net.sf.basedb.core.query.Hql; |
6813 |
25 Aug 22 |
nicklas |
31 |
import net.sf.basedb.core.query.Orders; |
6815 |
26 Aug 22 |
nicklas |
32 |
import net.sf.basedb.core.query.Restrictions; |
6813 |
25 Aug 22 |
nicklas |
33 |
import net.sf.basedb.core.snapshot.SnapshotManager; |
6814 |
26 Aug 22 |
nicklas |
34 |
import net.sf.basedb.opengrid.JobDefinition; |
6814 |
26 Aug 22 |
nicklas |
35 |
import net.sf.basedb.opengrid.OpenGridCluster; |
6814 |
26 Aug 22 |
nicklas |
36 |
import net.sf.basedb.opengrid.service.OpenGridService; |
6813 |
25 Aug 22 |
nicklas |
37 |
import net.sf.basedb.reggie.JsonUtil; |
6813 |
25 Aug 22 |
nicklas |
38 |
import net.sf.basedb.reggie.Reggie; |
6815 |
26 Aug 22 |
nicklas |
39 |
import net.sf.basedb.reggie.activity.ActivityDef; |
6815 |
26 Aug 22 |
nicklas |
40 |
import net.sf.basedb.reggie.autoconfirm.HisatAlignAutoConfirmer; |
6813 |
25 Aug 22 |
nicklas |
41 |
import net.sf.basedb.reggie.counter.CounterService; |
6815 |
26 Aug 22 |
nicklas |
42 |
import net.sf.basedb.reggie.dao.AlignedSequences; |
6813 |
25 Aug 22 |
nicklas |
43 |
import net.sf.basedb.reggie.dao.Annotationtype; |
6813 |
25 Aug 22 |
nicklas |
44 |
import net.sf.basedb.reggie.dao.BiomaterialList; |
6813 |
25 Aug 22 |
nicklas |
45 |
import net.sf.basedb.reggie.dao.Library; |
6815 |
26 Aug 22 |
nicklas |
46 |
import net.sf.basedb.reggie.dao.MaskedSequences; |
6813 |
25 Aug 22 |
nicklas |
47 |
import net.sf.basedb.reggie.dao.MergedSequences; |
6815 |
26 Aug 22 |
nicklas |
48 |
import net.sf.basedb.reggie.dao.Pipeline; |
6814 |
26 Aug 22 |
nicklas |
49 |
import net.sf.basedb.reggie.dao.ReggieRole; |
6813 |
25 Aug 22 |
nicklas |
50 |
import net.sf.basedb.reggie.dao.Rna; |
6813 |
25 Aug 22 |
nicklas |
51 |
import net.sf.basedb.reggie.dao.Subtype; |
6814 |
26 Aug 22 |
nicklas |
52 |
import net.sf.basedb.reggie.grid.Hisat2023AlignJobCreator; |
6814 |
26 Aug 22 |
nicklas |
53 |
import net.sf.basedb.reggie.grid.ScriptUtil; |
6813 |
25 Aug 22 |
nicklas |
54 |
import net.sf.basedb.util.Values; |
6813 |
25 Aug 22 |
nicklas |
55 |
import net.sf.basedb.util.error.ThrowableUtil; |
6813 |
25 Aug 22 |
nicklas |
56 |
|
6813 |
25 Aug 22 |
nicklas |
57 |
|
6813 |
25 Aug 22 |
nicklas |
58 |
public class Hisat2023Servlet |
6813 |
25 Aug 22 |
nicklas |
59 |
extends HttpServlet |
6813 |
25 Aug 22 |
nicklas |
60 |
{ |
6814 |
26 Aug 22 |
nicklas |
61 |
|
6814 |
26 Aug 22 |
nicklas |
62 |
private static final long serialVersionUID = 6297449181470540649L; |
6813 |
25 Aug 22 |
nicklas |
63 |
|
6813 |
25 Aug 22 |
nicklas |
64 |
public Hisat2023Servlet() |
6813 |
25 Aug 22 |
nicklas |
65 |
{} |
6813 |
25 Aug 22 |
nicklas |
66 |
|
6813 |
25 Aug 22 |
nicklas |
67 |
@Override |
6813 |
25 Aug 22 |
nicklas |
68 |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) |
6813 |
25 Aug 22 |
nicklas |
69 |
throws ServletException, IOException |
6813 |
25 Aug 22 |
nicklas |
70 |
{ |
6813 |
25 Aug 22 |
nicklas |
71 |
String cmd = req.getParameter("cmd"); |
6813 |
25 Aug 22 |
nicklas |
72 |
JsonUtil.setJsonResponseHeaders(resp); |
6813 |
25 Aug 22 |
nicklas |
73 |
|
6813 |
25 Aug 22 |
nicklas |
74 |
JSONObject json = new JSONObject(); |
6813 |
25 Aug 22 |
nicklas |
75 |
json.put("status", "ok"); |
6813 |
25 Aug 22 |
nicklas |
76 |
|
6813 |
25 Aug 22 |
nicklas |
77 |
final SessionControl sc = Reggie.getSessionControl(req); |
6813 |
25 Aug 22 |
nicklas |
78 |
DbControl dc = null; |
6813 |
25 Aug 22 |
nicklas |
79 |
try |
6813 |
25 Aug 22 |
nicklas |
80 |
{ |
6813 |
25 Aug 22 |
nicklas |
81 |
if ("GetMergedSequencesForHisat2023".equals(cmd)) |
6813 |
25 Aug 22 |
nicklas |
82 |
{ |
6813 |
25 Aug 22 |
nicklas |
83 |
dc = sc.newDbControl(":Start Hisat/2023 alignment"); |
6813 |
25 Aug 22 |
nicklas |
84 |
|
6813 |
25 Aug 22 |
nicklas |
85 |
List<MergedSequences> list = null; |
6813 |
25 Aug 22 |
nicklas |
86 |
String items = Values.getStringOrNull(req.getParameter("items")); |
6813 |
25 Aug 22 |
nicklas |
87 |
if (items == null) |
6813 |
25 Aug 22 |
nicklas |
88 |
{ |
6813 |
25 Aug 22 |
nicklas |
// Load items from the pipeline list |
6813 |
25 Aug 22 |
nicklas |
90 |
ItemList hisatPipeline = BiomaterialList.HISAT_2023_PIPELINE.load(dc); |
6813 |
25 Aug 22 |
nicklas |
91 |
ItemQuery<DerivedBioAssay> query = hisatPipeline.getMembers(); |
6813 |
25 Aug 22 |
nicklas |
92 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6813 |
25 Aug 22 |
nicklas |
93 |
Subtype.MERGED_SEQUENCES.addFilter(dc, query); |
6813 |
25 Aug 22 |
nicklas |
// Join LibPlate for sorting |
6813 |
25 Aug 22 |
nicklas |
95 |
query.join(Hql.innerJoin(null, "extract", "lib", true)); |
6813 |
25 Aug 22 |
nicklas |
96 |
query.join(Hql.innerJoin("lib", "bioWell", "bw", true)); |
6813 |
25 Aug 22 |
nicklas |
97 |
query.join(Hql.innerJoin("bw", "bioPlate", "libPlate", true)); |
6813 |
25 Aug 22 |
nicklas |
98 |
query.order(Orders.asc(Hql.property("libPlate", "id"))); |
6813 |
25 Aug 22 |
nicklas |
99 |
query.order(Orders.asc(Hql.property("name"))); |
6813 |
25 Aug 22 |
nicklas |
100 |
query.setMaxResults(250); |
6813 |
25 Aug 22 |
nicklas |
101 |
list = MergedSequences.toList(query.list(dc)); |
6813 |
25 Aug 22 |
nicklas |
102 |
} |
6813 |
25 Aug 22 |
nicklas |
103 |
else |
6813 |
25 Aug 22 |
nicklas |
104 |
{ |
6813 |
25 Aug 22 |
nicklas |
105 |
Integer[] ids = Values.getInt(items.split(",")); |
6813 |
25 Aug 22 |
nicklas |
106 |
list = new ArrayList<MergedSequences>(); |
6813 |
25 Aug 22 |
nicklas |
107 |
for (Integer id : ids) |
6813 |
25 Aug 22 |
nicklas |
108 |
{ |
6813 |
25 Aug 22 |
nicklas |
109 |
list.add(MergedSequences.getById(dc, id)); |
6813 |
25 Aug 22 |
nicklas |
110 |
} |
6813 |
25 Aug 22 |
nicklas |
111 |
} |
6813 |
25 Aug 22 |
nicklas |
112 |
|
6813 |
25 Aug 22 |
nicklas |
113 |
SnapshotManager manager = new SnapshotManager(); |
6813 |
25 Aug 22 |
nicklas |
114 |
JSONArray jsonMergedSequences = new JSONArray(); |
6813 |
25 Aug 22 |
nicklas |
115 |
for (MergedSequences ms : list) |
6813 |
25 Aug 22 |
nicklas |
116 |
{ |
6813 |
25 Aug 22 |
nicklas |
117 |
ms.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null); |
6813 |
25 Aug 22 |
nicklas |
118 |
Library lib = ms.getLibrary(dc); |
6813 |
25 Aug 22 |
nicklas |
119 |
lib.loadBioPlateLocation(); |
6813 |
25 Aug 22 |
nicklas |
120 |
Rna r = lib.getRna(dc, true); |
6813 |
25 Aug 22 |
nicklas |
121 |
if (r != null) lib.setAnnotation("specimen", r.loadYellowLabelInfo(dc, manager)); |
6813 |
25 Aug 22 |
nicklas |
122 |
ms.setAnnotation("lib", lib.asJSONObject()); |
6813 |
25 Aug 22 |
nicklas |
123 |
ms.loadAnnotations(dc, manager, "AutoProcess", Annotationtype.AUTO_PROCESSING, null); |
6813 |
25 Aug 22 |
nicklas |
124 |
ms.loadDoNotUseAnnotations(dc, manager); |
6813 |
25 Aug 22 |
nicklas |
125 |
jsonMergedSequences.add(ms.asJSONObject()); |
6813 |
25 Aug 22 |
nicklas |
126 |
} |
6813 |
25 Aug 22 |
nicklas |
127 |
json.put("mergedSequences", jsonMergedSequences); |
6813 |
25 Aug 22 |
nicklas |
128 |
} |
6815 |
26 Aug 22 |
nicklas |
129 |
else if ("GetUnconfirmedAlignedSequences".equals(cmd)) |
6815 |
26 Aug 22 |
nicklas |
130 |
{ |
6815 |
26 Aug 22 |
nicklas |
131 |
dc = sc.newDbControl(":Confirm Hisat/2023 alignment"); |
6815 |
26 Aug 22 |
nicklas |
132 |
ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); |
6815 |
26 Aug 22 |
nicklas |
133 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6815 |
26 Aug 22 |
nicklas |
134 |
Subtype.ALIGNED_SEQUENCES.addFilter(dc, query); |
6815 |
26 Aug 22 |
nicklas |
135 |
Pipeline.RNASEQ_HISAT_2023.addFilter(dc, query); |
6815 |
26 Aug 22 |
nicklas |
// The job must be a HisatAlign job and it must be ended |
6815 |
26 Aug 22 |
nicklas |
137 |
query.join(Hql.innerJoin("job", "jb")); |
6815 |
26 Aug 22 |
nicklas |
138 |
Subtype.HISAT_ALIGN_JOB.addFilter(dc, query, "jb"); |
6815 |
26 Aug 22 |
nicklas |
139 |
query.restrict(Restrictions.neq(Hql.property("jb", "ended"), null)); |
6815 |
26 Aug 22 |
nicklas |
// Must NOT have a ANALYSIS_RESULT annotation |
6815 |
26 Aug 22 |
nicklas |
141 |
query.join(Annotations.leftJoin(null, Annotationtype.ANALYSIS_RESULT.load(dc), "ar")); |
6815 |
26 Aug 22 |
nicklas |
142 |
query.restrict(Restrictions.eq(Hql.alias("ar"), null)); |
6815 |
26 Aug 22 |
nicklas |
// Ignore if AutoProcess==AutoConfirm |
6815 |
26 Aug 22 |
nicklas |
144 |
query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap")); |
6815 |
26 Aug 22 |
nicklas |
145 |
query.restrict( |
6815 |
26 Aug 22 |
nicklas |
146 |
Restrictions.or( |
6815 |
26 Aug 22 |
nicklas |
147 |
Restrictions.neq(Hql.alias("ap"), Expressions.string("AutoConfirm")), |
6815 |
26 Aug 22 |
nicklas |
148 |
Restrictions.eq(Hql.alias("ap"), null) |
6815 |
26 Aug 22 |
nicklas |
149 |
)); |
6815 |
26 Aug 22 |
nicklas |
// Join LibPlate for sorting |
6815 |
26 Aug 22 |
nicklas |
151 |
query.join(Hql.innerJoin(null, "extract", "lib", true)); |
6815 |
26 Aug 22 |
nicklas |
152 |
query.join(Hql.innerJoin("lib", "bioWell", "bw", true)); |
6815 |
26 Aug 22 |
nicklas |
153 |
query.join(Hql.innerJoin("bw", "bioPlate", "libPlate", true)); |
6815 |
26 Aug 22 |
nicklas |
154 |
query.order(Orders.asc(Hql.property("libPlate", "id"))); |
6815 |
26 Aug 22 |
nicklas |
155 |
query.order(Orders.asc(Hql.property("name"))); |
6815 |
26 Aug 22 |
nicklas |
156 |
query.setMaxResults(250); |
6815 |
26 Aug 22 |
nicklas |
157 |
|
6815 |
26 Aug 22 |
nicklas |
158 |
SnapshotManager manager = new SnapshotManager(); |
6815 |
26 Aug 22 |
nicklas |
159 |
JSONArray jsonAligned = new JSONArray(); |
6815 |
26 Aug 22 |
nicklas |
160 |
List<AlignedSequences> list = AlignedSequences.toList(query.list(dc)); |
6815 |
26 Aug 22 |
nicklas |
161 |
for (AlignedSequences aligned : list) |
6815 |
26 Aug 22 |
nicklas |
162 |
{ |
6815 |
26 Aug 22 |
nicklas |
163 |
aligned.loadAnnotations(dc, manager, "ALIGNED_PAIRS", Annotationtype.ALIGNED_PAIRS, null); |
6815 |
26 Aug 22 |
nicklas |
164 |
aligned.loadAnnotations(dc, manager, "READ_PAIRS_EXAMINED", Annotationtype.READ_PAIRS_EXAMINED, null); |
6815 |
26 Aug 22 |
nicklas |
165 |
aligned.loadAnnotations(dc, manager, "READ_PAIR_DUPLICATES", Annotationtype.READ_PAIR_DUPLICATES, null); |
6815 |
26 Aug 22 |
nicklas |
166 |
aligned.loadAnnotations(dc, manager, "FRACTION_DUPLICATION", Annotationtype.FRACTION_DUPLICATION, null); |
6815 |
26 Aug 22 |
nicklas |
167 |
aligned.loadAnnotations(dc, manager, "QC_GENOTYPE_COUNT", Annotationtype.QC_GENOTYPE_COUNT, null); |
6815 |
26 Aug 22 |
nicklas |
168 |
aligned.loadAnnotations(dc, manager, "QC_GENOTYPE_HET_PCT", Annotationtype.QC_GENOTYPE_HET_PCT, null); |
6815 |
26 Aug 22 |
nicklas |
169 |
aligned.loadAnnotations(dc, manager, "DataFilesFolder", Annotationtype.DATA_FILES_FOLDER, null); |
6815 |
26 Aug 22 |
nicklas |
170 |
|
6815 |
26 Aug 22 |
nicklas |
171 |
aligned.setAnnotation("qcVcf", JsonUtil.loadLinkedItem(dc, aligned.getItem(), "qc_genotype.vcf", Item.FILE, null)); |
6815 |
26 Aug 22 |
nicklas |
172 |
|
6815 |
26 Aug 22 |
nicklas |
// Load job information |
6815 |
26 Aug 22 |
nicklas |
174 |
Job job = aligned.getItem().getJob(); |
6815 |
26 Aug 22 |
nicklas |
175 |
JSONObject jsonJob = JsonUtil.getJobAsJSON(job); |
6815 |
26 Aug 22 |
nicklas |
176 |
aligned.setAnnotation("job", jsonJob); |
6813 |
25 Aug 22 |
nicklas |
177 |
|
6815 |
26 Aug 22 |
nicklas |
178 |
boolean debug = Boolean.TRUE.equals(job.getParameterValue("debug")); |
6815 |
26 Aug 22 |
nicklas |
179 |
jsonJob.put("debug", debug); |
6815 |
26 Aug 22 |
nicklas |
180 |
|
6815 |
26 Aug 22 |
nicklas |
181 |
JSONObject jsonLimits = new JSONObject(); |
6815 |
26 Aug 22 |
nicklas |
182 |
jsonLimits.put("minAlignedPairsFlag", debug ? HisatAlignAutoConfirmer.MIN_ALIGNED_PAIRS_FLAG_DEBUG : HisatAlignAutoConfirmer.MIN_ALIGNED_PAIRS_FLAG); |
6815 |
26 Aug 22 |
nicklas |
183 |
jsonLimits.put("minAlignedPairsStop", debug ? HisatAlignAutoConfirmer.MIN_ALIGNED_PAIRS_STOP_DEBUG : HisatAlignAutoConfirmer.MIN_ALIGNED_PAIRS_STOP); |
6815 |
26 Aug 22 |
nicklas |
184 |
jsonLimits.put("maxHetPct", HisatAlignAutoConfirmer.MAX_HET_PERCENTAGE); |
6815 |
26 Aug 22 |
nicklas |
185 |
jsonJob.put("limits", jsonLimits); |
6815 |
26 Aug 22 |
nicklas |
186 |
|
6815 |
26 Aug 22 |
nicklas |
// Load library information |
6815 |
26 Aug 22 |
nicklas |
188 |
Library lib = aligned.getLibrary(dc); |
6815 |
26 Aug 22 |
nicklas |
189 |
lib.loadBioPlateLocation(); |
6815 |
26 Aug 22 |
nicklas |
190 |
aligned.setAnnotation("lib", lib.asJSONObject()); |
6815 |
26 Aug 22 |
nicklas |
191 |
Rna r = lib.getRna(dc, true); |
6815 |
26 Aug 22 |
nicklas |
192 |
lib.setAnnotation("specimen", r.loadYellowLabelInfo(dc, manager)); |
6815 |
26 Aug 22 |
nicklas |
193 |
|
6815 |
26 Aug 22 |
nicklas |
// Load masked information |
6815 |
26 Aug 22 |
nicklas |
195 |
MaskedSequences masked = aligned.getMaskedSequences(dc); |
6815 |
26 Aug 22 |
nicklas |
196 |
masked.loadAnnotations(dc, manager, "PM_READS", Annotationtype.PM_READS, null); |
6815 |
26 Aug 22 |
nicklas |
197 |
aligned.setAnnotation("masked", masked.asJSONObject()); |
6815 |
26 Aug 22 |
nicklas |
198 |
|
6815 |
26 Aug 22 |
nicklas |
// Load merged information |
6815 |
26 Aug 22 |
nicklas |
200 |
MergedSequences merged = masked.getMergedSequences(dc); |
6815 |
26 Aug 22 |
nicklas |
201 |
merged.loadAnnotations(dc, manager, "PF_READS", Annotationtype.PF_READS, null); |
6815 |
26 Aug 22 |
nicklas |
202 |
merged.loadAnnotations(dc, manager, "PT_READS", Annotationtype.PT_READS, null); |
6815 |
26 Aug 22 |
nicklas |
203 |
aligned.setAnnotation("merged", merged.asJSONObject()); |
6815 |
26 Aug 22 |
nicklas |
204 |
|
6815 |
26 Aug 22 |
nicklas |
205 |
jsonAligned.add(aligned.asJSONObject()); |
6815 |
26 Aug 22 |
nicklas |
206 |
} |
6815 |
26 Aug 22 |
nicklas |
207 |
|
6815 |
26 Aug 22 |
nicklas |
208 |
json.put("alignedSequences", jsonAligned); |
6815 |
26 Aug 22 |
nicklas |
209 |
} |
6813 |
25 Aug 22 |
nicklas |
210 |
} |
6813 |
25 Aug 22 |
nicklas |
211 |
catch (Throwable t) |
6813 |
25 Aug 22 |
nicklas |
212 |
{ |
6813 |
25 Aug 22 |
nicklas |
213 |
t.printStackTrace(); |
6813 |
25 Aug 22 |
nicklas |
214 |
json.clear(); |
6813 |
25 Aug 22 |
nicklas |
215 |
json.put("status", "error"); |
6813 |
25 Aug 22 |
nicklas |
216 |
json.put("message", t.getMessage()); |
6813 |
25 Aug 22 |
nicklas |
217 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
6813 |
25 Aug 22 |
nicklas |
218 |
} |
6813 |
25 Aug 22 |
nicklas |
219 |
finally |
6813 |
25 Aug 22 |
nicklas |
220 |
{ |
6813 |
25 Aug 22 |
nicklas |
221 |
if (dc != null) dc.close(); |
6813 |
25 Aug 22 |
nicklas |
222 |
json.writeJSONString(resp.getWriter()); |
6813 |
25 Aug 22 |
nicklas |
223 |
} |
6813 |
25 Aug 22 |
nicklas |
224 |
|
6813 |
25 Aug 22 |
nicklas |
225 |
} |
6813 |
25 Aug 22 |
nicklas |
226 |
|
6813 |
25 Aug 22 |
nicklas |
227 |
@Override |
6813 |
25 Aug 22 |
nicklas |
228 |
protected void doPost(HttpServletRequest req, HttpServletResponse resp) |
6813 |
25 Aug 22 |
nicklas |
229 |
throws ServletException, IOException |
6813 |
25 Aug 22 |
nicklas |
230 |
{ |
6813 |
25 Aug 22 |
nicklas |
231 |
String cmd = req.getParameter("cmd"); |
6813 |
25 Aug 22 |
nicklas |
232 |
JsonUtil.setJsonResponseHeaders(resp); |
6813 |
25 Aug 22 |
nicklas |
233 |
|
6813 |
25 Aug 22 |
nicklas |
234 |
JSONObject json = new JSONObject(); |
6813 |
25 Aug 22 |
nicklas |
235 |
json.put("status", "ok"); |
6813 |
25 Aug 22 |
nicklas |
236 |
JSONArray jsonMessages = new JSONArray(); |
6813 |
25 Aug 22 |
nicklas |
237 |
|
6813 |
25 Aug 22 |
nicklas |
238 |
final SessionControl sc = Reggie.getSessionControl(req); |
6813 |
25 Aug 22 |
nicklas |
239 |
DbControl dc = null; |
6813 |
25 Aug 22 |
nicklas |
240 |
try |
6813 |
25 Aug 22 |
nicklas |
241 |
{ |
6814 |
26 Aug 22 |
nicklas |
242 |
if ("StartHisat2023Alignment".equals(cmd)) |
6814 |
26 Aug 22 |
nicklas |
243 |
{ |
6814 |
26 Aug 22 |
nicklas |
244 |
dc = sc.newDbControl(":Start Hisat/2023 alignment"); |
6813 |
25 Aug 22 |
nicklas |
245 |
|
6814 |
26 Aug 22 |
nicklas |
246 |
ReggieRole.checkPermission(dc, "'" + cmd + "' wizard", ReggieRole.SECONDARY_ANALYSIS, ReggieRole.ADMINISTRATOR); |
6813 |
25 Aug 22 |
nicklas |
247 |
|
6814 |
26 Aug 22 |
nicklas |
248 |
JSONObject jsonReq = JsonUtil.parseRequest(req); |
6814 |
26 Aug 22 |
nicklas |
249 |
JSONArray jsonMerged = (JSONArray)jsonReq.get("mergedSequences"); |
6814 |
26 Aug 22 |
nicklas |
250 |
|
6814 |
26 Aug 22 |
nicklas |
251 |
Number maskingSoftwareId = (Number)jsonReq.get("maskingSoftware"); |
6814 |
26 Aug 22 |
nicklas |
252 |
Number maskingProtocolId = (Number)jsonReq.get("maskingProtocol"); |
6814 |
26 Aug 22 |
nicklas |
253 |
Number alignSoftwareId = (Number)jsonReq.get("alignSoftware"); |
6814 |
26 Aug 22 |
nicklas |
254 |
Number alignProtocolId = (Number)jsonReq.get("alignProtocol"); |
6814 |
26 Aug 22 |
nicklas |
255 |
|
6814 |
26 Aug 22 |
nicklas |
256 |
String clusterId = (String)jsonReq.get("cluster"); |
6814 |
26 Aug 22 |
nicklas |
257 |
boolean debug = Boolean.TRUE.equals(jsonReq.get("debug")); |
6814 |
26 Aug 22 |
nicklas |
258 |
boolean autoConfirm = Boolean.TRUE.equals(jsonReq.get("autoConfirm")); |
6814 |
26 Aug 22 |
nicklas |
259 |
Number priority = (Number)jsonReq.get("priority"); |
6979 |
16 Jan 23 |
nicklas |
260 |
String partition = Values.getStringOrNull((String)jsonReq.get("partition")); |
7372 |
06 Oct 23 |
nicklas |
261 |
String submitOptions = Values.getStringOrNull((String)jsonReq.get("submitOptionsOverride")); |
6814 |
26 Aug 22 |
nicklas |
262 |
|
6814 |
26 Aug 22 |
nicklas |
263 |
OpenGridCluster cluster = OpenGridService.getInstance().getClusterById(dc, clusterId); |
6814 |
26 Aug 22 |
nicklas |
264 |
if (cluster == null) |
6814 |
26 Aug 22 |
nicklas |
265 |
{ |
6814 |
26 Aug 22 |
nicklas |
266 |
throw new ItemNotFoundException("OpenGridCluster[" + clusterId + "]"); |
6814 |
26 Aug 22 |
nicklas |
267 |
} |
6814 |
26 Aug 22 |
nicklas |
268 |
|
6814 |
26 Aug 22 |
nicklas |
// Load common items |
6814 |
26 Aug 22 |
nicklas |
270 |
Software maskingSoftware = maskingSoftwareId != null ? Software.getById(dc, maskingSoftwareId.intValue()) : null; |
6814 |
26 Aug 22 |
nicklas |
271 |
Protocol maskingProtocol = maskingProtocolId != null ? Protocol.getById(dc, maskingProtocolId.intValue()) : null; |
6814 |
26 Aug 22 |
nicklas |
272 |
Software alignSoftware = alignSoftwareId != null ? Software.getById(dc, alignSoftwareId.intValue()) : null; |
6814 |
26 Aug 22 |
nicklas |
273 |
Protocol alignProtocol = alignProtocolId != null ? Protocol.getById(dc, alignProtocolId.intValue()) : null; |
6814 |
26 Aug 22 |
nicklas |
274 |
|
6814 |
26 Aug 22 |
nicklas |
// Align job creator implementation |
6814 |
26 Aug 22 |
nicklas |
276 |
Hisat2023AlignJobCreator jobCreator = new Hisat2023AlignJobCreator(); |
6814 |
26 Aug 22 |
nicklas |
277 |
jobCreator.setAutoConfirm(autoConfirm); |
6814 |
26 Aug 22 |
nicklas |
278 |
jobCreator.setDebug(debug); |
6814 |
26 Aug 22 |
nicklas |
279 |
jobCreator.setPriority(priority == null ? null : priority.intValue()); |
6979 |
16 Jan 23 |
nicklas |
280 |
jobCreator.setPartition(partition); |
6814 |
26 Aug 22 |
nicklas |
281 |
jobCreator.setMaskingProtocol(maskingProtocol); |
6814 |
26 Aug 22 |
nicklas |
282 |
jobCreator.setMaskingSoftware(maskingSoftware); |
6814 |
26 Aug 22 |
nicklas |
283 |
jobCreator.setAlignProtocol(alignProtocol); |
6814 |
26 Aug 22 |
nicklas |
284 |
jobCreator.setAlignSoftware(alignSoftware); |
7372 |
06 Oct 23 |
nicklas |
285 |
jobCreator.setSubmitOptionsOverride(submitOptions); |
6814 |
26 Aug 22 |
nicklas |
286 |
|
6814 |
26 Aug 22 |
nicklas |
287 |
List<MergedSequences> mergedSequences = new ArrayList<MergedSequences>(); |
6814 |
26 Aug 22 |
nicklas |
288 |
for (int mgNo = 0; mgNo < jsonMerged.size(); mgNo++) |
6814 |
26 Aug 22 |
nicklas |
289 |
{ |
6814 |
26 Aug 22 |
nicklas |
290 |
JSONObject jsonMg = (JSONObject)jsonMerged.get(mgNo); |
6814 |
26 Aug 22 |
nicklas |
291 |
Number mergedId = (Number)jsonMg.get("id"); |
6814 |
26 Aug 22 |
nicklas |
292 |
|
6814 |
26 Aug 22 |
nicklas |
293 |
MergedSequences ms = MergedSequences.getById(dc, mergedId.intValue()); |
6814 |
26 Aug 22 |
nicklas |
294 |
mergedSequences.add(ms); |
6814 |
26 Aug 22 |
nicklas |
295 |
|
6814 |
26 Aug 22 |
nicklas |
// Reset AUTO_PROCESSING annotation |
6814 |
26 Aug 22 |
nicklas |
297 |
DerivedBioAssay merged = ms.getDerivedBioAssay(); |
6814 |
26 Aug 22 |
nicklas |
298 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, merged, null); |
6814 |
26 Aug 22 |
nicklas |
299 |
} |
6814 |
26 Aug 22 |
nicklas |
300 |
|
6814 |
26 Aug 22 |
nicklas |
301 |
List<JobDefinition> jobDefs = jobCreator.createHisatAlignJobs(dc, cluster, mergedSequences); |
6814 |
26 Aug 22 |
nicklas |
302 |
List<Job> jobs = ScriptUtil.submitJobs(dc, cluster, jobDefs); |
6814 |
26 Aug 22 |
nicklas |
303 |
for (Job job : jobs) |
6814 |
26 Aug 22 |
nicklas |
304 |
{ |
6814 |
26 Aug 22 |
nicklas |
305 |
if (job.getStatus() == Job.Status.ERROR) |
6814 |
26 Aug 22 |
nicklas |
306 |
{ |
6814 |
26 Aug 22 |
nicklas |
307 |
jsonMessages.add("[Error]Job submission for '" + job.getName() + "' failed: " + job.getStatusMessage()); |
6814 |
26 Aug 22 |
nicklas |
308 |
} |
6814 |
26 Aug 22 |
nicklas |
309 |
else |
6814 |
26 Aug 22 |
nicklas |
310 |
{ |
6814 |
26 Aug 22 |
nicklas |
311 |
jsonMessages.add("Submitted Hisat/2023 alignment job to " + cluster.getConnectionInfo().getName() + " with id " + job.getExternalId()); |
6814 |
26 Aug 22 |
nicklas |
312 |
} |
6814 |
26 Aug 22 |
nicklas |
313 |
} |
6814 |
26 Aug 22 |
nicklas |
314 |
dc.commit(); |
6814 |
26 Aug 22 |
nicklas |
315 |
} |
6815 |
26 Aug 22 |
nicklas |
316 |
else if ("RegisterHisat2023Alignment".equals(cmd)) |
6815 |
26 Aug 22 |
nicklas |
317 |
{ |
6815 |
26 Aug 22 |
nicklas |
318 |
dc = sc.newDbControl(":Confirm Hisat/2023 alignment"); |
6814 |
26 Aug 22 |
nicklas |
319 |
|
6815 |
26 Aug 22 |
nicklas |
320 |
ReggieRole.checkPermission(dc, "'" + cmd + "' wizard", ReggieRole.SECONDARY_ANALYSIS, ReggieRole.ADMINISTRATOR); |
6815 |
26 Aug 22 |
nicklas |
321 |
|
6815 |
26 Aug 22 |
nicklas |
322 |
JSONObject jsonReq = JsonUtil.parseRequest(req); |
6815 |
26 Aug 22 |
nicklas |
323 |
JSONArray jsonAlignedSequences = (JSONArray)jsonReq.get("alignedSequences"); |
6815 |
26 Aug 22 |
nicklas |
324 |
|
6815 |
26 Aug 22 |
nicklas |
325 |
int numConfirmed = 0; |
6815 |
26 Aug 22 |
nicklas |
326 |
int numUnconfirmed = 0; |
6815 |
26 Aug 22 |
nicklas |
327 |
int numRealign = 0; |
6815 |
26 Aug 22 |
nicklas |
328 |
int numFlaggedRna = 0; |
6815 |
26 Aug 22 |
nicklas |
329 |
int numDeleted = 0; |
6815 |
26 Aug 22 |
nicklas |
330 |
|
6815 |
26 Aug 22 |
nicklas |
331 |
ItemList flaggedRna = BiomaterialList.FLAGGED_RNA.load(dc); |
6815 |
26 Aug 22 |
nicklas |
332 |
ItemList hisatPipeline = BiomaterialList.HISAT_2023_PIPELINE.load(dc); |
6815 |
26 Aug 22 |
nicklas |
333 |
ItemList stringtiePipeline = BiomaterialList.STRINGTIE_2023_PIPELINE.load(dc); |
6815 |
26 Aug 22 |
nicklas |
334 |
|
6815 |
26 Aug 22 |
nicklas |
335 |
boolean deleteItemsCreatedByFailedJobs = Boolean.TRUE.equals(jsonReq.get("deleteItemsCreatedByFailedJobs")); |
6815 |
26 Aug 22 |
nicklas |
336 |
List<BasicItem> toDelete = new ArrayList<BasicItem>(); |
6815 |
26 Aug 22 |
nicklas |
337 |
|
6815 |
26 Aug 22 |
nicklas |
338 |
for (int alignNo = 0; alignNo < jsonAlignedSequences.size(); ++alignNo) |
6815 |
26 Aug 22 |
nicklas |
339 |
{ |
6815 |
26 Aug 22 |
nicklas |
340 |
JSONObject jsonAligned = (JSONObject)jsonAlignedSequences.get(alignNo); |
6815 |
26 Aug 22 |
nicklas |
341 |
Number alignedId = (Number)jsonAligned.get("id"); |
6815 |
26 Aug 22 |
nicklas |
342 |
|
6815 |
26 Aug 22 |
nicklas |
343 |
AlignedSequences aligned = AlignedSequences.getById(dc, alignedId.intValue()); |
6815 |
26 Aug 22 |
nicklas |
344 |
MaskedSequences masked = aligned.getMaskedSequences(dc); |
6815 |
26 Aug 22 |
nicklas |
345 |
MergedSequences merged = masked.getMergedSequences(dc); |
6815 |
26 Aug 22 |
nicklas |
346 |
|
6815 |
26 Aug 22 |
nicklas |
347 |
DerivedBioAssay alignedDBA = aligned.getDerivedBioAssay(); |
6815 |
26 Aug 22 |
nicklas |
348 |
Job alignJob = alignedDBA.getJob(); |
6815 |
26 Aug 22 |
nicklas |
349 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, alignedDBA, null); |
6815 |
26 Aug 22 |
nicklas |
350 |
|
6815 |
26 Aug 22 |
nicklas |
351 |
String flag = (String)(jsonAligned.get("flag")); |
6815 |
26 Aug 22 |
nicklas |
352 |
if (flag != null && !Reggie.isExternalItem(aligned.getName())) |
6815 |
26 Aug 22 |
nicklas |
353 |
{ |
6815 |
26 Aug 22 |
nicklas |
354 |
Library lib = Library.get(alignedDBA.getExtract()); |
6815 |
26 Aug 22 |
nicklas |
355 |
Rna rna = lib.getRna(dc, false); |
6815 |
26 Aug 22 |
nicklas |
356 |
Extract r = rna.getItem(); |
6815 |
26 Aug 22 |
nicklas |
357 |
Annotationtype.FLAG.setAnnotationValue(dc, r, flag); |
6815 |
26 Aug 22 |
nicklas |
358 |
flaggedRna.add(r); |
6815 |
26 Aug 22 |
nicklas |
359 |
numFlaggedRna++; |
6815 |
26 Aug 22 |
nicklas |
360 |
} |
6815 |
26 Aug 22 |
nicklas |
361 |
|
6815 |
26 Aug 22 |
nicklas |
362 |
String comment = Values.getStringOrNull((String)jsonAligned.get("comment")); |
6815 |
26 Aug 22 |
nicklas |
363 |
alignedDBA.setDescription(comment); |
6815 |
26 Aug 22 |
nicklas |
364 |
|
6815 |
26 Aug 22 |
nicklas |
365 |
boolean reAlign = Boolean.TRUE.equals(jsonAligned.get("realign")); |
6815 |
26 Aug 22 |
nicklas |
366 |
boolean startStringTie = Boolean.TRUE.equals(jsonAligned.get("stringtie")); |
6815 |
26 Aug 22 |
nicklas |
367 |
boolean deleted = false; |
6815 |
26 Aug 22 |
nicklas |
368 |
|
6815 |
26 Aug 22 |
nicklas |
369 |
if (reAlign) |
6815 |
26 Aug 22 |
nicklas |
370 |
{ |
6815 |
26 Aug 22 |
nicklas |
// Set ReProcess annotation on merged sequences item |
6815 |
26 Aug 22 |
nicklas |
372 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, merged.getItem(), "ReProcess"); |
6815 |
26 Aug 22 |
nicklas |
373 |
hisatPipeline.add(merged.getItem()); |
6815 |
26 Aug 22 |
nicklas |
374 |
numRealign++; |
6815 |
26 Aug 22 |
nicklas |
375 |
|
6815 |
26 Aug 22 |
nicklas |
376 |
if (deleteItemsCreatedByFailedJobs && alignJob.getStatus() == Job.Status.ERROR) |
6815 |
26 Aug 22 |
nicklas |
377 |
{ |
6815 |
26 Aug 22 |
nicklas |
// Delete aligned sequences items |
6815 |
26 Aug 22 |
nicklas |
379 |
alignedDBA.setRemoved(true); |
6815 |
26 Aug 22 |
nicklas |
380 |
toDelete.add(alignedDBA); |
6815 |
26 Aug 22 |
nicklas |
381 |
toDelete.addAll(Reggie.removeAttachedFiles(dc, alignedDBA)); |
6815 |
26 Aug 22 |
nicklas |
382 |
|
6815 |
26 Aug 22 |
nicklas |
383 |
DerivedBioAssay mask = masked.getItem(); |
6815 |
26 Aug 22 |
nicklas |
384 |
mask.setRemoved(true); |
6815 |
26 Aug 22 |
nicklas |
385 |
toDelete.add(mask); |
6815 |
26 Aug 22 |
nicklas |
386 |
toDelete.addAll(Reggie.removeAttachedFiles(dc, mask)); |
6815 |
26 Aug 22 |
nicklas |
387 |
|
6815 |
26 Aug 22 |
nicklas |
388 |
deleted = true; |
6815 |
26 Aug 22 |
nicklas |
389 |
numDeleted++; |
6815 |
26 Aug 22 |
nicklas |
390 |
if (comment != null) |
6815 |
26 Aug 22 |
nicklas |
391 |
{ |
6815 |
26 Aug 22 |
nicklas |
392 |
merged.getItem().setDescription(comment); |
6815 |
26 Aug 22 |
nicklas |
393 |
} |
6815 |
26 Aug 22 |
nicklas |
394 |
} |
6815 |
26 Aug 22 |
nicklas |
395 |
} |
6815 |
26 Aug 22 |
nicklas |
396 |
|
6815 |
26 Aug 22 |
nicklas |
397 |
if (!deleted) |
6815 |
26 Aug 22 |
nicklas |
398 |
{ |
6815 |
26 Aug 22 |
nicklas |
399 |
if (startStringTie) |
6815 |
26 Aug 22 |
nicklas |
400 |
{ |
6815 |
26 Aug 22 |
nicklas |
401 |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, alignedDBA, AlignedSequences.ALIGN_SUCCESSFUL); |
6815 |
26 Aug 22 |
nicklas |
402 |
stringtiePipeline.add(alignedDBA); |
6815 |
26 Aug 22 |
nicklas |
403 |
numConfirmed++; |
6815 |
26 Aug 22 |
nicklas |
404 |
} |
6815 |
26 Aug 22 |
nicklas |
405 |
else if (reAlign || flag != null) |
6815 |
26 Aug 22 |
nicklas |
406 |
{ |
6815 |
26 Aug 22 |
nicklas |
407 |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, alignedDBA, AlignedSequences.ALIGN_FAILED); |
6815 |
26 Aug 22 |
nicklas |
408 |
} |
6815 |
26 Aug 22 |
nicklas |
409 |
else |
6815 |
26 Aug 22 |
nicklas |
410 |
{ |
6815 |
26 Aug 22 |
nicklas |
411 |
numUnconfirmed++; |
6815 |
26 Aug 22 |
nicklas |
412 |
} |
6815 |
26 Aug 22 |
nicklas |
413 |
} |
6815 |
26 Aug 22 |
nicklas |
414 |
} |
6815 |
26 Aug 22 |
nicklas |
415 |
|
6815 |
26 Aug 22 |
nicklas |
416 |
if (numConfirmed > 0) |
6815 |
26 Aug 22 |
nicklas |
417 |
{ |
6815 |
26 Aug 22 |
nicklas |
418 |
jsonMessages.add(numConfirmed + " libraries confirmed for StringTie/2023"); |
6815 |
26 Aug 22 |
nicklas |
419 |
ActivityDef.HISAT_CONFIRMED.merge(dc, numConfirmed); |
6815 |
26 Aug 22 |
nicklas |
420 |
} |
6815 |
26 Aug 22 |
nicklas |
421 |
else |
6815 |
26 Aug 22 |
nicklas |
422 |
{ |
6815 |
26 Aug 22 |
nicklas |
423 |
jsonMessages.add("No libraries confirmed as aligned"); |
6815 |
26 Aug 22 |
nicklas |
424 |
} |
6815 |
26 Aug 22 |
nicklas |
425 |
|
6815 |
26 Aug 22 |
nicklas |
426 |
if (numRealign > 0) |
6815 |
26 Aug 22 |
nicklas |
427 |
{ |
6815 |
26 Aug 22 |
nicklas |
428 |
jsonMessages.add(numRealign + " libraries flagged for re-alignment"); |
6815 |
26 Aug 22 |
nicklas |
429 |
} |
6815 |
26 Aug 22 |
nicklas |
430 |
|
6815 |
26 Aug 22 |
nicklas |
431 |
if (numDeleted > 0) |
6815 |
26 Aug 22 |
nicklas |
432 |
{ |
6815 |
26 Aug 22 |
nicklas |
433 |
jsonMessages.add(numDeleted + " libraries deleted due to failure"); |
6815 |
26 Aug 22 |
nicklas |
434 |
if (toDelete.size() > numDeleted) |
6815 |
26 Aug 22 |
nicklas |
435 |
{ |
6815 |
26 Aug 22 |
nicklas |
436 |
jsonMessages.add((toDelete.size() - numDeleted) + " linked items (eg. files) deleted"); |
6815 |
26 Aug 22 |
nicklas |
437 |
} |
6815 |
26 Aug 22 |
nicklas |
438 |
} |
6815 |
26 Aug 22 |
nicklas |
439 |
|
6815 |
26 Aug 22 |
nicklas |
440 |
if (numFlaggedRna > 0) |
6815 |
26 Aug 22 |
nicklas |
441 |
{ |
6815 |
26 Aug 22 |
nicklas |
442 |
jsonMessages.add("Added " + numFlaggedRna + " RNA items to the '" + flaggedRna.getName() + "' list"); |
6815 |
26 Aug 22 |
nicklas |
443 |
} |
6815 |
26 Aug 22 |
nicklas |
444 |
|
6815 |
26 Aug 22 |
nicklas |
445 |
if (numUnconfirmed > 0) |
6815 |
26 Aug 22 |
nicklas |
446 |
{ |
6815 |
26 Aug 22 |
nicklas |
447 |
jsonMessages.add(numUnconfirmed + " libraries remain unconfirmed"); |
6815 |
26 Aug 22 |
nicklas |
448 |
} |
6815 |
26 Aug 22 |
nicklas |
449 |
|
6815 |
26 Aug 22 |
nicklas |
450 |
dc.commit(); |
6815 |
26 Aug 22 |
nicklas |
451 |
|
6815 |
26 Aug 22 |
nicklas |
452 |
if (toDelete.size() > 0) |
6815 |
26 Aug 22 |
nicklas |
453 |
{ |
6815 |
26 Aug 22 |
nicklas |
454 |
try |
6815 |
26 Aug 22 |
nicklas |
455 |
{ |
6815 |
26 Aug 22 |
nicklas |
456 |
Trashcan.delete(sc, toDelete, false, null); |
6815 |
26 Aug 22 |
nicklas |
457 |
} |
6815 |
26 Aug 22 |
nicklas |
458 |
catch (RuntimeException ex) |
6815 |
26 Aug 22 |
nicklas |
459 |
{ |
6815 |
26 Aug 22 |
nicklas |
460 |
ex.printStackTrace(); |
6815 |
26 Aug 22 |
nicklas |
461 |
jsonMessages.add("[Error]Could not delete all items created by failed jobs: " + ex.getMessage()); |
6815 |
26 Aug 22 |
nicklas |
462 |
} |
6815 |
26 Aug 22 |
nicklas |
463 |
} |
6815 |
26 Aug 22 |
nicklas |
464 |
} |
6815 |
26 Aug 22 |
nicklas |
465 |
|
6813 |
25 Aug 22 |
nicklas |
466 |
json.put("messages", jsonMessages); |
6813 |
25 Aug 22 |
nicklas |
467 |
CounterService.getInstance().setForceCount(); |
6813 |
25 Aug 22 |
nicklas |
468 |
} |
6813 |
25 Aug 22 |
nicklas |
469 |
catch (Throwable t) |
6813 |
25 Aug 22 |
nicklas |
470 |
{ |
6813 |
25 Aug 22 |
nicklas |
471 |
t.printStackTrace(); |
6813 |
25 Aug 22 |
nicklas |
472 |
json.clear(); |
6813 |
25 Aug 22 |
nicklas |
473 |
json.put("status", "error"); |
6813 |
25 Aug 22 |
nicklas |
474 |
json.put("message", t.getMessage()); |
6813 |
25 Aug 22 |
nicklas |
475 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
6813 |
25 Aug 22 |
nicklas |
476 |
} |
6813 |
25 Aug 22 |
nicklas |
477 |
finally |
6813 |
25 Aug 22 |
nicklas |
478 |
{ |
6813 |
25 Aug 22 |
nicklas |
479 |
if (dc != null) dc.close(); |
6813 |
25 Aug 22 |
nicklas |
480 |
json.writeJSONString(resp.getWriter()); |
6813 |
25 Aug 22 |
nicklas |
481 |
} |
6813 |
25 Aug 22 |
nicklas |
482 |
|
6813 |
25 Aug 22 |
nicklas |
483 |
} |
6813 |
25 Aug 22 |
nicklas |
484 |
|
6813 |
25 Aug 22 |
nicklas |
485 |
|
6813 |
25 Aug 22 |
nicklas |
486 |
|
6813 |
25 Aug 22 |
nicklas |
487 |
} |