Changeset 6211


Ignore:
Timestamp:
Apr 14, 2021, 12:40:34 PM (13 months ago)
Author:
Nicklas Nordborg
Message:

References #1295: Registration of specimen handled by external lab

Implemented support for auto-starting FASTQ import after a successful JSON import.

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/batch/import-external-specimen.js

    r6208 r6211  
    55  var importItems;
    66
    7   var clusterIsValid = false;
     7  var autoAnalyzeIsValid = false;
    88
    99  specimen.initPage = function()
     
    1616    Events.addEventHandler('step-2', 'wizard-validate', specimen.validateStep2);
    1717    Events.addEventHandler('clusters', 'change', specimen.clusterOnChange);
     18    Events.addEventHandler('autoAnalyzeYes', 'click', specimen.autoAnalyzeOnChange);
     19    Events.addEventHandler('autoAnalyzeNo', 'click', specimen.autoAnalyzeOnChange);
    1820
    1921    // Navigation
     
    162164  specimen.validateStep1 = function(event)
    163165  {
    164     //if (!selectionIsValid) event.preventDefault();
    165   }
    166 
     166    Wizard.hideGoNextConfirmation();
     167    var frm = document.forms['reggie'];
     168    for (var itemNo = 0; itemNo < importItems.length; itemNo++)
     169    {
     170      if (frm['import.'+itemNo].checked) return;
     171    }
     172    Wizard.showGoNextConfirmation(false, 'Please select at least one item!');
     173    event.preventDefault();
     174  }
    167175
    168176  // --- Step 2 -----------------------------------
     
    174182    var frm = document.forms['reggie'];
    175183    frm.debug.checked = debug || location.protocol != 'https:';
     184
     185    Reggie.loadProtocols('MERGE_PROTOCOL', 'mergeProtocol', 'PIPELINE', 'RNAseq');
     186    Reggie.loadSoftware('MERGE_SOFTWARE', 'mergeSoftware', 'PIPELINE,PARAMETER_SET', 'RNAseq');
    176187
    177188    // Load open grid clusters
     
    187198  specimen.validateStep2 = function(event)
    188199  {
    189     if (!clusterIsValid) event.preventDefault();
     200    if (!autoAnalyzeIsValid) event.preventDefault();
    190201  }
    191202 
     
    194205    Doc.removeClass('clusters', 'list-loading');
    195206    var frm = document.forms['reggie'];
     207    frm.clusters.length = 0;
    196208    var clusters = response.hosts;
    197     frm.clusters.length = 0;
     209    if (clusters.length == 0)
     210    {
     211      Doc.element('autoAnalyzeNo').checked = true;
     212      autoAnalyzeIsValid = true;
     213      Wizard.setInputStatus('autoAnalyze', 'warning', 'No Open Grid cluster available');
     214      return;
     215    }
     216   
     217    Doc.element('autoAnalyzeNo').disabled = false;
     218    Doc.element('autoAnalyzeYes').disabled = false;
    198219    for (var i = 0; i < clusters.length; i++)
    199220    {
     
    202223      option.cluster = cl;
    203224      frm.clusters[frm.clusters.length] = option;
    204       Wizard.setInputStatus('clusters', 'valid');
    205       clusterIsValid = true;
    206     }
    207     if (frm.clusters.length == 0)
    208     {
    209       Wizard.setInputStatus('clusters', 'invalid', 'No available Open Grid clusters');
    210       clusterIsValid = false;
    211     }
    212     else
    213     {
    214       specimen.clusterOnChange();
    215     }
    216   }
     225    }
     226    specimen.autoAnalyzeOnChange();
     227  }
     228 
     229  specimen.autoAnalyzeOnChange = function()
     230  {
     231    Wizard.setInputStatus('autoAnalyze');
     232    autoAnalyzeIsValid = false;
     233   
     234    var frm = document.forms['reggie'];
     235    var yesChecked = Doc.element('autoAnalyzeYes').checked;
     236    var noChecked = Doc.element('autoAnalyzeNo').checked;
     237   
     238    frm.mergeProtocol.disabled = !yesChecked;
     239    frm.mergeSoftware.disabled = !yesChecked;
     240    frm.clusters.disabled = !yesChecked;
     241    frm.priority.disabled = !yesChecked;
     242    frm.autoConfirm.disabled = !yesChecked;
     243    frm.debug.disabled = !yesChecked;
     244
     245    if (!yesChecked && !noChecked)
     246    {
     247      Wizard.setInputStatus('autoAnalyze', 'invalid', 'Must select Yes or No');
     248      return;
     249    }
     250   
     251    autoAnalyzeIsValid = true;
     252    Wizard.setInputStatus('autoAnalyze', 'valid');
     253   
     254    if (yesChecked) specimen.clusterOnChange();
     255  }
     256
    217257 
    218258  specimen.clusterOnChange = function()
     
    242282    var submitInfo = {};
    243283   
    244     submitInfo.cluster = frm.clusters.value;
    245     if (frm.priority.selectedIndex >= 0)
    246     {
    247       submitInfo.priority = parseInt(frm.priority.value);
    248     }
    249     submitInfo.debug = frm.debug.checked;
    250     submitInfo.autoConfirm = frm.autoConfirm.checked;
    251 
    252284    var items = [];
    253285    submitInfo.items = items;
     
    264296    }
    265297
     298    if (Doc.element('autoAnalyzeYes').checked)
     299    {
     300      var autoAnalyze = {};
     301      autoAnalyze.mergeSoftware = parseInt(frm.mergeSoftware.value);
     302      autoAnalyze.mergeProtocol = parseInt(frm.mergeProtocol.value);
     303      autoAnalyze.cluster = frm.clusters.value;
     304      autoAnalyze.priority = parseInt(frm.priority.value);
     305      autoAnalyze.debug = frm.debug.checked;
     306      autoAnalyze.autoConfirm = frm.autoConfirm.checked;
     307      submitInfo.autoAnalyze = autoAnalyze;
     308    }
     309
    266310    var url = '../FutureSpecimen.servlet?ID='+App.getSessionId();
    267311    url += '&cmd=ImportFromJSON';
  • extensions/net.sf.basedb.reggie/trunk/resources/batch/import-external-specimen.jsp

    r6198 r6211  
    9999        <table class="step-form">
    100100        <tbody>
     101          <tr>
     102            <td class="subprompt">Auto-analyze</td>
     103            <td class="input">
     104              <label><input type="radio" name="autoAnalyze" id="autoAnalyzeYes" disabled>Yes</label>
     105              <label><input type="radio" name="autoAnalyze" id="autoAnalyzeNo" disabled>No</label>
     106            </td>
     107            <td class="status" id="autoAnalyze.status"></td>
     108            <td class="help">
     109              <span id="autoAnalyze.message" class="message"></span>
     110              If the auto-analyze option is enabled, Reggie will automatically start
     111              importing the FASTQ files after a successful JSON import.
     112            </td>
     113          </tr>
     114          <tr>
     115            <td class="subprompt">Protocol</td>
     116            <td class="input">
     117              <select name="mergeProtocol" id="mergeProtocol" disabled></select>
     118            </td>
     119            <td class="status" id="mergeProtocol.status"></td>
     120            <td class="help">
     121              <span id="mergeProtocol.message" class="message"></span>
     122              Select the protocol used for merging.
     123            </td>
     124          </tr>
     125          <tr>
     126            <td class="subprompt">Software</td>
     127            <td class="input">
     128              <select name="mergeSoftware" id="mergeSoftware" disabled></select>
     129            </td>
     130            <td class="status" id="mergeSoftware.status"></td>
     131            <td class="help">
     132              <span id="mergeSoftware.message" class="message"></span>
     133              Select the software to use for merging the FASTQ files.
     134            </td>
     135          </tr>
     136        </tbody>
     137        <tbody>
    101138          <tr class="section-header">
    102139            <td colspan="4">Open Grid Scheduler</td>
    103140          </tr>
    104141          <tr>
    105             <td class="subprompt">Cluster</td>
    106             <td class="input">
    107               <select name="clusters" id="clusters" class="required"></select></td>
     142            <td class="subprompt">Open Grid Cluster</td>
     143            <td class="input">
     144              <select name="clusters" id="clusters" class="required" disabled></select>
     145            </td>
    108146            <td class="status" id="clusters.status"></td>
    109147            <td class="help">
    110148              <span id="clusters.message" class="message"></span>
    111               Select the cluster to use for running the software.
    112             </td>
    113           </tr>
    114           <tr id="job-priority" style="display: none;">
     149              Select the cluster to use for running the analysis.
     150            </td>
     151          </tr>
     152          <tr>
    115153            <td class="subprompt">Job priority</td>
    116154            <td class="input">
    117               <select name="priority" id="priority"></select>
     155              <select name="priority" id="priority" disabled></select>
    118156            </td>
    119157            <td class="status" id="priority.status"></td>
    120158            <td class="help">
    121159              <span id="priority.message" class="message"></span>
    122               Select the priority of the job.
     160              Select the priority of the analysis jobs.
    123161            </td>
    124162          </tr>
    125163          <tr>
    126164            <td class="subprompt">Auto-confirm</td>
    127             <td class="input"><input type="checkbox" name="autoConfirm" checked></td>
     165            <td class="input"><input type="checkbox" name="autoConfirm" checked disabled></td>
    128166            <td class="status" id="autoConfirm.status"></td>
    129167            <td class="help">
    130168              <span id="autoConfirm.message" class="message"></span>
    131              
     169              If the FASTQ analysis is successful, with at least 10M reads
     170              after trimmomatic and valid fragment size values, it is
     171              automatically confirmed and alignment is started.
    132172            </td>
    133173          </tr>
    134174          <tr>
    135175            <td class="subprompt">Debug</td>
    136             <td class="input"><input type="checkbox" name="debug"></td>
     176            <td class="input"><input type="checkbox" name="debug" disabled></td>
    137177            <td class="status" id="debug.status"></td>
    138178            <td class="help">
    139179              <span id="debug.message" class="message"></span>
    140               When running in debug mode temporary files are not removed from the
    141               cluster node.
     180              When running in debug mode only part of the sequenced data is used and
     181              temporary files are not removed from the cluster nodes.
    142182            </td>
    143183          </tr>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/ImportFastqJobCreator.java

    r6209 r6211  
    214214      importJob.setSendMessage(Values.getBoolean(sc.getUserClientSetting("plugins.sendmessage"), false));
    215215      importJob.setName("FASTQ Import to " + mergeName);
    216       importJob.setParameterValue("pipeline", new StringParameterType(), Pipeline.RNASEQ_HISAT_STRINGTIE.getId());
     216      importJob.setParameterValue("pipeline", new StringParameterType(), Pipeline.RNA_SEQ.getId());
    217217      if (debug) importJob.setName(importJob.getName() + " (debug)");
    218218      dc.saveItem(importJob);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/FutureSpecimenServlet.java

    r6210 r6211  
    1818import net.sf.basedb.core.ItemNotFoundException;
    1919import net.sf.basedb.core.ItemQuery;
     20import net.sf.basedb.core.Job;
     21import net.sf.basedb.core.Protocol;
    2022import net.sf.basedb.core.Sample;
    2123import net.sf.basedb.core.SessionControl;
     24import net.sf.basedb.core.Software;
     25import net.sf.basedb.opengrid.JobDefinition;
    2226import net.sf.basedb.opengrid.OpenGrid;
    2327import net.sf.basedb.opengrid.OpenGridCluster;
     
    3438import net.sf.basedb.reggie.dao.Fileserver;
    3539import net.sf.basedb.reggie.dao.FutureSpecimen;
     40import net.sf.basedb.reggie.dao.MergedSequences;
    3641import net.sf.basedb.reggie.dao.ReggieRole;
    3742import net.sf.basedb.reggie.dao.SpecimenTube;
    3843import net.sf.basedb.reggie.dao.Subtype;
     44import net.sf.basedb.reggie.grid.ImportFastqJobCreator;
    3945import net.sf.basedb.reggie.grid.ScriptUtil;
    4046import net.sf.basedb.reggie.plugins.FutureSpecimenImporter;
     
    189195        JSONObject jsonReq = JsonUtil.parseRequest(req);
    190196        JSONArray jsonItems = (JSONArray)jsonReq.get("items");
    191        
    192         String clusterId = (String)jsonReq.get("cluster");
    193         boolean debug = Boolean.TRUE.equals(jsonReq.get("debug"));
    194         boolean autoConfirm = Boolean.TRUE.equals(jsonReq.get("autoConfirm"));
    195         Number priority = (Number)jsonReq.get("priority");
    196 
    197         OpenGridCluster cluster = OpenGridService.getInstance().getClusterById(dc, clusterId);
    198         if (cluster == null)
    199         {
    200           throw new ItemNotFoundException("OpenGridCluster[" + clusterId + "]");
    201         }
    202        
     197        JSONObject jsonAutoAnalyze = (JSONObject)jsonReq.get("autoAnalyze");
     198
     199        OpenGridCluster cluster = null;
     200        ImportFastqJobCreator jobCreator = null;
     201        if (jsonAutoAnalyze != null)
     202        {
     203          boolean debug = Boolean.TRUE.equals(jsonAutoAnalyze.get("debug"));
     204          boolean autoConfirm = Boolean.TRUE.equals(jsonAutoAnalyze.get("autoConfirm"));
     205          Number priority = (Number)jsonAutoAnalyze.get("priority");
     206          String clusterId = (String)jsonAutoAnalyze.get("cluster");
     207          Number mergeSoftwareId = (Number)jsonAutoAnalyze.get("mergeSoftware");
     208          Number mergeProtocolId = (Number)jsonAutoAnalyze.get("mergeProtocol");
     209
     210          cluster = OpenGridService.getInstance().getClusterById(dc, clusterId);
     211          if (cluster == null)
     212          {
     213            throw new ItemNotFoundException("OpenGridCluster[" + clusterId + "]");
     214          }
     215          jobCreator = new ImportFastqJobCreator();
     216          jobCreator.setAutoConfirm(autoConfirm);
     217          jobCreator.setDebug(debug);
     218          if (priority != null) jobCreator.setPriority(priority.intValue());
     219          jobCreator.setMergeProtocol(mergeProtocolId != null ? Protocol.getById(dc, mergeProtocolId.intValue()) : null);
     220          jobCreator.setMergeSoftware(mergeSoftwareId != null ? Software.getById(dc, mergeSoftwareId.intValue()) : null);
     221        }
     222
    203223        FileServer importGateway = Fileserver.IMPORT_GATEWAY.load(dc);
    204224        FileServer importArchive = Fileserver.IMPORT_ARCHIVE.load(dc);
     
    212232          gatewaySession = new RemoteHost(new ConnectionInfo(importGateway)).connect(5);
    213233          archiveSession = new RemoteHost(new ConnectionInfo(importArchive)).connect(5);
    214          
     234          List<MergedSequences> mergedSequences = new ArrayList<>(); // Collect MergedSequences that has been created by the importer
    215235          for (int itemNo = 0; itemNo < jsonItems.size(); itemNo++)
    216236          {
     
    239259            else
    240260            {
    241              
    242261              // Add to FASTQ import pipeline
    243262              BiomaterialList.FASTQ_IMPORT_PIPELINE.get(dc).add(items.merged.getItem());
     
    245264              String dataFilesFolder = (String)Annotationtype.DATA_FILES_FOLDER.getAnnotationValue(dc, items.sequencingRun.getItem());
    246265              jsonFile.saveTo(archiveSession, archiveRoot + dataFilesFolder);
    247               //dc.commit();
     266              dc.commit();
    248267              jsonMessages.add("Imported "+specimen.getName()+" with data from "+jsonFile.getName());
     268              mergedSequences.add(items.merged);
    249269              // Remove JSON from Filesever.IMPORT_GATEWAY
    250               //jsonFile.deleteFrom(gatewaySession, gatewayRoot);
     270              jsonFile.deleteFrom(gatewaySession, gatewayRoot);
    251271              if (jsonFile.hasError())
    252272              {
    253273                jsonMessages.addAll(prefix("[Warning]["+jsonFile.getName()+"] ", jsonFile.getErrorMessages()));
    254274              }
    255               if (autoConfirm)
     275            }
     276           
     277            jsonMessages.addAll(prefix("[Warning]["+jsonFile.getName()+"] ", jsonFile.getWarningMessages()));
     278            // jsonMessages.addAll(prefix("[Debug]["+jsonFile.getName()+"] ", jsonFile.getDebugMessages()));
     279          }
     280         
     281          if (jobCreator != null)
     282          {
     283            dc = sc.newDbControl();
     284            List<JobDefinition> jobDefs = jobCreator.createFastqImportJobs(dc, cluster, mergedSequences);
     285            List<Job> jobs = ScriptUtil.submitJobs(dc, cluster, jobDefs);
     286            for (Job job : jobs)
     287            {
     288              if (job.getStatus() == Job.Status.ERROR)
    256289              {
    257                 jsonMessages.add(items.merged.getName()+" added to FASTQ import pipeline");
    258                 // TODO -- implement this
     290                jsonMessages.add("[Warning]Job submission for '" + job.getName() + "' failed: " + job.getStatusMessage());
    259291              }
    260              
    261             }
    262            
    263             jsonMessages.addAll(prefix("[Warning]["+jsonFile.getName()+"] ", jsonFile.getWarningMessages()));
    264             if (debug)
    265             {
    266               jsonMessages.addAll(prefix("[Debug]["+jsonFile.getName()+"] ", jsonFile.getDebugMessages()));
    267             }
    268           }
     292              else
     293              {
     294                jsonMessages.add("Submitted "+job.getName()+" to "+cluster.getConnectionInfo().getName()+" with id "+job.getExternalId());
     295              }
     296            }
     297            dc.commit();
     298          }
     299         
    269300        }
    270301        finally
Note: See TracChangeset for help on using the changeset viewer.