Examples of PacBioStatus


Examples of uk.ac.bbsrc.tgac.miso.core.data.impl.pacbio.PacBioStatus

      if (!"".equals(status)) {
        try {
          //String runLog = run.getString("status");
          if (!status.startsWith("ERROR")) {
            Status is = new PacBioStatus(status);
            is.setHealth(ht);
            is.setRunName(runName);

            Run r = null;

            Matcher m = p.matcher(runName);
            if (m.matches()) {
              try {
                r = requestManager.getRunByAlias(runName);
              }
              catch(IOException ioe) {
                log.warn("Cannot find run by this alias. This usually means the run hasn't been previously imported. If attemptRunPopulation is false, processing will not take place for this run!");
              }
            }

            if (attemptRunPopulation) {
              if (r == null) {
                log.info("\\_ Saving new run and status: " + is.getRunName());
                r = new PacBioRun(status);
                r.setAlias(run.getString("runName"));
                r.setDescription(m.group(2));
                r.setPairedEnd(false);

                if (run.has("fullPath")) {
                  r.setFilePath(run.getString("fullPath"));
                }

                SequencerReference sr = null;
                if (run.has("sequencerName")) {
                  sr = requestManager.getSequencerReferenceByName(run.getString("sequencerName"));
                }

                if (sr != null) {
                  if (run.has("startDate") && !"".equals(run.getString("startDate"))) {
                    try {
                      r.getStatus().setStartDate(startDateFormat.parse(run.getString("startDate")));
                    }
                    catch (ParseException e) {
                      log.error(e.getMessage());
                      e.printStackTrace();
                    }
                  }

                  if (run.has("completionDate") && !"".equals(run.getString("completionDate"))) {
                    try {
                      r.getStatus().setCompletionDate(startDateFormat.parse(run.getString("completionDate")));
                    }
                    catch (ParseException e) {
                      log.error(e.getMessage());
                      e.printStackTrace();
                    }
                  }

                  is.setInstrumentName(sr.getName());
                  r.setStatus(is);

                  r.setSequencerReference(sr);
                }
                else {
                  log.error("\\_ Cannot save " + is.getRunName() + ": no sequencer reference available.");
                }
              }
              else {
                log.info("\\_ Updating existing run and status: " + is.getRunName());

                r.setPlatformType(PlatformType.PACBIO);
                r.setDescription(m.group(2));
                r.setPairedEnd(false);

                if (r.getSequencerReference() == null) {
                  SequencerReference sr = null;
                  if (run.has("sequencerName")) {
                    sr = requestManager.getSequencerReferenceByName(run.getString("sequencerName"));
                  }

                  if (sr != null) {
                    r.getStatus().setInstrumentName(sr.getName());
                    r.setSequencerReference(sr);
                  }
                }

                if (r.getSequencerReference() != null) {
                  if (run.has("startDate") && !"".equals(run.getString("startDate"))) {
                    try {
                      r.getStatus().setStartDate(startDateFormat.parse(run.getString("startDate")));
                    }
                    catch (ParseException e) {
                      log.error(e.getMessage());
                      e.printStackTrace();
                    }
                  }

                  if (run.has("completionDate") && !"".equals(run.getString("completionDate"))) {
                    try {
                      r.getStatus().setCompletionDate(startDateFormat.parse(run.getString("completionDate")));
                    }
                    catch (ParseException e) {
                      log.error(e.getMessage());
                      e.printStackTrace();
                    }
                  }

                  //update path if changed
                  if (run.has("fullPath") && !"".equals(run.getString("fullPath")) && r.getFilePath() != null && !"".equals(r.getFilePath())) {
                    if (!run.getString("fullPath").equals(r.getFilePath())) {
                      log.info("Updating run file path:" + r.getFilePath() + " -> " + run.getString("fullPath"));
                      r.setFilePath(run.getString("fullPath"));
                    }
                  }

                  // update status if run isn't completed or failed
                  if (!r.getStatus().getHealth().equals(HealthType.Completed) && !r.getStatus().getHealth().equals(HealthType.Failed)) {
                    log.info("Saving previously saved status: " + is.getRunName() + " (" + r.getStatus().getHealth().getKey() + " -> " + is.getHealth().getKey() + ")");
                    //if (!r.getStatus().getHealth().equals(is.getHealth())) {
                    r.setStatus(is);
                    //}
                    //requestManager.saveStatus(is);
                  }
                }
              }

              if (r.getSequencerReference() != null) {
                List<SequencerPartitionContainer<SequencerPoolPartition>> fs = ((PacBioRun)r).getSequencerPartitionContainers();
                if (fs.isEmpty()) {
                  if (run.has("plateId") && !"".equals(run.getString("plateId"))) {
                    Collection<SequencerPartitionContainer<SequencerPoolPartition>> pfs =
                            requestManager.listSequencerPartitionContainersByBarcode(run.getString("plateId"));
                    if (!pfs.isEmpty()) {
                      if (pfs.size() == 1) {
                        SequencerPartitionContainer<SequencerPoolPartition> lf = new ArrayList<SequencerPartitionContainer<SequencerPoolPartition>>(pfs).get(0);
                        if (lf.getSecurityProfile() != null && r.getSecurityProfile() == null) {
                          r.setSecurityProfile(lf.getSecurityProfile());
                        }
                        if (lf.getPlatformType() == null && r.getPlatformType() != null) {
                          lf.setPlatformType(r.getPlatformType());
                        }
                        else {
                          lf.setPlatformType(PlatformType.PACBIO);
                        }
                        ((RunImpl)r).addSequencerPartitionContainer(lf);
                      }
                      else {
                        //more than one flowcell hit to this barcode
                        log.warn(r.getAlias() + ":: More than one container has this barcode. Cannot automatically link to a pre-existing barcode.");
                      }
                    }
                    else {
                      if (run.has("cells")) {
                        JSONArray cells = run.getJSONArray("cells");
                        SequencerPartitionContainer f = new SequencerPartitionContainerImpl();
                        f.setPartitionLimit(cells.size());
                        f.initEmptyPartitions();
                        if (run.has("plateId") && !"".equals(run.getString("plateId"))) {
                          f.setIdentificationBarcode(run.getString("plateId"));
                        }
                        if (f.getPlatformType() == null && r.getPlatformType() != null) {
                          f.setPlatformType(r.getPlatformType());
                        }
                        else {
                          f.setPlatformType(PlatformType.PACBIO);
                        }
                        f.setRun(r);
                        log.info("\\_ Created new container with "+f.getPartitions().size()+" partitions");
                        long flowId = requestManager.saveSequencerPartitionContainer(f);
                        f.setId(flowId);
                        ((RunImpl)r).addSequencerPartitionContainer(f);
                        //TODO match up samples to libraries and pools?
                        /*
                        for (JSONObject obj : (Iterable<JSONObject>)cells) {
                          int cellindex = obj.getInt("index");
                          String sample = obj.getString("sample");

                          SequencerPoolPartition p = f.getPartitionAt(cellindex);
                          if (p.getPool() == null) {
                            Pool pool = new PoolImpl();

                          }
                        }
                        */
                      }
                    }
                  }
                }
                else {
                  SequencerPartitionContainer f = fs.iterator().next();
                  f.setSecurityProfile(r.getSecurityProfile());
                  if (f.getPlatformType() == null && r.getPlatformType() != null) {
                    f.setPlatformType(r.getPlatformType());
                  }
                  else {
                    f.setPlatformType(PlatformType.PACBIO);
                  }
                  if (f.getIdentificationBarcode() == null || "".equals(f.getIdentificationBarcode())) {
                    if (run.has("plateId") && !"".equals(run.getString("plateId"))) {
                      f.setIdentificationBarcode(run.getString("plateId"));
                      requestManager.saveSequencerPartitionContainer(f);
                    }
                  }
                }

                updatedRuns.put(r.getAlias(), r);
                runsToSave.add(r);
              }
            }
            else {
              log.warn("\\_ Run not saved. Saving status: " + is.getRunName());
              requestManager.saveStatus(is);
            }
          }
        }
        catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.