Changeset 5772


Ignore:
Timestamp:
Dec 3, 2019, 11:56:24 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #1208: Implement wizard for building database of variant frequencies in SCAN-B samples

Added a new job subtype so that we can get a callback when the job has ended. The callback will get some information from the log file and generate a message.

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r5684 r5772  
    324324  public static final Subtype VARIANT_CALLING_JOB = new Subtype("Variant calling", null, null, null, Item.JOB, false);
    325325
     326  /**
     327    The definition of the variant calling job.
     328    @since 4.25
     329  */
     330  public static final Subtype VARIANT_STATISTICS_JOB = new Subtype("Variant statistics", null, null, null, Item.JOB, false);
     331 
    326332  /**
    327333    The definition of the "Sequencer" hardware subtype. Should already exist in BASE.
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/JobCompletionHandlerFactory.java

    r5684 r5772  
    103103          action = new VariantCallingJobCreator.VariantCallJobCompletionHandler();
    104104        }
     105        else if (jobType.equals(Subtype.VARIANT_STATISTICS_JOB.get(dc)))
     106        {
     107          action = new VariantStatisticsJobCreator.VariantStatisticsJobCompletionHandler();
     108        }
    105109      }
    106110      finally
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/VariantStatisticsJobCreator.java

    r5770 r5772  
    2727import net.sf.basedb.core.snapshot.SnapshotManager;
    2828import net.sf.basedb.opengrid.JobDefinition;
     29import net.sf.basedb.opengrid.JobStatus;
    2930import net.sf.basedb.opengrid.OpenGridCluster;
     31import net.sf.basedb.opengrid.OpenGridSession;
    3032import net.sf.basedb.opengrid.ScriptBuilder;
    3133import net.sf.basedb.opengrid.config.ClusterConfig;
    3234import net.sf.basedb.opengrid.config.JobConfig;
    3335import net.sf.basedb.opengrid.filetransfer.StringUploadSource;
     36import net.sf.basedb.opengrid.service.JobCompletionHandler;
    3437import net.sf.basedb.reggie.Reggie;
    3538import net.sf.basedb.reggie.XmlConfig;
     
    104107    // Create job
    105108    Job statJob = Job.getNew(dc, null, null, null);
    106 //    statJob.setItemSubtype(Subtype.VARIANT_CALLING_JOB.get(dc));
     109    statJob.setItemSubtype(Subtype.VARIANT_STATISTICS_JOB.get(dc));
    107110    statJob.setPluginVersion("reggie-"+Reggie.VERSION);
    108111    statJob.setSendMessage(Values.getBoolean(sc.getUserClientSetting("plugins.sendmessage"), false));
     
    124127    statCmd += " ${WD}/vcflist.txt";
    125128    statCmd += " ${WD}/progress";
     129    statCmd += " ${WD}/mut_stats.log";
    126130    statCmd += " > mut_stats.vcf";
    127131    script.cmd(statCmd);
     132    script.progress(95, "Sorting and indexing...");
    128133    script.cmd(bedtools_path+" sort -header -i mut_stats.vcf | bgzip -c > mut_stats.vcf.gz");
    129134    script.cmd("tabix mut_stats.vcf.gz");
     
    195200  }
    196201
    197  
     202  public static class VariantStatisticsJobCompletionHandler
     203    implements JobCompletionHandler
     204  {
     205   
     206    public VariantStatisticsJobCompletionHandler()
     207    {}
     208 
     209    @Override
     210    public String jobCompleted(SessionControl sc, OpenGridSession session, Job job, JobStatus status)
     211    {
     212      String jobName = status.getName();
     213      String log = session.getJobFileAsString(jobName, "mut_stats.log", "UTF-8");
     214      Stats stat = Stats.parse(log);
     215     
     216      return "Parsed " + stat.numVcf + " VCF files for " + stat.numPatients + " patients." +
     217        " Found "+Reggie.formatCount(stat.numVariants) + " variants.";
     218    }
     219  }
     220
     221  static class Stats
     222  {
     223    int numVcf = 0;
     224    int numPatients = 0;
     225    int numVariants = 0;
     226   
     227    static Stats parse(String statsOut)
     228    {
     229      Stats s = new Stats();
     230      for (String line : statsOut.split("\n"))
     231      {
     232        String[] stat = line.split(":", 2);
     233        String key = stat[0].strip();
     234        int val = Values.getInt(stat[1].strip());
     235        if ("NumberOfVCF".equals(key))
     236        {
     237          s.numVcf = val;
     238        }
     239        else if ("NumberOfPatients".equals(key))
     240        {
     241          s.numPatients = val;
     242        }
     243        else if ("NumberOfVariants".equals(key))
     244        {
     245          s.numVariants = val;
     246        }
     247      }
     248      return s;
     249    }
     250  }
    198251}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r5725 r5772  
    332332        jsonChecks.add(checkSubtype(dc, Subtype.MBAF_JOB, null, createIfMissing));
    333333        jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_CALLING_JOB, null, createIfMissing));
     334        jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_STATISTICS_JOB, null, createIfMissing));
    334335        jsonChecks.add(checkSubtype(dc, Subtype.REPORT_SOFTWARE, null, createIfMissing));
    335336        jsonChecks.add(checkSubtype(dc, Subtype.REPORT_JOB, null, createIfMissing));
Note: See TracChangeset for help on using the changeset viewer.