Changeset 5826


Ignore:
Timestamp:
Feb 18, 2020, 2:15:48 PM (22 months ago)
Author:
Nicklas Nordborg
Message:

References #1218: Implement MIPs alignment

Started to implement this wizard. A GUI for selecting merged sequences has been created. Functionality for submitting a job to the cluster has been implemented, but the script will not do anything except copy the FASTQ files to the temporary working directory on the node.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/config/reggie-config.xml

    r5816 r5826  
    319319      </align-hisat>
    320320     
     321      <!-- settings for aligning MIPs sequencing -->
     322      <align-mips>
     323        <!-- parallel environment option to the queue system -->
     324        <!-- the default setting use up to 16 slots on hosts with at least 8 slots available -->
     325        <parallel-environment>smp 8-16</parallel-environment>
     326       
     327      </align-mips>
     328     
    321329      <mbaf>
    322330        <!-- parallel environment option to the queue system -->
  • extensions/net.sf.basedb.reggie/trunk/resources/index.jsp

    r5801 r5826  
    991991              </ul>
    992992            </dd>
     993           
     994            <dt>
     995              <base:icon image="<%=home+"/images/align.png" %>" />
     996              Alignment pipeline
     997            </dt>
     998            <dd>
     999              <ul>
     1000              <li><span class="require-permission" data-role="SecondaryAnalysis" data-link="mipsanalysis/align_start.jsp?ID=<%=ID%>"
     1001                >Start MIPs alignment</span>
     1002                <span class="counter" data-counter="merged-sequences-for-mips-alignment"
     1003                  title="Number of merged sequences waiting for MIPs alignment">∙</span>
     1004                <span id="mips-align-pipeline-disabled" class="info-warning">auto-processing is disabled</span>
     1005              </ul>
     1006            </dd>
     1007           
    9931008          </dl>
    9941009         
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/counter/CounterService.java

    r5737 r5826  
    11741174    json.put("merged-sequences-for-hisat-alignment", hisatPipeline.getSize());
    11751175
     1176    // Items in the MIPs pipeline waiting to be aligned
     1177    ItemList mipsAlignPipeline = BiomaterialList.MIPS_ALIGN_PIPELINE.load(dc);
     1178    json.put("merged-sequences-for-mips-alignment", mipsAlignPipeline.getSize());
     1179   
    11761180    // Hisat aligned sequences not confirmed
    11771181    query = DerivedBioAssay.getQuery();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r5774 r5826  
    310310  */
    311311  public static final Subtype HISAT_ALIGN_JOB = new Subtype("HisatAlign", null, null, null, Item.JOB, false);
     312
     313  /**
     314    The definition of the MIPs alignment job.
     315    @since 4.26
     316  */
     317  public static final Subtype MIPS_ALIGN_JOB = new Subtype("MIPsAlign", null, null, null, Item.JOB, false);
    312318
    313319  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/JobCompletionHandlerFactory.java

    r5772 r5826  
    8787          action = new HisatAlignJobCreator.AlignJobCompletionHandler();
    8888        }
     89        else if (jobType.equals(Subtype.MIPS_ALIGN_JOB.get(dc)))
     90        {
     91          action = new MipsAlignJobCreator.AlignJobCompletionHandler();
     92        }
    8993        else if (jobType.equals(Subtype.TOPHAT_CUFFLINKS_JOB.get(dc)))
    9094        {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r5799 r5826  
    329329        jsonChecks.add(checkSubtype(dc, Subtype.TOPHAT_CUFFLINKS_JOB, null, createIfMissing));
    330330        jsonChecks.add(checkSubtype(dc, Subtype.HISAT_ALIGN_JOB, null, createIfMissing));
     331        jsonChecks.add(checkSubtype(dc, Subtype.MIPS_ALIGN_JOB, null, createIfMissing));
    331332        jsonChecks.add(checkSubtype(dc, Subtype.STRINGTIE_JOB, null, createIfMissing));
    332333        jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_CALLING_SOFTWARE, null, createIfMissing));
     
    668669            createIfMissing, effectivePermissionsUse));
    669670        jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALIGNMENT_TYPE, 1,
    670             new ValueOptions("Tophat", "Hisat"),
     671            new ValueOptions("Tophat", "Hisat", "MIPs"),
    671672            createIfMissing, effectivePermissionsUse));
    672673        jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXPRESSION_TYPE, 1,
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/MipsServlet.java

    r5791 r5826  
    2727import net.sf.basedb.core.BioWell;
    2828import net.sf.basedb.core.DbControl;
     29import net.sf.basedb.core.DerivedBioAssay;
    2930import net.sf.basedb.core.Extract;
    3031import net.sf.basedb.core.File;
     
    3233import net.sf.basedb.core.Item;
    3334import net.sf.basedb.core.ItemList;
     35import net.sf.basedb.core.ItemNotFoundException;
    3436import net.sf.basedb.core.ItemQuery;
    3537import net.sf.basedb.core.ItemSubtype;
     38import net.sf.basedb.core.Job;
    3639import net.sf.basedb.core.Path;
    3740import net.sf.basedb.core.PhysicalBioAssay;
     
    3942import net.sf.basedb.core.Protocol;
    4043import net.sf.basedb.core.SessionControl;
     44import net.sf.basedb.core.Software;
    4145import net.sf.basedb.core.Tag;
    4246import net.sf.basedb.core.Type;
     
    4650import net.sf.basedb.core.query.Orders;
    4751import net.sf.basedb.core.query.Restrictions;
     52import net.sf.basedb.core.snapshot.SnapshotManager;
     53import net.sf.basedb.opengrid.JobDefinition;
     54import net.sf.basedb.opengrid.OpenGridCluster;
     55import net.sf.basedb.opengrid.service.OpenGridService;
    4856import net.sf.basedb.reggie.JsonUtil;
    4957import net.sf.basedb.reggie.Reggie;
     
    5765import net.sf.basedb.reggie.dao.FlowCell;
    5866import net.sf.basedb.reggie.dao.Library;
     67import net.sf.basedb.reggie.dao.MergedSequences;
    5968import net.sf.basedb.reggie.dao.Pipeline;
    6069import net.sf.basedb.reggie.dao.PooledLibrary;
     
    6473import net.sf.basedb.reggie.dao.Rna;
    6574import net.sf.basedb.reggie.dao.Subtype;
     75import net.sf.basedb.reggie.grid.MipsAlignJobCreator;
     76import net.sf.basedb.reggie.grid.ScriptUtil;
    6677import net.sf.basedb.reggie.plugins.AliquotImporter;
    6778import net.sf.basedb.reggie.plugins.AliquotImporter.AliquotPlate;
     
    8293  {}
    8394
     95  @SuppressWarnings("unchecked")
    8496  @Override
    8597  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     
    429441        int numNames = Values.getInt(req.getParameter("numNames"));
    430442        json.put("names", FlowCell.getNextNames(dc, numNames));
     443      }
     444      else if ("GetMergedSequencesForAlignment".equals(cmd))
     445      {
     446        dc = sc.newDbControl();
     447       
     448        List<MergedSequences> list = null;
     449        String items = Values.getStringOrNull(req.getParameter("items"));
     450        if (items == null)
     451        {
     452          // Load items from the pipeline list
     453          ItemList mipsPipeline = BiomaterialList.MIPS_ALIGN_PIPELINE.load(dc);
     454          ItemQuery<DerivedBioAssay> query = (ItemQuery<DerivedBioAssay>)mipsPipeline.getMembers();
     455          query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     456          Subtype.MERGED_SEQUENCES.addFilter(dc, query);
     457          // Join LibPlate for sorting
     458          query.join(Hql.innerJoin(null, "extract", "lib", true));
     459          query.join(Hql.innerJoin("lib", "bioWell", "bw", true));
     460          query.join(Hql.innerJoin("bw", "bioPlate", "libPlate", true));
     461          query.order(Orders.asc(Hql.property("libPlate", "id")));
     462          query.order(Orders.asc(Hql.property("name")));
     463          query.setMaxResults(250);
     464          list = MergedSequences.toList(query.list(dc));
     465        }
     466        else
     467        {
     468          Integer[] ids = Values.getInt(items.split(","));
     469          list = new ArrayList<MergedSequences>();
     470          for (Integer id : ids)
     471          {
     472            list.add(MergedSequences.getById(dc, id));
     473          }
     474        }
     475
     476        SnapshotManager manager = new SnapshotManager();
     477        JSONArray jsonMergedSequences = new JSONArray();
     478        for (MergedSequences ms : list)
     479        {
     480          ms.loadAnnotations(dc, "pipeline", Annotationtype.PIPELINE, null);
     481          Library lib = ms.getLibrary(dc);
     482          lib.loadBioPlateLocation();
     483          ms.setAnnotation("lib", lib.asJSONObject());
     484          ms.loadAnnotations(dc, manager, "AutoProcess", Annotationtype.AUTO_PROCESSING, null);
     485          ms.loadDoNotUseAnnotations(dc, manager);
     486          jsonMergedSequences.add(ms.asJSONObject());
     487        }
     488        json.put("mergedSequences", jsonMergedSequences);       
    431489      }
    432490
     
    925983        dc.commit();
    926984      }
     985      else if ("StartMipsAlignment".equals(cmd))
     986      {
     987        dc = sc.newDbControl();
     988
     989        ReggieRole.checkPermission(dc, "'" + cmd + "' wizard", ReggieRole.MIPS_SECONDARY_ANALYSIS, ReggieRole.ADMINISTRATOR);
     990
     991        JSONObject jsonReq = JsonUtil.parseRequest(req);
     992        JSONArray jsonMerged = (JSONArray)jsonReq.get("mergedSequences");
     993       
     994        Number alignSoftwareId = (Number)jsonReq.get("alignSoftware");
     995        Number alignProtocolId = (Number)jsonReq.get("alignProtocol");
     996       
     997        String clusterId = (String)jsonReq.get("cluster");
     998        boolean debug = Boolean.TRUE.equals(jsonReq.get("debug"));
     999        boolean autoConfirm = Boolean.TRUE.equals(jsonReq.get("autoConfirm"));
     1000        Number priority = (Number)jsonReq.get("priority");
     1001
     1002        OpenGridCluster cluster = OpenGridService.getInstance().getClusterById(dc, clusterId);
     1003        if (cluster == null)
     1004        {
     1005          throw new ItemNotFoundException("OpenGridCluster[" + clusterId + "]");
     1006        }
     1007       
     1008        // Load common items
     1009        Software alignSoftware = alignSoftwareId != null ? Software.getById(dc, alignSoftwareId.intValue()) : null;
     1010        Protocol alignProtocol = alignProtocolId != null ? Protocol.getById(dc, alignProtocolId.intValue()) : null;
     1011
     1012        // Align job creator implementation
     1013        MipsAlignJobCreator jobCreator = new MipsAlignJobCreator();
     1014        jobCreator.setAutoConfirm(autoConfirm);
     1015        jobCreator.setDebug(debug);
     1016        jobCreator.setPriority(priority == null ? null : priority.intValue());
     1017        jobCreator.setAlignProtocol(alignProtocol);
     1018        jobCreator.setAlignSoftware(alignSoftware);
     1019
     1020        List<MergedSequences> mergedSequences = new ArrayList<MergedSequences>();
     1021        for (int mgNo = 0; mgNo < jsonMerged.size(); mgNo++)
     1022        {
     1023          JSONObject jsonMg = (JSONObject)jsonMerged.get(mgNo);
     1024          Number mergedId = (Number)jsonMg.get("id");
     1025       
     1026          MergedSequences ms = MergedSequences.getById(dc, mergedId.intValue());
     1027          mergedSequences.add(ms);
     1028
     1029          // Reset AUTO_PROCESSING annotation
     1030          DerivedBioAssay merged = ms.getDerivedBioAssay();
     1031          Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, merged, null);
     1032        }
     1033       
     1034        List<JobDefinition> jobDefs = jobCreator.createMipsAlignJobs(dc, cluster, mergedSequences);
     1035        List<Job> jobs = ScriptUtil.submitJobs(dc, cluster, jobDefs);
     1036        for (Job job : jobs)
     1037        {
     1038          if (job.getStatus() == Job.Status.ERROR)
     1039          {
     1040            jsonMessages.add("[Error]Job submission for '" + job.getName() + "' failed: " + job.getStatusMessage());
     1041          }
     1042          else
     1043          {
     1044            jsonMessages.add("Submitted MIPs alignment job to " + cluster.getConnectionInfo().getName() + " with id " + job.getExternalId());
     1045          }
     1046        }
     1047        dc.commit();
     1048      }
    9271049      json.put("messages", jsonMessages);
    9281050      CounterService.getInstance().setForceCount();
Note: See TracChangeset for help on using the changeset viewer.