@Override
  public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException {
    Set<File> filePaths = new HashSet<File>();
    if ((partition.getSequencerPartitionContainer().getRun().getFilePath()) == null) {
      throw new SubmissionException("No valid run filepath!");
    }

    Pool<? extends Poolable> pool = partition.getPool();
    if (pool == null) {
      throw new SubmissionException("partition.getPool=null!");
    } else {
      Collection<Experiment> experiments = pool.getExperiments();
      if (experiments.isEmpty()) {
        throw new SubmissionException("Collection or experiments is empty");
      } else {
        Collection<? extends Dilution> libraryDilutions = pool.getDilutions();
        if (libraryDilutions.isEmpty()) {
          throw new SubmissionException("Collection of libraryDilutions is empty");
        } else {
          for (Dilution l : libraryDilutions) {
            Set<File> files = generateFilePath(partition, l);
            filePaths.addAll(files);
          }
        }
      }
    }
    return filePaths;
  }
 @Override
 public Set<File> generateFilePath(SequencerPoolPartition partition, Dilution l)
     throws SubmissionException {
   Pool<? extends Poolable> pool = partition.getPool();
   if (pool != null) {
     if (pool.getExperiments() != null) {
       Collection<Experiment> experiments = pool.getExperiments();
       Experiment experiment = experiments.iterator().next();
       StringBuilder filePath = new StringBuilder();
       if (!"".equals(basePath)) {
         filePath.append(
             partition.getSequencerPartitionContainer().getRun().getFilePath()
                 + "/Data/Intensities/BaseCalls/PAP/Project_"
                 + experiment.getStudy().getProject().getAlias()
                 + "/Sample_"
                 + l.getLibrary().getName()
                 + "/"
                 + l.getLibrary().getName());
       } else {
         filePath.append(
             basePath
                 + "/"
                 + experiment.getStudy().getProject().getAlias()
                 + "/Sample_"
                 + l.getLibrary().getName()
                 + "/"
                 + l.getLibrary().getName());
       }
       if (l.getLibrary().getTagBarcodes() != null && !l.getLibrary().getTagBarcodes().isEmpty()) {
         filePath.append("_");
         for (TagBarcode tb : l.getLibrary().getTagBarcodes().values()) {
           filePath.append(tb.getSequence());
         }
       }
       filePath.append("_L00" + partition.getPartitionNumber() + "*.fastq.gz");
       Set<File> files = new HashSet<File>();
       files.add(new File(filePath.toString()));
       return files;
     } else {
       throw new SubmissionException("partition.getPool=null!");
     }
   } else {
     throw new SubmissionException("Collection of experiments is empty");
   }
 }
  @Override
  public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException {
    log.debug("Generating filepaths for partition " + partition.getId());
    Set<File> filePaths = new HashSet<File>();

    Pool pool = partition.getPool();
    if (pool == null) {
      throw new SubmissionException("partition.getPool=null!");
    } else {
      Collection<Experiment> experiments = pool.getExperiments();
      if (experiments.isEmpty()) {
        throw new SubmissionException("Collection or experiments is empty");
      } else {
        Collection<LibraryDilution> libraryDilutions = pool.getDilutions();
        if (libraryDilutions.isEmpty()) {
          throw new SubmissionException("Collection or libraryDilutions is empty");
        } else {
          for (Experiment e : experiments) {
            StringBuilder filePath = new StringBuilder();

            filePath.append(partition.getSequencerPartitionContainer().getRun().getFilePath());
            filePath.append("/Data/Intensities/BaseCalls/PAP/Project_");
            filePath.append(e.getStudy().getProject().getAlias());
            filePath.append("/Sample_");

            for (LibraryDilution l : libraryDilutions) {
              // filePath.append(l.getLibrary().getName()+"/");
              /*
                      +l.getLibrary().getName()+"_"+l.getLibrary().getTagBarcode().getSequence());
              filePath.append("L00"+lane.getPartitionNumber())
              */
              String folder = filePath.toString() + l.getLibrary().getName() + "/*.fastq.gz";
              // System.out.println(folder);
              File file = new File(folder);
              filePaths.add(file);
            }
          }
        }
      }
    }
    return (filePaths);
  }
  @Override
  public File generateFilePath(SequencerPoolPartition partition, LibraryDilution l)
      throws SubmissionException {
    log.debug("Generating filepaths for partition " + partition.getId());

    Pool pool = partition.getPool();
    if (pool != null) {
      if (pool.getExperiments() != null) {

        Collection<Experiment> experiments = pool.getExperiments();
        Experiment experiment = experiments.iterator().next();
        // String filePath =
        // lane.getFlowcell().getRun().getFilePath()+"/Data/Intensities/BaseCalls/PAP/Project_"+
        String filePath =
            partition.getSequencerPartitionContainer().getRun().getFilePath()
                + "/Data/Intensities/BaseCalls/PAP/Project_"
                + experiment.getStudy().getProject().getAlias()
                + "/Sample_"
                + l.getLibrary().getName()
                + "/"
                + l.getLibrary().getName()
                + "_"
                + l.getLibrary().getTagBarcode().getSequence()
                + "_L00"
                + partition.getPartitionNumber()
                + "*.fastq.gz";
        // System.out.println(filePath);
        File file = new File(filePath);
        return (file);
      } else {
        throw new SubmissionException("partition.getPool=null!");
      }
    } else {
      throw new SubmissionException("Collection of experiments is empty");
    }
  }
Exemplo n.º 5
0
  @RequestMapping(value = "project/{projectId}", method = RequestMethod.GET)
  public @ResponseBody String jsonRestProject(@PathVariable Long projectId, ModelMap model)
      throws IOException {
    StringBuilder sb = new StringBuilder();

    Project p = requestManager.getProjectById(projectId);
    sb.append("'id':'" + projectId + "'");
    sb.append(",");
    sb.append("'name':'" + p.getName() + "'");
    sb.append(",");
    sb.append("'alias':'" + p.getAlias() + "'");
    sb.append(",");
    sb.append("'progress':'" + p.getProgress().name() + "'");
    sb.append(",");
    sb.append("'description':'" + p.getDescription() + "'");
    sb.append(",");

    sb.append("'overviews':[");
    if (p.getOverviews().size() > 0) {
      int oi = 0;
      for (ProjectOverview overview : p.getOverviews()) {
        oi++;
        sb.append("{");
        sb.append("'allSampleQcPassed':" + overview.getAllSampleQcPassed());
        sb.append(",");
        sb.append("'libraryPreparationComplete':" + overview.getLibraryPreparationComplete());
        sb.append(",");
        sb.append("'allLibrariesQcPassed':" + overview.getAllLibrariesQcPassed());
        sb.append(",");
        sb.append("'allPoolsConstructed':" + overview.getAllPoolsConstructed());
        sb.append(",");
        sb.append("'allRunsCompleted':" + overview.getAllRunsCompleted());
        sb.append(",");
        sb.append("'primaryAnalysisCompleted':" + overview.getPrimaryAnalysisCompleted());
        sb.append("}");
        if (oi < p.getOverviews().size()) {
          sb.append(",");
        }
      }
    }
    sb.append("]");
    sb.append(",");

    sb.append("'samples':[");
    Collection<Sample> samples = requestManager.listAllSamplesByProjectId(projectId);
    if (samples.size() > 0) {
      int si = 0;
      for (Sample sample : samples) {
        si++;
        String sampleQubit = "not available";
        if (requestManager.listAllSampleQCsBySampleId(sample.getId()).size() > 0) {
          ArrayList<SampleQC> sampleQcList =
              new ArrayList(requestManager.listAllSampleQCsBySampleId(sample.getId()));
          SampleQC lastQc = sampleQcList.get(sampleQcList.size() - 1);
          sampleQubit = (lastQc.getResults() != null ? lastQc.getResults().toString() : "");
        }
        sb.append("{");
        sb.append("'alias':'" + sample.getAlias() + "'");
        sb.append(",");
        sb.append(
            "'qcPassed':'"
                + (sample.getQcPassed() != null ? sample.getQcPassed().toString() : "")
                + "'");
        sb.append(",");

        sb.append(
            "'receivedDate':'"
                + (sample.getReceivedDate() != null
                    ? LimsUtils.getDateAsString(sample.getReceivedDate())
                    : "not available")
                + "'");
        sb.append(",");
        sb.append(
            "'sampleType':'"
                + (sample.getSampleType() != null ? sample.getSampleType() : "")
                + "'");
        sb.append(",");
        sb.append("'sampleQubit':'" + sampleQubit + "'");
        sb.append("}");

        if (si < samples.size()) {
          sb.append(",");
        }
      }
    }
    sb.append("]");
    sb.append(",");

    sb.append("'runs':[");
    Collection<Run> runs = requestManager.listAllRunsByProjectId(projectId);
    if (runs.size() > 0) {
      int ri = 0;
      for (Run run : runs) {
        ri++;
        if (!run.getStatus().getHealth().getKey().equals("Failed")) {
          ArrayList<String> runSamples = new ArrayList();
          Collection<SequencerPartitionContainer<SequencerPoolPartition>> spcs =
              requestManager.listSequencerPartitionContainersByRunId(run.getId());
          if (spcs.size() > 0) {
            for (SequencerPartitionContainer<SequencerPoolPartition> spc : spcs) {

              if (spc.getPartitions().size() > 0) {
                for (SequencerPoolPartition spp : spc.getPartitions()) {
                  if (spp.getPool() != null) {
                    if (spp.getPool().getDilutions().size() > 0) {
                      for (Dilution dilution : spp.getPool().getDilutions()) {
                        Sample sample = dilution.getLibrary().getSample();
                        if (sample.getProject().equals(p)) {
                          runSamples.add(sample.getAlias());
                        }
                      }
                    }
                  }
                }
              }
            }
          }

          sb.append("{");
          sb.append("'name':'" + run.getName() + "'");
          sb.append(",");
          sb.append(
              "'status':'"
                  + (run.getStatus() != null && run.getStatus().getHealth() != null
                      ? run.getStatus().getHealth().getKey()
                      : "")
                  + "'");
          sb.append(",");
          sb.append(
              "'startDate':'"
                  + (run.getStatus() != null && run.getStatus().getStartDate() != null
                      ? run.getStatus().getStartDate().toString()
                      : "")
                  + "'");
          sb.append(",");
          sb.append(
              "'completionDate':'"
                  + (run.getStatus() != null && run.getStatus().getCompletionDate() != null
                      ? run.getStatus().getCompletionDate().toString()
                      : "")
                  + "'");
          sb.append(",");
          sb.append(
              "'platformType':'"
                  + (run.getPlatformType() != null ? run.getPlatformType().getKey() : "")
                  + "'");
          sb.append(",");
          sb.append("'samples':[");
          if (runSamples.size() > 0) {
            int rsi = 0;
            for (String alias : runSamples) {
              rsi++;
              sb.append("{'sampleAlias':'" + alias + "'}");
              if (rsi < runSamples.size()) {
                sb.append(",");
              }
            }
          }
          sb.append("]");
          sb.append("}");
          if (ri < runs.size()) {
            sb.append(",");
          }
        }
      }
    }
    sb.append("]");

    return "{" + sb.toString() + "}";
  }