4600 |
28 Sep 17 |
nicklas |
1 |
package net.sf.basedb.reggie.autoconfirm; |
4600 |
28 Sep 17 |
nicklas |
2 |
|
4662 |
29 Jan 18 |
nicklas |
3 |
import java.util.Collections; |
4662 |
29 Jan 18 |
nicklas |
4 |
import java.util.List; |
4662 |
29 Jan 18 |
nicklas |
5 |
|
4600 |
28 Sep 17 |
nicklas |
6 |
import org.slf4j.LoggerFactory; |
4600 |
28 Sep 17 |
nicklas |
7 |
|
4662 |
29 Jan 18 |
nicklas |
8 |
import net.sf.basedb.core.Annotatable; |
4600 |
28 Sep 17 |
nicklas |
9 |
import net.sf.basedb.core.DbControl; |
4600 |
28 Sep 17 |
nicklas |
10 |
import net.sf.basedb.core.DerivedBioAssay; |
4660 |
29 Jan 18 |
nicklas |
11 |
import net.sf.basedb.core.ItemList; |
4600 |
28 Sep 17 |
nicklas |
12 |
import net.sf.basedb.core.Job; |
4662 |
29 Jan 18 |
nicklas |
13 |
import net.sf.basedb.core.Protocol; |
4600 |
28 Sep 17 |
nicklas |
14 |
import net.sf.basedb.core.SessionControl; |
4662 |
29 Jan 18 |
nicklas |
15 |
import net.sf.basedb.core.Software; |
4662 |
29 Jan 18 |
nicklas |
16 |
import net.sf.basedb.opengrid.JobDefinition; |
4662 |
29 Jan 18 |
nicklas |
17 |
import net.sf.basedb.opengrid.OpenGridCluster; |
6674 |
11 Apr 22 |
nicklas |
18 |
import net.sf.basedb.opengrid.config.BatchConfig; |
4662 |
29 Jan 18 |
nicklas |
19 |
import net.sf.basedb.opengrid.service.OpenGridService; |
5384 |
26 Apr 19 |
nicklas |
20 |
import net.sf.basedb.reggie.activity.ActivityDef; |
4600 |
28 Sep 17 |
nicklas |
21 |
import net.sf.basedb.reggie.dao.AlignedSequences; |
4600 |
28 Sep 17 |
nicklas |
22 |
import net.sf.basedb.reggie.dao.Annotationtype; |
4662 |
29 Jan 18 |
nicklas |
23 |
import net.sf.basedb.reggie.dao.Arraydesign; |
4660 |
29 Jan 18 |
nicklas |
24 |
import net.sf.basedb.reggie.dao.BiomaterialList; |
6812 |
25 Aug 22 |
nicklas |
25 |
import net.sf.basedb.reggie.dao.Pipeline; |
4667 |
01 Feb 18 |
nicklas |
26 |
import net.sf.basedb.reggie.dao.Rawdatatype; |
4600 |
28 Sep 17 |
nicklas |
27 |
import net.sf.basedb.reggie.dao.Rna; |
4662 |
29 Jan 18 |
nicklas |
28 |
import net.sf.basedb.reggie.dao.Subtype; |
5037 |
17 Oct 18 |
nicklas |
29 |
import net.sf.basedb.reggie.grid.MBafJobCreator; |
4662 |
29 Jan 18 |
nicklas |
30 |
import net.sf.basedb.reggie.grid.ScriptUtil; |
4663 |
29 Jan 18 |
nicklas |
31 |
import net.sf.basedb.reggie.grid.StringTieJobCreator; |
5684 |
25 Oct 19 |
nicklas |
32 |
import net.sf.basedb.reggie.grid.VariantCallingJobCreator; |
7077 |
27 Mar 23 |
nicklas |
33 |
import net.sf.basedb.util.extensions.logging.ExtensionsLog; |
7077 |
27 Mar 23 |
nicklas |
34 |
import net.sf.basedb.util.extensions.logging.ExtensionsLogger; |
4662 |
29 Jan 18 |
nicklas |
35 |
import net.sf.basedb.util.filter.Filter; |
4600 |
28 Sep 17 |
nicklas |
36 |
|
4600 |
28 Sep 17 |
nicklas |
37 |
/** |
4600 |
28 Sep 17 |
nicklas |
Auto-confirm implementation for sequences aligned with Hisat. |
4600 |
28 Sep 17 |
nicklas |
The rules are simple: |
4600 |
28 Sep 17 |
nicklas |
40 |
|
4600 |
28 Sep 17 |
nicklas |
* {@link DerivedBioAssay#getJob()} job status must be {@link net.sf.basedb.core.Job.Status#DONE}. |
4600 |
28 Sep 17 |
nicklas |
42 |
|
4663 |
29 Jan 18 |
nicklas |
Auto-confirmation will then continue with StringTie if the number of aligned |
4600 |
28 Sep 17 |
nicklas |
pairs is higher than 1 million. If the number of aligned pairs is less than |
4600 |
28 Sep 17 |
nicklas |
5 millions the RNA is flagged. |
4600 |
28 Sep 17 |
nicklas |
46 |
|
4600 |
28 Sep 17 |
nicklas |
@author nicklas |
4600 |
28 Sep 17 |
nicklas |
@since 4.12 |
4600 |
28 Sep 17 |
nicklas |
49 |
*/ |
4600 |
28 Sep 17 |
nicklas |
50 |
public class HisatAlignAutoConfirmer |
4600 |
28 Sep 17 |
nicklas |
51 |
extends AutoConfirmer<DerivedBioAssay> |
4600 |
28 Sep 17 |
nicklas |
52 |
{ |
4600 |
28 Sep 17 |
nicklas |
53 |
|
7077 |
27 Mar 23 |
nicklas |
54 |
private static final ExtensionsLogger logger = |
7077 |
27 Mar 23 |
nicklas |
55 |
ExtensionsLog.getLogger(AutoConfirmService.ID, true).wrap(LoggerFactory.getLogger(HisatAlignAutoConfirmer.class)); |
4600 |
28 Sep 17 |
nicklas |
56 |
|
4600 |
28 Sep 17 |
nicklas |
57 |
|
4600 |
28 Sep 17 |
nicklas |
58 |
/** |
4600 |
28 Sep 17 |
nicklas |
At least 5 million aligned pairs is required for |
4600 |
28 Sep 17 |
nicklas |
alignment to pass without flagging. |
4600 |
28 Sep 17 |
nicklas |
61 |
*/ |
4600 |
28 Sep 17 |
nicklas |
62 |
public static final long MIN_ALIGNED_PAIRS_FLAG = 5*M; |
4600 |
28 Sep 17 |
nicklas |
63 |
|
4600 |
28 Sep 17 |
nicklas |
64 |
/** |
4600 |
28 Sep 17 |
nicklas |
At least 1 million aligned pairs is required for |
4600 |
28 Sep 17 |
nicklas |
alignment to pass but with flagging RNA. |
4600 |
28 Sep 17 |
nicklas |
67 |
*/ |
4600 |
28 Sep 17 |
nicklas |
68 |
public static final long MIN_ALIGNED_PAIRS_STOP = 1*M; |
4600 |
28 Sep 17 |
nicklas |
69 |
|
4658 |
26 Jan 18 |
nicklas |
70 |
/** |
4658 |
26 Jan 18 |
nicklas |
A higher HET percentage may indicate contamination. |
4658 |
26 Jan 18 |
nicklas |
@since 4.15 |
4658 |
26 Jan 18 |
nicklas |
73 |
*/ |
4658 |
26 Jan 18 |
nicklas |
74 |
public static final float MAX_HET_PERCENTAGE = 65f; |
4658 |
26 Jan 18 |
nicklas |
75 |
|
4600 |
28 Sep 17 |
nicklas |
76 |
public static final long MIN_ALIGNED_PAIRS_FLAG_DEBUG = 200*k; |
4600 |
28 Sep 17 |
nicklas |
77 |
public static final long MIN_ALIGNED_PAIRS_STOP_DEBUG = 150*k; |
4600 |
28 Sep 17 |
nicklas |
78 |
|
4600 |
28 Sep 17 |
nicklas |
79 |
public HisatAlignAutoConfirmer(DerivedBioAssay aligned) |
4600 |
28 Sep 17 |
nicklas |
80 |
{ |
4600 |
28 Sep 17 |
nicklas |
81 |
super(aligned, aligned.getJob()); |
4600 |
28 Sep 17 |
nicklas |
82 |
} |
4600 |
28 Sep 17 |
nicklas |
83 |
|
4600 |
28 Sep 17 |
nicklas |
84 |
/** |
4675 |
08 Feb 18 |
nicklas |
Passes if the job ended successfully and HET percentage is below the |
4675 |
08 Feb 18 |
nicklas |
limit. |
4600 |
28 Sep 17 |
nicklas |
87 |
*/ |
4600 |
28 Sep 17 |
nicklas |
88 |
@Override |
4600 |
28 Sep 17 |
nicklas |
89 |
public boolean checkRules(DbControl dc, AutoConfirmManager manager) |
4600 |
28 Sep 17 |
nicklas |
90 |
{ |
4600 |
28 Sep 17 |
nicklas |
91 |
DerivedBioAssay aligned = item(dc); |
4600 |
28 Sep 17 |
nicklas |
92 |
Job job = aligned.getJob(); |
4675 |
08 Feb 18 |
nicklas |
93 |
|
4675 |
08 Feb 18 |
nicklas |
94 |
if (job.getStatus() != Job.Status.DONE) return false; |
4675 |
08 Feb 18 |
nicklas |
95 |
|
4675 |
08 Feb 18 |
nicklas |
96 |
Float hetPercentage = (Float)Annotationtype.QC_GENOTYPE_HET_PCT.getAnnotationValue(dc, aligned); |
4675 |
08 Feb 18 |
nicklas |
97 |
return hetPercentage != null && hetPercentage <= MAX_HET_PERCENTAGE; |
4600 |
28 Sep 17 |
nicklas |
98 |
} |
4600 |
28 Sep 17 |
nicklas |
99 |
|
4600 |
28 Sep 17 |
nicklas |
100 |
/** |
4675 |
08 Feb 18 |
nicklas |
Flag RNA if aligned pairs is less than 5 million or HET percentage is |
4675 |
08 Feb 18 |
nicklas |
higher than the limit. Continue with StringTie if aligned pairs is more |
4675 |
08 Feb 18 |
nicklas |
than 1 million. |
4675 |
08 Feb 18 |
nicklas |
104 |
|
4675 |
08 Feb 18 |
nicklas |
NOTE! Since the HET percentage is checked in the checkRules() method also |
4675 |
08 Feb 18 |
nicklas |
we never get here if the percentage is higher than the limit, but we keep |
4675 |
08 Feb 18 |
nicklas |
the flagging code here just in case we need it in the future. |
4600 |
28 Sep 17 |
nicklas |
108 |
*/ |
4600 |
28 Sep 17 |
nicklas |
109 |
@Override |
4600 |
28 Sep 17 |
nicklas |
110 |
public boolean autoConfirm(DbControl dc, AutoConfirmManager manager) |
4600 |
28 Sep 17 |
nicklas |
111 |
{ |
4600 |
28 Sep 17 |
nicklas |
112 |
DerivedBioAssay aligned = item(dc); |
4600 |
28 Sep 17 |
nicklas |
113 |
Job job = aligned.getJob(); |
4600 |
28 Sep 17 |
nicklas |
114 |
boolean debug = Boolean.TRUE.equals(job.getParameterValue("debug")); |
4600 |
28 Sep 17 |
nicklas |
115 |
|
4600 |
28 Sep 17 |
nicklas |
116 |
long minAlignedPairsFlag = debug ? MIN_ALIGNED_PAIRS_FLAG_DEBUG : MIN_ALIGNED_PAIRS_FLAG; |
4600 |
28 Sep 17 |
nicklas |
117 |
long minAlignedPairsStop = debug ? MIN_ALIGNED_PAIRS_STOP_DEBUG : MIN_ALIGNED_PAIRS_STOP; |
4600 |
28 Sep 17 |
nicklas |
118 |
|
4600 |
28 Sep 17 |
nicklas |
// Reset auto-processing so that it shows up in the manual wizard if |
4600 |
28 Sep 17 |
nicklas |
// starting the next step fails |
4600 |
28 Sep 17 |
nicklas |
121 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, aligned, null); |
4600 |
28 Sep 17 |
nicklas |
122 |
Long alignedPairs = (Long)Annotationtype.ALIGNED_PAIRS.getAnnotationValue(dc, aligned); |
4658 |
26 Jan 18 |
nicklas |
123 |
Float hetPercentage = (Float)Annotationtype.QC_GENOTYPE_HET_PCT.getAnnotationValue(dc, aligned); |
4600 |
28 Sep 17 |
nicklas |
124 |
|
4658 |
26 Jan 18 |
nicklas |
125 |
String flagRNA = null; |
4600 |
28 Sep 17 |
nicklas |
126 |
boolean stop = false; |
4600 |
28 Sep 17 |
nicklas |
127 |
if (alignedPairs == null || alignedPairs < minAlignedPairsStop) |
4600 |
28 Sep 17 |
nicklas |
128 |
{ |
4600 |
28 Sep 17 |
nicklas |
// Flag and stop |
4658 |
26 Jan 18 |
nicklas |
130 |
flagRNA = Rna.FLAG_ALIGN_FAILED; |
4600 |
28 Sep 17 |
nicklas |
131 |
stop = true; |
4600 |
28 Sep 17 |
nicklas |
132 |
} |
4600 |
28 Sep 17 |
nicklas |
133 |
else if (alignedPairs < minAlignedPairsFlag) |
4600 |
28 Sep 17 |
nicklas |
134 |
{ |
4600 |
28 Sep 17 |
nicklas |
// Flag and continue |
4658 |
26 Jan 18 |
nicklas |
136 |
flagRNA = Rna.FLAG_ALIGN_FAILED; |
4600 |
28 Sep 17 |
nicklas |
137 |
} |
4658 |
26 Jan 18 |
nicklas |
138 |
else if (hetPercentage != null && hetPercentage > MAX_HET_PERCENTAGE) |
4658 |
26 Jan 18 |
nicklas |
139 |
{ |
4658 |
26 Jan 18 |
nicklas |
140 |
flagRNA = Rna.FLAG_HIGH_HET; |
4658 |
26 Jan 18 |
nicklas |
141 |
} |
4600 |
28 Sep 17 |
nicklas |
142 |
|
4658 |
26 Jan 18 |
nicklas |
143 |
if (flagRNA != null) |
4600 |
28 Sep 17 |
nicklas |
144 |
{ |
4658 |
26 Jan 18 |
nicklas |
145 |
manager.flagRna(dc, aligned.getExtract(), flagRNA); |
4600 |
28 Sep 17 |
nicklas |
146 |
} |
4600 |
28 Sep 17 |
nicklas |
147 |
|
4600 |
28 Sep 17 |
nicklas |
148 |
if (stop) |
4600 |
28 Sep 17 |
nicklas |
149 |
{ |
4600 |
28 Sep 17 |
nicklas |
150 |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_FAILED); |
4600 |
28 Sep 17 |
nicklas |
151 |
} |
4600 |
28 Sep 17 |
nicklas |
152 |
else |
4600 |
28 Sep 17 |
nicklas |
153 |
{ |
4600 |
28 Sep 17 |
nicklas |
154 |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_SUCCESSFUL); |
4660 |
29 Jan 18 |
nicklas |
155 |
|
4660 |
29 Jan 18 |
nicklas |
// Pipelines for further processing |
5015 |
08 Oct 18 |
nicklas |
157 |
BiomaterialList.STRINGTIE_PIPELINE.load(dc).add(aligned); |
5015 |
08 Oct 18 |
nicklas |
158 |
BiomaterialList.MBAF_PIPELINE.load(dc).add(aligned); |
5683 |
22 Oct 19 |
nicklas |
159 |
BiomaterialList.VARIANT_CALLING_PIPELINE.load(dc).add(aligned); |
5421 |
13 May 19 |
nicklas |
160 |
ActivityDef.HISAT_AUTOCONFIRMED.merge(dc, 1).setUser("Auto-confirm"); |
4600 |
28 Sep 17 |
nicklas |
161 |
} |
4600 |
28 Sep 17 |
nicklas |
162 |
|
4600 |
28 Sep 17 |
nicklas |
163 |
return !stop; |
4600 |
28 Sep 17 |
nicklas |
164 |
} |
4600 |
28 Sep 17 |
nicklas |
165 |
|
4600 |
28 Sep 17 |
nicklas |
166 |
/** |
5684 |
25 Oct 19 |
nicklas |
Schedule StringTie/mBAF/VariantCall analysis to run on the cluster. |
4600 |
28 Sep 17 |
nicklas |
168 |
*/ |
4600 |
28 Sep 17 |
nicklas |
169 |
@Override |
4600 |
28 Sep 17 |
nicklas |
170 |
public boolean startNextStep(SessionControl sc, AutoConfirmManager manager) |
4600 |
28 Sep 17 |
nicklas |
171 |
{ |
4662 |
29 Jan 18 |
nicklas |
172 |
DbControl dc = null; |
4662 |
29 Jan 18 |
nicklas |
173 |
try |
4662 |
29 Jan 18 |
nicklas |
174 |
{ |
6599 |
22 Feb 22 |
nicklas |
175 |
dc = sc.newDbControl("Reggie: Auto-confirm Hisat"); |
5037 |
17 Oct 18 |
nicklas |
176 |
|
4662 |
29 Jan 18 |
nicklas |
177 |
DerivedBioAssay aligned = item(dc); |
4662 |
29 Jan 18 |
nicklas |
178 |
Job job = aligned.getJob(); |
5037 |
17 Oct 18 |
nicklas |
179 |
|
4662 |
29 Jan 18 |
nicklas |
180 |
boolean debug = Boolean.TRUE.equals(job.getParameterValue("debug")); |
4662 |
29 Jan 18 |
nicklas |
181 |
Integer priority = (Integer)job.getParameterValue("priority"); |
6982 |
17 Jan 23 |
nicklas |
182 |
String partition = job.getParameterValue("partition"); |
4662 |
29 Jan 18 |
nicklas |
183 |
|
4662 |
29 Jan 18 |
nicklas |
184 |
String clusterId = job.getServer(); |
4662 |
29 Jan 18 |
nicklas |
185 |
OpenGridCluster cluster = OpenGridService.getInstance().getClusterById(dc, clusterId); |
4662 |
29 Jan 18 |
nicklas |
186 |
if (cluster == null) |
4662 |
29 Jan 18 |
nicklas |
187 |
{ |
4662 |
29 Jan 18 |
nicklas |
// If we don't have required items, abort and revert to manual start |
4662 |
29 Jan 18 |
nicklas |
189 |
return false; |
4662 |
29 Jan 18 |
nicklas |
190 |
} |
4662 |
29 Jan 18 |
nicklas |
191 |
|
5037 |
17 Oct 18 |
nicklas |
// Pipelines for further processing |
5037 |
17 Oct 18 |
nicklas |
193 |
ItemList stringtiePipeline = BiomaterialList.STRINGTIE_PIPELINE.load(dc); |
5037 |
17 Oct 18 |
nicklas |
194 |
boolean stringtieDisabled = "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, stringtiePipeline)); |
5037 |
17 Oct 18 |
nicklas |
195 |
ItemList mBafPipeline = BiomaterialList.MBAF_PIPELINE.load(dc); |
5037 |
17 Oct 18 |
nicklas |
196 |
boolean mBafDisabled = "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, mBafPipeline)); |
5683 |
22 Oct 19 |
nicklas |
197 |
ItemList variantCallingPipeline = BiomaterialList.VARIANT_CALLING_PIPELINE.load(dc); |
5683 |
22 Oct 19 |
nicklas |
198 |
boolean variantCallingDisabled = "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, variantCallingPipeline)); |
5037 |
17 Oct 18 |
nicklas |
199 |
|
5683 |
22 Oct 19 |
nicklas |
200 |
if (stringtieDisabled && mBafDisabled && variantCallingDisabled) return false; |
5037 |
17 Oct 18 |
nicklas |
201 |
dc.close(); |
5037 |
17 Oct 18 |
nicklas |
202 |
|
6674 |
11 Apr 22 |
nicklas |
203 |
BatchConfig batchConfig = new BatchConfig(); |
5684 |
25 Oct 19 |
nicklas |
// Create StringTie/mBaf/VariantCall jobs |
5037 |
17 Oct 18 |
nicklas |
// We use separate transactions so that if one pipeline can fail without affecting the other |
5037 |
17 Oct 18 |
nicklas |
206 |
if (!stringtieDisabled) |
5037 |
17 Oct 18 |
nicklas |
207 |
{ |
5037 |
17 Oct 18 |
nicklas |
208 |
try |
5037 |
17 Oct 18 |
nicklas |
209 |
{ |
6599 |
22 Feb 22 |
nicklas |
210 |
dc = sc.newDbControl("Reggie: Auto-confirm Hisat - start StringTie"); |
4662 |
29 Jan 18 |
nicklas |
211 |
|
6819 |
26 Aug 22 |
nicklas |
212 |
Filter<Annotatable> pipelineFilter = Annotationtype.PIPELINE.createFilter(Pipeline.RNASEQ_HISAT_STRINGTIE.getName()); |
6819 |
26 Aug 22 |
nicklas |
213 |
Arraydesign design = Arraydesign.getLatestProjectDefault(dc, Rawdatatype.STRINGTIE.getVariantId(), pipelineFilter); |
6819 |
26 Aug 22 |
nicklas |
214 |
Protocol protocol = (Protocol)Subtype.FEATURE_EXTRACTION_PROTOCOL.getLatestProjectDefault(dc, pipelineFilter); |
6819 |
26 Aug 22 |
nicklas |
215 |
Software software = (Software)Subtype.FEATURE_EXTRACTION_SOFTWARE.getLatestProjectDefault(dc, pipelineFilter); |
5037 |
17 Oct 18 |
nicklas |
216 |
|
5037 |
17 Oct 18 |
nicklas |
217 |
if (logger.isDebugEnabled()) |
5037 |
17 Oct 18 |
nicklas |
218 |
{ |
5037 |
17 Oct 18 |
nicklas |
219 |
logger.debug("Starting StringTie jobs on cluster: " + clusterId); |
5037 |
17 Oct 18 |
nicklas |
220 |
logger.debug("StringTie Software/protocol: " + software + "/" + protocol); |
5037 |
17 Oct 18 |
nicklas |
221 |
logger.debug("Array design: " + design); |
5037 |
17 Oct 18 |
nicklas |
222 |
} |
5037 |
17 Oct 18 |
nicklas |
223 |
|
6982 |
17 Jan 23 |
nicklas |
224 |
OpenGridCluster stringtieCluster = ScriptUtil.autoSelectClusterWithConfig(dc, "stringtie", cluster); |
5037 |
17 Oct 18 |
nicklas |
225 |
StringTieJobCreator jobCreator = new StringTieJobCreator(); |
5037 |
17 Oct 18 |
nicklas |
226 |
jobCreator.setArrayDesign(design == null ? null : design.getItem()); |
5037 |
17 Oct 18 |
nicklas |
227 |
jobCreator.setProtocol(protocol); |
5037 |
17 Oct 18 |
nicklas |
228 |
jobCreator.setSoftware(software); |
5037 |
17 Oct 18 |
nicklas |
229 |
jobCreator.setAutoConfirm(true); |
5037 |
17 Oct 18 |
nicklas |
230 |
jobCreator.setDebug(debug); |
5037 |
17 Oct 18 |
nicklas |
231 |
jobCreator.setPriority(priority); |
6982 |
17 Jan 23 |
nicklas |
232 |
if (cluster == stringtieCluster) jobCreator.setPartition(partition); |
6674 |
11 Apr 22 |
nicklas |
233 |
jobCreator.setBatchConfig(batchConfig); |
5037 |
17 Oct 18 |
nicklas |
234 |
|
6637 |
09 Mar 22 |
nicklas |
235 |
List<JobDefinition> jobDefs = jobCreator.createStringTieJobs(dc, stringtieCluster, Collections.singletonList(AlignedSequences.getById(dc, aligned.getId()))); |
6637 |
09 Mar 22 |
nicklas |
236 |
ScriptUtil.submitJobs(dc, stringtieCluster, jobDefs); |
5037 |
17 Oct 18 |
nicklas |
237 |
dc.commit(); |
5037 |
17 Oct 18 |
nicklas |
238 |
} |
5037 |
17 Oct 18 |
nicklas |
239 |
catch (RuntimeException ex) |
5037 |
17 Oct 18 |
nicklas |
240 |
{ |
5037 |
17 Oct 18 |
nicklas |
241 |
logger.error("Could not create StringTie job", ex); |
5037 |
17 Oct 18 |
nicklas |
242 |
} |
5037 |
17 Oct 18 |
nicklas |
243 |
} |
5037 |
17 Oct 18 |
nicklas |
244 |
|
5037 |
17 Oct 18 |
nicklas |
245 |
if (!mBafDisabled) |
4662 |
29 Jan 18 |
nicklas |
246 |
{ |
5037 |
17 Oct 18 |
nicklas |
247 |
try |
5037 |
17 Oct 18 |
nicklas |
248 |
{ |
6599 |
22 Feb 22 |
nicklas |
249 |
dc = sc.newDbControl("Reggie: Auto-confirm Hisat - start mBAF analysis"); |
5037 |
17 Oct 18 |
nicklas |
250 |
|
5057 |
29 Oct 18 |
nicklas |
251 |
Filter<Annotatable> mBafFilter = Annotationtype.VARIANT_CALL_TYPE.createFilter("mBAF"); |
5057 |
29 Oct 18 |
nicklas |
252 |
Software software = (Software)Subtype.VARIANT_CALLING_SOFTWARE.getLatestProjectDefault(dc, mBafFilter); |
5037 |
17 Oct 18 |
nicklas |
253 |
|
5037 |
17 Oct 18 |
nicklas |
254 |
if (logger.isDebugEnabled()) |
5037 |
17 Oct 18 |
nicklas |
255 |
{ |
5037 |
17 Oct 18 |
nicklas |
256 |
logger.debug("Starting mBAF analysis jobs on cluster: " + clusterId); |
5057 |
29 Oct 18 |
nicklas |
257 |
logger.debug("mBAF Software: " + software); |
5037 |
17 Oct 18 |
nicklas |
258 |
} |
5037 |
17 Oct 18 |
nicklas |
259 |
|
6982 |
17 Jan 23 |
nicklas |
260 |
OpenGridCluster mbafCluster = ScriptUtil.autoSelectClusterWithConfig(dc, "mbaf", cluster); |
5037 |
17 Oct 18 |
nicklas |
261 |
MBafJobCreator jobCreator = new MBafJobCreator(); |
5057 |
29 Oct 18 |
nicklas |
262 |
jobCreator.setSoftware(software); |
5037 |
17 Oct 18 |
nicklas |
263 |
jobCreator.setAutoConfirm(true); |
5037 |
17 Oct 18 |
nicklas |
264 |
jobCreator.setDebug(debug); |
5037 |
17 Oct 18 |
nicklas |
265 |
jobCreator.setPriority(priority); |
6982 |
17 Jan 23 |
nicklas |
266 |
if (cluster == mbafCluster) jobCreator.setPartition(partition); |
6674 |
11 Apr 22 |
nicklas |
267 |
jobCreator.setBatchConfig(batchConfig); |
5037 |
17 Oct 18 |
nicklas |
268 |
|
6637 |
09 Mar 22 |
nicklas |
269 |
List<JobDefinition> jobDefs = jobCreator.createMBafJobs(dc, mbafCluster, Collections.singletonList(AlignedSequences.getById(dc, aligned.getId()))); |
6637 |
09 Mar 22 |
nicklas |
270 |
ScriptUtil.submitJobs(dc, mbafCluster, jobDefs); |
5037 |
17 Oct 18 |
nicklas |
271 |
dc.commit(); |
5037 |
17 Oct 18 |
nicklas |
272 |
} |
5037 |
17 Oct 18 |
nicklas |
273 |
catch (RuntimeException ex) |
5037 |
17 Oct 18 |
nicklas |
274 |
{ |
5037 |
17 Oct 18 |
nicklas |
275 |
logger.error("Could not create mBAF analysis job", ex); |
5037 |
17 Oct 18 |
nicklas |
276 |
} |
4662 |
29 Jan 18 |
nicklas |
277 |
} |
4662 |
29 Jan 18 |
nicklas |
278 |
|
5683 |
22 Oct 19 |
nicklas |
279 |
if (!variantCallingDisabled) |
5683 |
22 Oct 19 |
nicklas |
280 |
{ |
5683 |
22 Oct 19 |
nicklas |
281 |
try |
5683 |
22 Oct 19 |
nicklas |
282 |
{ |
6599 |
22 Feb 22 |
nicklas |
283 |
dc = sc.newDbControl("Reggie: Auto-confirm Hisat - start Variant calling"); |
5683 |
22 Oct 19 |
nicklas |
284 |
|
5684 |
25 Oct 19 |
nicklas |
285 |
Filter<Annotatable> filter = Annotationtype.VARIANT_CALL_TYPE.createFilter("VariantCall"); |
5684 |
25 Oct 19 |
nicklas |
286 |
Software software = (Software)Subtype.VARIANT_CALLING_SOFTWARE.getLatestProjectDefault(dc, filter); |
5684 |
25 Oct 19 |
nicklas |
287 |
|
5684 |
25 Oct 19 |
nicklas |
288 |
if (logger.isDebugEnabled()) |
5684 |
25 Oct 19 |
nicklas |
289 |
{ |
5684 |
25 Oct 19 |
nicklas |
290 |
logger.debug("Starting variant calling jobs on cluster: " + clusterId); |
5684 |
25 Oct 19 |
nicklas |
291 |
logger.debug("Variant calling software: " + software); |
5684 |
25 Oct 19 |
nicklas |
292 |
} |
5684 |
25 Oct 19 |
nicklas |
293 |
|
6982 |
17 Jan 23 |
nicklas |
294 |
OpenGridCluster vcallCluster = ScriptUtil.autoSelectClusterWithConfig(dc, "variant-call", cluster); |
5684 |
25 Oct 19 |
nicklas |
295 |
VariantCallingJobCreator jobCreator = new VariantCallingJobCreator(); |
5713 |
12 Nov 19 |
nicklas |
296 |
jobCreator.setSkipRaw(false); |
5818 |
31 Jan 20 |
nicklas |
297 |
jobCreator.setRawOnly(false); |
5684 |
25 Oct 19 |
nicklas |
298 |
jobCreator.setSoftware(software); |
5684 |
25 Oct 19 |
nicklas |
299 |
jobCreator.setAutoConfirm(true); |
5684 |
25 Oct 19 |
nicklas |
300 |
jobCreator.setDebug(debug); |
5684 |
25 Oct 19 |
nicklas |
301 |
jobCreator.setPriority(priority); |
6982 |
17 Jan 23 |
nicklas |
302 |
if (cluster == vcallCluster) jobCreator.setPartition(partition); |
6674 |
11 Apr 22 |
nicklas |
303 |
jobCreator.setBatchConfig(batchConfig); |
5684 |
25 Oct 19 |
nicklas |
304 |
|
6637 |
09 Mar 22 |
nicklas |
305 |
List<JobDefinition> jobDefs = jobCreator.createVariantCallingJobs(dc, vcallCluster, Collections.singletonList(AlignedSequences.getById(dc, aligned.getId()))); |
6637 |
09 Mar 22 |
nicklas |
306 |
ScriptUtil.submitJobs(dc, vcallCluster, jobDefs); |
5684 |
25 Oct 19 |
nicklas |
307 |
dc.commit(); |
5683 |
22 Oct 19 |
nicklas |
308 |
} |
5683 |
22 Oct 19 |
nicklas |
309 |
catch (RuntimeException ex) |
5683 |
22 Oct 19 |
nicklas |
310 |
{ |
5683 |
22 Oct 19 |
nicklas |
311 |
logger.error("Could not create Variant calling job", ex); |
6637 |
09 Mar 22 |
nicklas |
312 |
} |
5683 |
22 Oct 19 |
nicklas |
313 |
} |
4662 |
29 Jan 18 |
nicklas |
314 |
} |
4662 |
29 Jan 18 |
nicklas |
315 |
finally |
4662 |
29 Jan 18 |
nicklas |
316 |
{ |
4662 |
29 Jan 18 |
nicklas |
317 |
if (dc != null) dc.close(); |
4662 |
29 Jan 18 |
nicklas |
318 |
} |
4662 |
29 Jan 18 |
nicklas |
319 |
return true; |
4600 |
28 Sep 17 |
nicklas |
320 |
} |
4600 |
28 Sep 17 |
nicklas |
321 |
} |