extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/autoconfirm/MipsAlignAutoConfirmer.java

Code
Comments
Other
Rev Date Author Line
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 14   Auto-confirm implementation for MIPs aligned sequences.
5845 26 Feb 20 nicklas 15   The rules are simple:
5845 26 Feb 20 nicklas 16
5845 26 Feb 20 nicklas 17   * {@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 19   Until the next step has been implemented, actual auto-confirmation will not take.
5845 26 Feb 20 nicklas 20   Instead, the auto-confirm flag will be cleared to make the alignment appear in
5845 26 Feb 20 nicklas 21   the manual confirmation wizard.
5845 26 Feb 20 nicklas 22
5845 26 Feb 20 nicklas 23   @author nicklas
5845 26 Feb 20 nicklas 24   @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 39     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 53     Flag RNA if aligned pairs is less than 5 million or HET percentage is
5845 26 Feb 20 nicklas 54     higher than the limit. Continue with StringTie if aligned pairs is more 
5845 26 Feb 20 nicklas 55     than 1 million.
5845 26 Feb 20 nicklas 56     
5845 26 Feb 20 nicklas 57     NOTE! Since the HET percentage is checked in the checkRules() method also
5845 26 Feb 20 nicklas 58     we never get here if the percentage is higher than the limit, but we keep
5845 26 Feb 20 nicklas 59     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 67     // Reset auto-processing so that it shows up in the manual wizard if
5845 26 Feb 20 nicklas 68     // 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 72     // TODO - any rules for flagging or stopping??
5845 26 Feb 20 nicklas 73     // TODO - implement this when we know what the next step will be
5845 26 Feb 20 nicklas 74     /*
5845 26 Feb 20 nicklas 75     String flagDNA = null;
5845 26 Feb 20 nicklas 76     boolean stop = false;
5845 26 Feb 20 nicklas 77     if (flagDNA != null)
5845 26 Feb 20 nicklas 78     {
5845 26 Feb 20 nicklas 79       manager.flagDna(dc, aligned.getExtract(), flagDNA);
5845 26 Feb 20 nicklas 80     }
5845 26 Feb 20 nicklas 81     
5845 26 Feb 20 nicklas 82     if (stop)
5845 26 Feb 20 nicklas 83     {
5845 26 Feb 20 nicklas 84       Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_FAILED);
5845 26 Feb 20 nicklas 85     }
5845 26 Feb 20 nicklas 86     else
5845 26 Feb 20 nicklas 87     {
5845 26 Feb 20 nicklas 88       Annotationtype.ANALYSIS_RESULT.setAnnotationValue(dc, aligned, AlignedSequences.ALIGN_SUCCESSFUL);
5845 26 Feb 20 nicklas 89
5845 26 Feb 20 nicklas 90       // Pipelines for further processing
5845 26 Feb 20 nicklas 91       BiomaterialList.MIPS_NEXTSTEP_TODO.load(dc).add(aligned);
5845 26 Feb 20 nicklas 92       ActivityDef.MIPS_ALIGNMENT_AUTOCONFIRMED.merge(dc, 1).setUser("Auto-confirm");
5845 26 Feb 20 nicklas 93     }
5845 26 Feb 20 nicklas 94     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 99     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 }