@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);
  }
Exemple #3
0
  @Test
  public void testExperiments() {
    try {
      // get row count of experiments in the dataset
      int expected = getDataSet().getTable("Experiment").getRowCount();

      // get number of experiments from the DAO
      int actual = getExperimentDAO().count();

      // test data contains 2 experiments, check size of returned list
      TestCase.assertEquals("Wrong number of experiments", expected, actual);

      System.out.println("Expected number of experiments: " + expected + ", actual: " + actual);

      for (Experiment d : random(getExperimentDAO(), actual, 5)) {
        TestCase.assertNotNull(d);
        TestCase.assertNotNull(d.getId());
      }
    } catch (Exception e) {
      e.printStackTrace();
      TestCase.fail();
    }
  }
  @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");
    }
  }
  @Deprecated
  public JSONObject previewExperiment(HttpSession session, JSONObject json) {
    String experimentId = (String) json.get("experimentId");

    try {
      Experiment e = requestManager.getExperimentById(Long.parseLong(experimentId));
      Collection<Run> runs = requestManager.listRunsByExperimentId(e.getExperimentId());

      session.setAttribute("experiment", e);

      StringBuilder rb = new StringBuilder();
      for (Run r : runs) {
        rb.append("<li><a href='/miso/run/")
            .append(r.getRunId())
            .append("'>")
            .append(r.getName())
            .append("</a></li>");
      }

      StringBuilder sb = new StringBuilder();
      if (e.getPool() != null) {
        if (e.getPlatform().getPlatformType().equals(PlatformType.ILLUMINA)) {
          for (Object dil : e.getPool().getDilutions()) {
            Sample s = ((LibraryDilution) dil).getLibrary().getSample();
            sb.append("<li><a href='/miso/sample/")
                .append(s.getSampleId())
                .append("'>")
                .append(s.getName())
                .append("</a></li>");
          }
        } else {
          for (Object dil : e.getPool().getDilutions()) {
            Sample s =
                ((emPCRDilution) dil).getEmPCR().getLibraryDilution().getLibrary().getSample();
            sb.append("<li><a href='/miso/sample/")
                .append(s.getSampleId())
                .append("'>")
                .append(s.getName())
                .append("</a></li>");
          }
        }
      }

      StringBuilder b = new StringBuilder();
      b.append(
          "<div onclick=\"Effect.toggle('preview"
              + experimentId
              + "','blind'); return false;\">"
              + "<img src=\"/styles/images/moreinfo.png\" class=\"previewimage\"/></div>");
      b.append("<br/><div id=\"preview" + experimentId + "\" class='exppreview'>");
      b.append("Title: <b>").append(e.getTitle()).append("</b><br/>");
      b.append("Description: <b>").append(e.getDescription()).append("</b><br/>");
      b.append("Samples: <ul class=\"bullets\">").append(sb.toString()).append("</ul>");
      b.append("Runs: <ul class=\"bullets\">").append(rb.toString()).append("</ul>");
      b.append("</div>");
      return JSONUtils.SimpleJSONResponse(b.toString());

    } catch (IOException e) {
      log.debug("Failed", e);
      return JSONUtils.SimpleJSONError("Failed");
    }
  }