コード例 #1
0
ファイル: MultiExperiment.java プロジェクト: Presage/Presage2
 @Override
 public Experiment build() throws InvalidParametersException {
   for (Experiment e : experiments) {
     e.build();
   }
   this.exprIt = experiments.iterator();
   return this;
 }
コード例 #2
0
  /**
   * Pushes a host back onto the queue of available hosts and attempts to launch a waiting
   * experiment (if any).
   *
   * @param hostNum the index of the host to push back onto the queue of available hosts
   */
  protected synchronized void availableHost(int hostNum) {
    if (hostNum >= 0) {
      if (m_remoteHostFailureCounts[hostNum] < MAX_FAILURES) {
        m_remoteHostsQueue.push(new Integer(hostNum));
      } else {
        notifyListeners(
            false,
            true,
            false,
            "Max failures exceeded for host "
                + ((String) m_remoteHosts.elementAt(hostNum))
                + ". Removed from host list.");
        m_removedHosts++;
      }
    }

    // check for all sub exp complete or all hosts failed or failed count
    // exceeded
    if (m_failedCount == (MAX_FAILURES * m_remoteHosts.size())) {
      abortExperiment();
      notifyListeners(
          false, true, true, "Experiment aborted! Max failures " + "exceeded on all remote hosts.");
      return;
    }

    if ((getSplitByDataSet() && (m_baseExperiment.getDatasets().size() == m_finishedCount))
        || (getSplitByProperty() && (m_baseExperiment.getPropertyArrayLength() == m_finishedCount))
        || (!getSplitByDataSet()
            && !getSplitByProperty()
            && (getRunUpper() - getRunLower() + 1) == m_finishedCount)) {
      notifyListeners(false, true, false, "Experiment completed successfully.");
      notifyListeners(false, true, true, postExperimentInfo());
      return;
    }

    if (checkForAllFailedHosts()) {
      return;
    }

    if (m_experimentAborted
        && (m_remoteHostsQueue.size() + m_removedHosts) == m_remoteHosts.size()) {
      notifyListeners(false, true, true, "Experiment aborted. All remote tasks " + "finished.");
    }

    if (!m_subExpQueue.empty() && !m_experimentAborted) {
      if (!m_remoteHostsQueue.empty()) {
        int availHost, waitingExp;
        try {
          availHost = ((Integer) m_remoteHostsQueue.pop()).intValue();
          waitingExp = ((Integer) m_subExpQueue.pop()).intValue();
          launchNext(waitingExp, availHost);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    }
  }
コード例 #3
0
ファイル: MultiExperiment.java プロジェクト: Presage/Presage2
 @Override
 public Simulation next() {
   if (exprIt == null) {
     throw new RuntimeException("Iterator not initialised, please call build()");
   }
   if (current == null || !current.hasNext()) {
     if (exprIt.hasNext()) current = exprIt.next();
     else throw new NoSuchElementException();
   }
   return current.next();
 }
コード例 #4
0
ファイル: JppfComputer.java プロジェクト: JonathanVK/RinSim
    @Override
    public void run() {
      // gather data from provider
      final DataProvider dataProvider = getDataProvider();
      checkNotNull(
          dataProvider,
          "Probable problem: your MASConfiguration/ObjectiveFunction/"
              + "PostProcessor is not fully serializable.");

      final Supplier<Scenario> scenario = getDataProvider().getParameter(scenarioId);
      final MASConfiguration configuration = getDataProvider().getParameter(configurationId);
      final ObjectiveFunction objectiveFunction =
          getDataProvider().getParameter(objectiveFunctionId);
      final PostProcessor<?> postProcessor = getDataProvider().getParameter(postProcessorId);

      final Scenario s = scenario.get();
      final SimArgs simArgs =
          SimArgs.create(s, configuration, seed, objectiveFunction, false, postProcessor, null);
      final Object simResult = Experiment.perform(simArgs);

      checkArgument(
          simResult instanceof Serializable,
          "Your PostProcessor must generate Serializable objects, found %s.",
          simResult);

      setResult(simResult);
    }
コード例 #5
0
  @Override
  public AbstractMultiConfExperiment clone() throws CloneNotSupportedException {
    AbstractMultiConfExperiment e = (AbstractMultiConfExperiment) super.clone();

    if (baseExperiment != null) e.baseExperiment = baseExperiment.clone();

    return e;
  }
コード例 #6
0
 @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");
   }
 }
コード例 #7
0
ファイル: Alternative.java プロジェクト: openpreserve/plato
 /** @see ITouchable#handleChanges(IChangesHandler) */
 public void handleChanges(IChangesHandler h) {
   h.visit(this);
   // call handleChanges of all child elementss
   experiment.handleChanges(h);
   resourceDescription.handleChanges(h);
   // manually created alternatives obviously don't have related
   // preservation actions
   if (action != null) action.handleChanges(h);
 }
コード例 #8
0
  /**
   * Overides toString in Experiment
   *
   * @return a description of this remote experiment
   */
  @Override
  public String toString() {
    String result = m_baseExperiment.toString();

    result += "\nRemote Hosts:\n";
    for (int i = 0; i < m_remoteHosts.size(); i++) {
      result += ((String) m_remoteHosts.elementAt(i)) + '\n';
    }
    return result;
  }
コード例 #9
0
  @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);
  }
コード例 #10
0
 /**
  * Set the base experiment. A sub experiment will be created for each run in the base experiment.
  *
  * @param base the base experiment to use.
  * @throws Exception if supplied base experiment is null
  */
 public void setBaseExperiment(Experiment base) throws Exception {
   if (base == null) {
     throw new Exception("Base experiment is null!");
   }
   m_baseExperiment = base;
   setRunLower(m_baseExperiment.getRunLower());
   setRunUpper(m_baseExperiment.getRunUpper());
   setResultListener(m_baseExperiment.getResultListener());
   setResultProducer(m_baseExperiment.getResultProducer());
   setDatasets(m_baseExperiment.getDatasets());
   setUsePropertyIterator(m_baseExperiment.getUsePropertyIterator());
   setPropertyPath(m_baseExperiment.getPropertyPath());
   setPropertyArray(m_baseExperiment.getPropertyArray());
   setNotes(m_baseExperiment.getNotes());
   m_ClassFirst = m_baseExperiment.m_ClassFirst;
   m_AdvanceDataSetFirst = m_baseExperiment.m_AdvanceDataSetFirst;
 }
コード例 #11
0
  /** getXml. */
  @Get
  public void getXml() {
    ExperimentService ss = BeanFactory.getExperimentServiceBean();
    Experiment experiment =
        (Experiment) testIfNull(ss.findBySWAccession(Integer.parseInt(getId())));
    Hibernate3DtoCopier copier = new Hibernate3DtoCopier();
    JaxbObject<Experiment> jaxbTool = new JaxbObject<Experiment>();

    Experiment dto = copier.hibernate2dto(Experiment.class, experiment);
    if (fields.contains("attributes")) {
      Set<ExperimentAttribute> eas = experiment.getExperimentAttributes();
      if (eas != null && !eas.isEmpty()) {
        Set<ExperimentAttribute> newEas = new TreeSet<ExperimentAttribute>();
        for (ExperimentAttribute ea : eas) {
          newEas.add(copier.hibernate2dto(ExperimentAttribute.class, ea));
        }
        dto.setExperimentAttributes(newEas);
      }
    }
    Document line = XmlTools.marshalToDocument(jaxbTool, dto);

    getResponse().setEntity(XmlTools.getRepresentation(line));
  }
コード例 #12
0
ファイル: LimsDAO.java プロジェクト: adwaitpatil/miso-lims
  @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();
    }
  }
コード例 #13
0
  public CellLine getCells(Experiment expt) throws SQLException, UnknownRoleException {

    java.sql.Connection cxn = loader.getConnection();
    PreparedStatement ps = cxn.prepareStatement("select cells from experiment" + " where id=?");
    ps.setInt(1, expt.getDBID());
    ResultSet rs = ps.executeQuery();
    int cellsID = -1;
    if (rs.next()) {
      cellsID = rs.getInt(1);
    }
    rs.close();
    ps.close();

    return chipLoader.loadCellLine(cellsID);
  }
コード例 #14
0
  @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");
    }
  }
コード例 #15
0
 public org.craftsmenlabs.gareth.api.model.Experiment map(final Experiment experiment) {
   org.craftsmenlabs.gareth.api.model.Experiment model =
       new org.craftsmenlabs.gareth.api.model.Experiment();
   model.setExperimentName(experiment.getExperimentName());
   AssumptionBlock block = new AssumptionBlock();
   block.setBaseline(experiment.getBaselineGlueLine());
   block.setAssumption(experiment.getAssumeGlueLine());
   block.setFailure(experiment.getFailureGlueLine());
   block.setSuccess(experiment.getSuccessGlueLine());
   block.setTime(experiment.getTimeGlueLine());
   model.setAssumptionBlockList(Arrays.asList(block));
   return model;
 }
コード例 #16
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);
    int size = buffer.getFrames().size();
    // int start = size-10;

    //	System.out.println("Range: "+start+","+(start+10));

    g.setColor(new Color(255, 255, 255));
    g.fillRect(SCREEN_MINX, SCREEN_MINY, SCREEN_MAXX - SCREEN_MINX, SCREEN_MAXY - SCREEN_MINY);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(SCREEN_MINX, SCREEN_MINY, SCREEN_MAXX - SCREEN_MINX, SCREEN_MAXY - SCREEN_MINY);

    if (size == 0) {
      g.drawString("Empty buffer", 10, 50);
      return;
    }
    //		if(size<10) {
    //			start=0;
    //		}

    // punkt w srodku
    double xM = Calc.recalcAB(middlePoint[0], coefX[0], coefX[1]);
    double yM = Calc.recalcAB(middlePoint[1], coefY[0], coefY[1]);
    double xMiddle = Calc.recalc(xM, -screenX, +screenX, SCREEN_MINX, SCREEN_MAXX);
    double yMiddle = Calc.recalc(yM, -screenY, +screenY, SCREEN_MINY, SCREEN_MAXY);
    yMiddle = SCREEN_MAXY - yMiddle; // ???
    Graph.circle(g, (int) xMiddle, (int) yMiddle, 10);

    // punkty poprzednie
    int frames = (size >= 10) ? 10 : size;
    for (int i = 0; i < frames; i++) {
      //	System.out.println("Reading "+(i+start));
      EyeFrame f = buffer.getFrames().get(i + size - frames);

      // przeliczenie do zakresu -1000,+1000 - 0,0 jesli na srodek
      double xCDeg = Calc.recalcAB(f.eyeX, coefX[0], coefX[1]);
      double yCDeg = Calc.recalcAB(f.eyeY, coefY[0], coefY[1]);

      // przeliczenie na wspó³rzêdne na ekranie
      // TODO wielkoϾ okna ustalona na sztywno... -1000 to lewy brzeg, +1000 to prawy brzeg
      double xScreen = Calc.recalc(xCDeg, -screenX, +screenX, SCREEN_MINX, SCREEN_MAXX);
      double yScreen = Calc.recalc(yCDeg, -screenY, +screenY, SCREEN_MINY, SCREEN_MAXY);

      // wyœwietlenie gaze pointa

      yScreen = SCREEN_MAXY - yScreen; // ???
      Point pScreen = new Point((int) xScreen, (int) yScreen);
      g.drawString(
          f.eyeX + "," + f.eyeY + " [" + (int) xScreen + "," + (int) yScreen + "]",
          5,
          (i * 20) + 50);
      int c = 255 - i * 20; // kolor
      // System.out.println(c);
      g.setColor(new Color(c, c, c));
      int s = i + 1;
      // rzeczywisty gaze point
      Graph.circle(g, pScreen.x, pScreen.y, s);

      // jeœli to ostani punkt - dodatkowo ramka
      if (i == frames - 1) {
        // dwa punkty na osiach
        g.fillRect(pScreen.x, getSize().height / 2 /*pScreen.y*/, s, s);
        g.fillRect(getSize().height / 2 /*pScreen.x*/, pScreen.y, s, s);
        g.drawLine(pScreen.x, getSize().height / 2, getSize().height / 2 /*pScreen.x*/, pScreen.y);

        Dimension d = getSize();
        g.drawString(
            f.eyeX
                + ","
                + f.eyeY
                + " <"
                + (int) xCDeg
                + ","
                + (int) yCDeg
                + "> ["
                + (int) xScreen
                + ","
                + (int) yScreen
                + "]",
            d.width / 2,
            d.height / 2);
        Graph.frame(g, (int) xScreen, (int) yScreen, 50);
      }
    }

    //		g.setColor(new Color(255,0,0));
    //		EyeFrame f = buffer.getFrames().get(size-1);
    //		double xCDeg = Calc.recalcAB(f.eyeX, coefX[0], coefX[1]);
    //		double yCDeg = Calc.recalcAB(f.eyeY, coefY[0], coefY[1]);
    //
    //		//TODO: okno powinno byc obliczone w katach
    //		double xScreen = Calc.recalc(xCDeg, -screenX, +screenX, SCREEN_MINX, SCREEN_MAXX);
    //		double yScreen = Calc.recalc(yCDeg, -screenY, +screenY, SCREEN_MAXY, SCREEN_MINY);
    //
    //		//yScreen = SCREEN_MAXY-yScreen;
    //		Dimension d = getSize();
    //		g.drawString(f.eyeX+","+f.eyeY+" <"+(int)xCDeg+","+(int)yCDeg+">
    // ["+(int)xScreen+","+(int)yScreen+"]", d.width/2, d.height/2);
    //		Graph.frame(g, (int)xScreen, (int)yScreen, 50);

  }
コード例 #17
0
 /**
  * Sets the array of values to set the custom property to.
  *
  * @param newPropArray a value of type Object which should be an array of the appropriate values.
  */
 @Override
 public void setPropertyArray(Object newPropArray) {
   super.setPropertyArray(newPropArray);
   m_baseExperiment.setPropertyArray(newPropArray);
 }
コード例 #18
0
  /**
   * Prepares a remote experiment for running, creates sub experiments
   *
   * @throws Exception if an error occurs
   */
  @Override
  public void initialize() throws Exception {
    if (m_baseExperiment == null) {
      throw new Exception("No base experiment specified!");
    }

    m_experimentAborted = false;
    m_finishedCount = 0;
    m_failedCount = 0;
    m_RunNumber = getRunLower();
    m_DatasetNumber = 0;
    m_PropertyNumber = 0;
    m_CurrentProperty = -1;
    m_CurrentInstances = null;
    m_Finished = false;

    if (m_remoteHosts.size() == 0) {
      throw new Exception("No hosts specified!");
    }
    // initialize all remote hosts to available
    m_remoteHostsStatus = new int[m_remoteHosts.size()];
    m_remoteHostFailureCounts = new int[m_remoteHosts.size()];

    m_remoteHostsQueue = new Queue();
    // prime the hosts queue
    for (int i = 0; i < m_remoteHosts.size(); i++) {
      m_remoteHostsQueue.push(new Integer(i));
    }

    // set up sub experiments
    m_subExpQueue = new Queue();
    int numExps;
    if (getSplitByDataSet()) {
      numExps = m_baseExperiment.getDatasets().size();
    } else if (getSplitByProperty()) {
      numExps = m_baseExperiment.getPropertyArrayLength();
    } else {
      numExps = getRunUpper() - getRunLower() + 1;
    }
    m_subExperiments = new Experiment[numExps];
    m_subExpComplete = new int[numExps];
    // create copy of base experiment
    SerializedObject so = new SerializedObject(m_baseExperiment);

    if (getSplitByDataSet()) {
      for (int i = 0; i < m_baseExperiment.getDatasets().size(); i++) {
        m_subExperiments[i] = (Experiment) so.getObject();
        // one for each data set
        DefaultListModel temp = new DefaultListModel();
        temp.addElement(m_baseExperiment.getDatasets().get(i));
        m_subExperiments[i].setDatasets(temp);
        m_subExpQueue.push(new Integer(i));
      }
    } else if (getSplitByProperty()) {
      for (int i = 0; i < m_baseExperiment.getPropertyArrayLength(); i++) {
        m_subExperiments[i] = (Experiment) so.getObject();
        Object[] a = new Object[1];
        a[0] = m_baseExperiment.getPropertyArrayValue(i);
        m_subExperiments[i].setPropertyArray(a);
        m_subExpQueue.push(new Integer(i));
      }
    } else {
      for (int i = getRunLower(); i <= getRunUpper(); i++) {
        m_subExperiments[i - getRunLower()] = (Experiment) so.getObject();
        // one run for each sub experiment
        m_subExperiments[i - getRunLower()].setRunLower(i);
        m_subExperiments[i - getRunLower()].setRunUpper(i);

        m_subExpQueue.push(new Integer(i - getRunLower()));
      }
    }
  }
コード例 #19
0
ファイル: OME.java プロジェクト: hflynn/bioformats
  protected Element asXMLElement(Document document, Element OME_element) {
    // Creating XML block for OME

    if (OME_element == null) {
      OME_element = document.createElementNS(NAMESPACE, "OME");
    }

    if (uuid != null) {
      // Attribute property UUID
      OME_element.setAttribute("UUID", uuid.toString());
    }
    if (creator != null) {
      // Attribute property Creator
      OME_element.setAttribute("Creator", creator.toString());
    }
    if (projects != null) {
      // Element property Project which is complex (has
      // sub-elements) and occurs more than once
      for (Project projects_value : projects) {
        OME_element.appendChild(projects_value.asXMLElement(document));
      }
    }
    if (datasets != null) {
      // Element property Dataset which is complex (has
      // sub-elements) and occurs more than once
      for (Dataset datasets_value : datasets) {
        OME_element.appendChild(datasets_value.asXMLElement(document));
      }
    }
    if (experiments != null) {
      // Element property Experiment which is complex (has
      // sub-elements) and occurs more than once
      for (Experiment experiments_value : experiments) {
        OME_element.appendChild(experiments_value.asXMLElement(document));
      }
    }
    if (plates != null) {
      // Element property Plate which is complex (has
      // sub-elements) and occurs more than once
      for (Plate plates_value : plates) {
        OME_element.appendChild(plates_value.asXMLElement(document));
      }
    }
    if (screens != null) {
      // Element property Screen which is complex (has
      // sub-elements) and occurs more than once
      for (Screen screens_value : screens) {
        OME_element.appendChild(screens_value.asXMLElement(document));
      }
    }
    if (experimenters != null) {
      // Element property Experimenter which is complex (has
      // sub-elements) and occurs more than once
      for (Experimenter experimenters_value : experimenters) {
        OME_element.appendChild(experimenters_value.asXMLElement(document));
      }
    }
    if (experimenterGroups != null) {
      // Element property ExperimenterGroup which is complex (has
      // sub-elements) and occurs more than once
      for (ExperimenterGroup experimenterGroups_value : experimenterGroups) {
        OME_element.appendChild(experimenterGroups_value.asXMLElement(document));
      }
    }
    if (instruments != null) {
      // Element property Instrument which is complex (has
      // sub-elements) and occurs more than once
      for (Instrument instruments_value : instruments) {
        OME_element.appendChild(instruments_value.asXMLElement(document));
      }
    }
    if (images != null) {
      // Element property Image which is complex (has
      // sub-elements) and occurs more than once
      for (Image images_value : images) {
        OME_element.appendChild(images_value.asXMLElement(document));
      }
    }
    if (structuredAnnotations != null) {
      // Element property StructuredAnnotations which is complex (has
      // sub-elements)
      OME_element.appendChild(structuredAnnotations.asXMLElement(document));
    }
    if (roIs != null) {
      // Element property ROI which is complex (has
      // sub-elements) and occurs more than once
      for (ROI roIs_value : roIs) {
        OME_element.appendChild(roIs_value.asXMLElement(document));
      }
    }
    if (binaryOnly != null) {
      // Element property BinaryOnly which is complex (has
      // sub-elements)
      OME_element.appendChild(binaryOnly.asXMLElement(document));
    }
    return super.asXMLElement(document, OME_element);
  }
コード例 #20
0
ファイル: ExperimentTest.java プロジェクト: jackcobb/CS3114
  /**
   * test method used to generate output for data about fifo. The assert is just to make webcat
   * happy about the test having at least one assert. I'm using the tests to collect data about
   * runtime and path size.
   */
  public void testFIFISol() {
    tester.testFIFO();

    assertNotNull(tester);
  }
コード例 #21
0
 public static ExperimentBuilder aCopyOf(Experiment experiment) {
   return anExperiment()
       .withExperimentSnapshot(experiment.getExperimentSnapshot())
       .withId(experiment.getId())
       .withLastUpdated(experiment.getLastUpdated());
 }
コード例 #22
0
ファイル: MultiExperiment.java プロジェクト: Presage/Presage2
 public Experiment addParameter(String name, Iterable<String> values) {
   for (Experiment e : experiments) {
     e.addParameter(name, values);
   }
   return this;
 }
コード例 #23
0
  /**
   * Sets whether the custom property iterator should be used.
   *
   * @param newUsePropertyIterator true if so
   */
  @Override
  public void setUsePropertyIterator(boolean newUsePropertyIterator) {

    super.setUsePropertyIterator(newUsePropertyIterator);
    m_baseExperiment.setUsePropertyIterator(newUsePropertyIterator);
  }
コード例 #24
0
ファイル: MultiExperiment.java プロジェクト: Presage/Presage2
 @Override
 public boolean hasNext() {
   return exprIt.hasNext() || (current != null && current.hasNext());
 }
コード例 #25
0
ファイル: ExperimentModule.java プロジェクト: samklr/caliper
 public static ExperimentModule forExperiment(Experiment experiment) {
   Method benchmarkMethod = experiment.instrumentation().benchmarkMethod();
   return new ExperimentModule(benchmarkMethod, experiment.userParameters());
 }
コード例 #26
0
ファイル: ExperimentTest.java プロジェクト: jackcobb/CS3114
  /**
   * test method used to generate output for data about the pq. The assert is just to make webcat
   * happy about the test having at least one assert. I'm using the tests to collect data about
   * runtime and path size.
   */
  public void testPQSol() {
    System.out.println("PQ:");
    tester.testPQ();

    assertNotNull(tester);
  }
コード例 #27
0
  /**
   * Sets the path of properties taken to get to the custom property to iterate over.
   *
   * @param newPropertyPath an array of PropertyNodes
   */
  @Override
  public void setPropertyPath(PropertyNode[] newPropertyPath) {

    super.setPropertyPath(newPropertyPath);
    m_baseExperiment.setPropertyPath(newPropertyPath);
  }
コード例 #28
0
  /**
   * Configures/Runs the Experiment from the command line.
   *
   * @param args command line arguments to the Experiment.
   */
  public static void main(String[] args) {

    try {
      weka.core.WekaPackageManager.loadPackages(false, true, false);
      RemoteExperiment exp = null;

      // get options from XML?
      String xmlOption = Utils.getOption("xml", args);
      if (!xmlOption.equals("")) {
        args = new XMLOptions(xmlOption).toArray();
      }

      Experiment base = null;
      String expFile = Utils.getOption('l', args);
      String saveFile = Utils.getOption('s', args);
      boolean runExp = Utils.getFlag('r', args);
      ArrayList<String> remoteHosts = new ArrayList<String>();
      String runHost = " ";
      while (runHost.length() != 0) {
        runHost = Utils.getOption('h', args);
        if (runHost.length() != 0) {
          remoteHosts.add(runHost);
        }
      }
      if (expFile.length() == 0) {
        base = new Experiment();
        try {
          base.setOptions(args);
          Utils.checkForRemainingOptions(args);
        } catch (Exception ex) {
          ex.printStackTrace();
          String result =
              "Usage:\n\n"
                  + "-l <exp file>\n"
                  + "\tLoad experiment from file (default use cli options)\n"
                  + "-s <exp file>\n"
                  + "\tSave experiment to file after setting other options\n"
                  + "\t(default don't save)\n"
                  + "-h <remote host name>\n"
                  + "\tHost to run experiment on (may be specified more than once\n"
                  + "\tfor multiple remote hosts)\n"
                  + "-r \n"
                  + "\tRun experiment on (default don't run)\n"
                  + "-xml <filename | xml-string>\n"
                  + "\tget options from XML-Data instead from parameters\n"
                  + "\n";
          Enumeration<Option> enm = ((OptionHandler) base).listOptions();
          while (enm.hasMoreElements()) {
            Option option = enm.nextElement();
            result += option.synopsis() + "\n";
            result += option.description() + "\n";
          }
          throw new Exception(result + "\n" + ex.getMessage());
        }
      } else {
        Object tmp;

        // KOML?
        if ((KOML.isPresent()) && (expFile.toLowerCase().endsWith(KOML.FILE_EXTENSION))) {
          tmp = KOML.read(expFile);
        } else
        // XML?
        if (expFile.toLowerCase().endsWith(".xml")) {
          XMLExperiment xml = new XMLExperiment();
          tmp = xml.read(expFile);
        }
        // binary
        else {
          FileInputStream fi = new FileInputStream(expFile);
          ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(fi));
          tmp = oi.readObject();
          oi.close();
        }
        if (tmp instanceof RemoteExperiment) {
          exp = (RemoteExperiment) tmp;
        } else {
          base = (Experiment) tmp;
        }
      }
      if (base != null) {
        exp = new RemoteExperiment(base);
      }
      for (int i = 0; i < remoteHosts.size(); i++) {
        exp.addRemoteHost(remoteHosts.get(i));
      }
      System.err.println("Experiment:\n" + exp.toString());

      if (saveFile.length() != 0) {
        // KOML?
        if ((KOML.isPresent()) && (saveFile.toLowerCase().endsWith(KOML.FILE_EXTENSION))) {
          KOML.write(saveFile, exp);
        } else
        // XML?
        if (saveFile.toLowerCase().endsWith(".xml")) {
          XMLExperiment xml = new XMLExperiment();
          xml.write(saveFile, exp);
        }
        // binary
        else {
          FileOutputStream fo = new FileOutputStream(saveFile);
          ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(fo));
          oo.writeObject(exp);
          oo.close();
        }
      }

      if (runExp) {
        System.err.println("Initializing...");
        exp.initialize();
        System.err.println("Iterating...");
        exp.runExperiment();
        System.err.println("Postprocessing...");
        exp.postProcess();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println(ex.getMessage());
    }
  }
コード例 #29
0
  /** {@inheritDoc} */
  @Override
  @Put
  public Representation put(Representation entity) {
    authenticate();
    Representation representation = null;
    Experiment newObj = null;
    JaxbObject<Experiment> jo = new JaxbObject<Experiment>();
    try {
      String text = entity.getText();
      newObj = (Experiment) XmlTools.unMarshal(jo, new Experiment(), text);
    } catch (SAXException ex) {
      ex.printStackTrace();
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, ex);
    } catch (IOException e) {
      e.printStackTrace();
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, e);
    }
    try {
      ExperimentService service = BeanFactory.getExperimentServiceBean();
      Experiment exp = (Experiment) testIfNull(service.findByID(newObj.getExperimentId()));
      exp.givesPermission(registration);

      // simple types
      String title = newObj.getTitle();
      String name = newObj.getName();
      String desc = newObj.getDescription();
      String alias = newObj.getAlias();
      String accession = newObj.getAccession();
      String status = newObj.getStatus();
      String centerName = newObj.getCenterName();
      String sequencerSpace = newObj.getSequenceSpace();
      String baseCaller = newObj.getBaseCaller();
      String qualityScorer = newObj.getQualityScorer();
      Integer qualityNumberLevels = newObj.getQualityNumberOfLevels();
      Integer qualityMultiplier = newObj.getQualityMultiplier();
      Long expectedNumberSpots = newObj.getExpectedNumberSpots();
      Long expectedNumberReads = newObj.getExpectedNumberReads();

      // foreign keys
      Study study = newObj.getStudy();
      Registration owner = newObj.getOwner();

      // sets
      Set<ExperimentAttribute> expAttributes = newObj.getExperimentAttributes();

      if (title != null) {
        exp.setTitle(title);
      }
      if (name != null) {
        exp.setName(name);
      }
      if (desc != null) {
        exp.setDescription(desc);
      }
      if (alias != null) {
        exp.setAlias(alias);
      }
      if (accession != null) {
        exp.setAccession(accession);
      }
      if (status != null) {
        exp.setStatus(status);
      }
      if (centerName != null) {
        exp.setCenterName(centerName);
      }
      if (sequencerSpace != null) {
        exp.setSequenceSpace(sequencerSpace);
      }
      if (baseCaller != null) {
        exp.setBaseCaller(baseCaller);
      }
      if (qualityScorer != null) {
        exp.setQualityScorer(qualityScorer);
      }
      if (qualityNumberLevels != null) {
        exp.setQualityNumberOfLevels(qualityNumberLevels);
      }
      if (qualityMultiplier != null) {
        exp.setQualityMultiplier(qualityMultiplier);
      }
      if (expectedNumberSpots != null) {
        exp.setExpectedNumberSpots(expectedNumberSpots);
      }
      if (expectedNumberReads != null) {
        exp.setExpectedNumberReads(expectedNumberReads);
      }

      if (study != null) {
        StudyService ss = BeanFactory.getStudyServiceBean();
        Study newStudy = ss.findByID(study.getStudyId());
        if (newStudy != null && newStudy.givesPermission(registration)) {
          exp.setStudy(newStudy);
        } else if (newStudy == null) {
          Log.info("Could not be found " + study);
        }
      }

      if (owner != null) {
        RegistrationService rs = BeanFactory.getRegistrationServiceBean();
        Registration newReg = rs.findByEmailAddress(owner.getEmailAddress());
        if (newReg != null) {
          exp.setOwner(newReg);
        } else {
          Log.info("Could not be found " + owner);
        }
      } else if (exp.getOwner() == null) {
        exp.setOwner(registration);
      }

      if (null != expAttributes) {
        exp.getExperimentAttributes().clear();
        for (ExperimentAttribute ea : expAttributes) {
          ea.setExperiment(exp);
          exp.getExperimentAttributes().add(ea);
        }
      }

      service.update(registration, exp);

      Hibernate3DtoCopier copier = new Hibernate3DtoCopier();
      Experiment detachedLane = copier.hibernate2dto(Experiment.class, exp);

      Document line = XmlTools.marshalToDocument(jo, detachedLane);
      representation = XmlTools.getRepresentation(line);
      getResponse().setEntity(representation);
      getResponse()
          .setLocationRef(
              getRequest().getRootRef() + "/experiments/" + detachedLane.getSwAccession());
      getResponse().setStatus(Status.SUCCESS_CREATED);
    } catch (SecurityException e) {
      getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN, e.getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      getResponse().setStatus(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }

    return representation;
  }
コード例 #30
0
ファイル: ExperimentTest.java プロジェクト: jackcobb/CS3114
 /** runs before every test and sets up the testing environment */
 public void setUp() {
   tester = new Experiment();
   tester.moveN(5);
 }