5845 |
26 Feb 20 |
nicklas |
1 |
package net.sf.basedb.reggie.autoconfirm; |
5845 |
26 Feb 20 |
nicklas |
2 |
|
5845 |
26 Feb 20 |
nicklas |
3 |
import org.slf4j.LoggerFactory; |
5845 |
26 Feb 20 |
nicklas |
4 |
|
5845 |
26 Feb 20 |
nicklas |
5 |
import net.sf.basedb.core.DbControl; |
5845 |
26 Feb 20 |
nicklas |
6 |
import net.sf.basedb.core.DerivedBioAssay; |
5845 |
26 Feb 20 |
nicklas |
7 |
import net.sf.basedb.core.Job; |
5845 |
26 Feb 20 |
nicklas |
8 |
import net.sf.basedb.core.SessionControl; |
5845 |
26 Feb 20 |
nicklas |
9 |
import net.sf.basedb.reggie.dao.Annotationtype; |
7077 |
27 Mar 23 |
nicklas |
10 |
import net.sf.basedb.util.extensions.logging.ExtensionsLog; |
7077 |
27 Mar 23 |
nicklas |
11 |
import net.sf.basedb.util.extensions.logging.ExtensionsLogger; |
5845 |
26 Feb 20 |
nicklas |
12 |
|
5845 |
26 Feb 20 |
nicklas |
13 |
/** |
5845 |
26 Feb 20 |
nicklas |
Auto-confirm implementation for MIPs aligned sequences. |
5845 |
26 Feb 20 |
nicklas |
The rules are simple: |
5845 |
26 Feb 20 |
nicklas |
16 |
|
5845 |
26 Feb 20 |
nicklas |
* {@link DerivedBioAssay#getJob()} job status must be {@link net.sf.basedb.core.Job.Status#DONE}. |
5845 |
26 Feb 20 |
nicklas |
18 |
|
5845 |
26 Feb 20 |
nicklas |
Until the next step has been implemented, actual auto-confirmation will not take. |
5845 |
26 Feb 20 |
nicklas |
Instead, the auto-confirm flag will be cleared to make the alignment appear in |
5845 |
26 Feb 20 |
nicklas |
the manual confirmation wizard. |
5845 |
26 Feb 20 |
nicklas |
22 |
|
5845 |
26 Feb 20 |
nicklas |
@author nicklas |
5845 |
26 Feb 20 |
nicklas |
@since 4.26 |
5845 |
26 Feb 20 |
nicklas |
25 |
*/ |
5845 |
26 Feb 20 |
nicklas |
26 |
public class MipsAlignAutoConfirmer |
5845 |
26 Feb 20 |
nicklas |
27 |
extends AutoConfirmer<DerivedBioAssay> |
5845 |
26 Feb 20 |
nicklas |
28 |
{ |
5845 |
26 Feb 20 |
nicklas |
29 |
|
7077 |
27 Mar 23 |
nicklas |
30 |
private static final ExtensionsLogger logger = |
7077 |
27 Mar 23 |
nicklas |
31 |
ExtensionsLog.getLogger(AutoConfirmService.ID, true).wrap(LoggerFactory.getLogger(MipsAlignAutoConfirmer.class)); |
5845 |
26 Feb 20 |
nicklas |
32 |
|
5845 |
26 Feb 20 |
nicklas |
33 |
public MipsAlignAutoConfirmer(DerivedBioAssay aligned) |
5845 |
26 Feb 20 |
nicklas |
34 |
{ |
5845 |
26 Feb 20 |
nicklas |
35 |
super(aligned, aligned.getJob()); |
5845 |
26 Feb 20 |
nicklas |
36 |
} |
5845 |
26 Feb 20 |
nicklas |
37 |
|
5845 |
26 Feb 20 |
nicklas |
38 |
/** |
5845 |
26 Feb 20 |
nicklas |
Passes if the job ended successfully. |
5845 |
26 Feb 20 |
nicklas |
40 |
*/ |
5845 |
26 Feb 20 |
nicklas |
41 |
@Override |
5845 |
26 Feb 20 |
nicklas |
42 |
public boolean checkRules(DbControl dc, AutoConfirmManager manager) |
5845 |
26 Feb 20 |
nicklas |
43 |
{ |
5845 |
26 Feb 20 |
nicklas |
44 |
DerivedBioAssay aligned = item(dc); |
5845 |
26 Feb 20 |
nicklas |
45 |
Job job = aligned.getJob(); |
5845 |
26 Feb 20 |
nicklas |
46 |
|
5845 |
26 Feb 20 |
nicklas |
47 |
if (job.getStatus() != Job.Status.DONE) return false; |
5845 |
26 Feb 20 |
nicklas |
48 |
|
5845 |
26 Feb 20 |
nicklas |
49 |
return true; |
5845 |
26 Feb 20 |
nicklas |
50 |
} |
5845 |
26 Feb 20 |
nicklas |
51 |
|
5845 |
26 Feb 20 |
nicklas |
52 |
/** |
5845 |
26 Feb 20 |
nicklas |
Flag RNA if aligned pairs is less than 5 million or HET percentage is |
5845 |
26 Feb 20 |
nicklas |
higher than the limit. Continue with StringTie if aligned pairs is more |
5845 |
26 Feb 20 |
nicklas |
than 1 million. |
5845 |
26 Feb 20 |
nicklas |
56 |
|
5845 |
26 Feb 20 |
nicklas |
NOTE! Since the HET percentage is checked in the checkRules() method also |
5845 |
26 Feb 20 |
nicklas |
we never get here if the percentage is higher than the limit, but we keep |
5845 |
26 Feb 20 |
nicklas |
the flagging code here just in case we need it in the future. |
5845 |
26 Feb 20 |
nicklas |
60 |
*/ |
5845 |
26 Feb 20 |
nicklas |
61 |
@Override |
5845 |
26 Feb 20 |
nicklas |
62 |
public boolean autoConfirm(DbControl dc, AutoConfirmManager manager) |
5845 |
26 Feb 20 |
nicklas |
63 |
{ |
5845 |
26 Feb 20 |
nicklas |
64 |
DerivedBioAssay aligned = item(dc); |
5845 |
26 Feb 20 |
nicklas |
65 |
Job job = aligned.getJob(); |
5845 |
26 Feb 20 |
nicklas |
66 |
|
5845 |
26 Feb 20 |
nicklas |
// Reset auto-processing so that it shows up in the manual wizard if |
5845 |
26 Feb 20 |
nicklas |
// starting the next step fails |
5845 |
26 Feb 20 |
nicklas |
69 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, aligned, null); |
5845 |
26 Feb 20 |
nicklas |
70 |
|
5845 |
26 Feb 20 |
nicklas |
71 |
return false; |
5845 |
26 Feb 20 |
nicklas |
// TODO - any rules for flagging or stopping?? |
5845 |
26 Feb 20 |
nicklas |
// TODO - implement this when we know what the next step will be |
5845 |
26 Feb 20 |
nicklas |
74 |
/* |
5845 |
26 Feb 20 |
nicklas |
String flagDNA = null; |
5845 |
26 Feb 20 |
nicklas |
boolean stop = false; |
5845 |
26 Feb 20 |
nicklas |
if (flagDNA != null) |
5845 |
26 Feb 20 |
nicklas |
78 |
{ |
5845 |
26 Feb 20 |
nicklas |
manager.flagDna(dc, aligned.getExtract(), flagDNA); |
5845 |
26 Feb 20 |
nicklas |
80 |
} |
5845 |
26 Feb 20 |
nicklas |
81 |
|
5845 |
26 Feb 20 |
nicklas |
if (stop) |
5845 |
26 Feb 20 |
nicklas |
83 |
{ |
5845 |
26 Feb 20 |
nicklas |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_FAILED); |
5845 |
26 Feb 20 |
nicklas |
85 |
} |
5845 |
26 Feb 20 |
nicklas |
else |
5845 |
26 Feb 20 |
nicklas |
87 |
{ |
5845 |
26 Feb 20 |
nicklas |
Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_SUCCESSFUL); |
5845 |
26 Feb 20 |
nicklas |
89 |
|
5845 |
26 Feb 20 |
nicklas |
// Pipelines for further processing |
5845 |
26 Feb 20 |
nicklas |
BiomaterialList.MIPS_NEXTSTEP_TODO.load(dc).add(aligned); |
5845 |
26 Feb 20 |
nicklas |
ActivityDef.MIPS_ALIGNMENT_AUTOCONFIRMED.merge(dc, 1).setUser("Auto-confirm"); |
5845 |
26 Feb 20 |
nicklas |
93 |
} |
5845 |
26 Feb 20 |
nicklas |
return !stop; |
5845 |
26 Feb 20 |
nicklas |
95 |
*/ |
5845 |
26 Feb 20 |
nicklas |
96 |
} |
5845 |
26 Feb 20 |
nicklas |
97 |
|
5845 |
26 Feb 20 |
nicklas |
98 |
/** |
5845 |
26 Feb 20 |
nicklas |
Schedule next analysis step -- TODO |
5845 |
26 Feb 20 |
nicklas |
100 |
*/ |
5845 |
26 Feb 20 |
nicklas |
101 |
@Override |
5845 |
26 Feb 20 |
nicklas |
102 |
public boolean startNextStep(SessionControl sc, AutoConfirmManager manager) |
5845 |
26 Feb 20 |
nicklas |
103 |
{ |
5845 |
26 Feb 20 |
nicklas |
104 |
return false; |
5845 |
26 Feb 20 |
nicklas |
105 |
} |
5845 |
26 Feb 20 |
nicklas |
106 |
|
5845 |
26 Feb 20 |
nicklas |
107 |
} |