コード例 #1
0
  public static void main(String[] args) {
    boolean test = false;

    if (test) {
      File f = new File("Z:\\workspace");
      System.out.println(f.getPath());

      File f2 = new File(f.getPath() + "petulant-batman");
      System.out.println(f2.getPath());
    }

    if (WINDOWS) {
      // StudyBuilder sb = new StudyBuilder("C:\\Studies", StudyBuilder.StudyType.local);
      String root = "C:\\";
      StudyFactory.StudyType type = StudyFactory.StudyType.local;
      List<Study> studies;

      try {
        StudyFactory.setRoot(root);
        studies = Arrays.asList(StudyFactory.getAvailableStudies(type));
        for (Study s : studies) {
          for (String img : s.getImgAddresses()) {
            System.out.println(img);
          }
        }
      } catch (NoValidStudiesFoundException nvsfe) {
        System.out.println(nvsfe);
      }
    } else {
      System.err.println("Please write a test for " + OS + "!");
    }
  }
コード例 #2
0
 public Interview(Study study) {
   interview_time = new Date();
   study_id = study.getId();
   recordings = new ArrayList<Recording>(study.getPhrases().size());
   for (Phrase phrase : study.getPhrases()) {
     Recording recording = new Recording();
     recording.setPhrase_id(phrase.getId());
     recordings.add(recording);
   }
 }
コード例 #3
0
  /*
   * (non-Javadoc)
   * @see mivc.System.ImageProcurator#getReferenceImage(int, mivc.System.Study)
   */
  @Override
  public BufferedImage getReferenceImage(int index, Study study) {
    BufferedImage retVal =
        new BufferedImage(study.getMaxX(), study.getMaxY(), BufferedImage.TYPE_INT_RGB);

    for (int x = 0; x < retVal.getWidth(); x++) {
      for (int y = 0; y < retVal.getHeight(); y++) {
        // Store the current x, y data into the array
        retVal.setRGB(x, y, study.getPixel(x, y, index));
      }
    }

    return retVal;
  }
コード例 #4
0
  private void migrateCourseAgent(
      CourseAgent caSrc,
      ExpeditedAdverseEventReport aeReportDest,
      DomainObjectImportOutcome<ExpeditedAdverseEventReport> outcome) {

    Study study = aeReportDest.getStudy();

    StudyAgent studyAgent = caSrc.getStudyAgent();
    if (studyAgent == null
        || ((studyAgent.getAgent() == null
                || StringUtils.isEmpty(studyAgent.getAgent().getNscNumber()))
            && StringUtils.isEmpty(studyAgent.getOtherAgent()))) {
      outcome.addWarning("ER-CA-1", "Study Agent is missing in the source");
      return;
    }

    StudyAgent realStudyAgent =
        studyAgent.getAgent() == null
            ? study.findStudyAgentByNscOrName(studyAgent.getOtherAgent())
            : study.findStudyAgentByNscOrName(studyAgent.getAgent().getNscNumber());
    if (realStudyAgent == null) {
      outcome.addWarning("ER-CA-2", "Given Agent is no longer associated to the study");
      return;
    }

    CourseAgent caDest = new CourseAgent();
    aeReportDest.getTreatmentInformation().addCourseAgent(caDest);

    // set the study agent
    caDest.setStudyAgent(realStudyAgent);

    caDest.setDose(caSrc.getDose());
    caDest.setAdministrationDelay(caSrc.getAdministrationDelay());
    caDest.setAdministrationDelayAmount(caSrc.getAdministrationDelayAmount());
    caDest.setAdministrationDelayUnits(caSrc.getAdministrationDelayUnits());
    caDest.setComments(caSrc.getComments());
    caDest.setAgentAdjustment(caSrc.getAgentAdjustment());
    caDest.setModifiedDose(caSrc.getModifiedDose());
    caDest.setLastAdministeredDate(caSrc.getLastAdministeredDate());
    caDest.setDurationAndSchedule(caSrc.getDurationAndSchedule());
    caDest.setFirstAdministeredDate(caSrc.getFirstAdministeredDate());
    caDest.setTotalDoseAdministeredThisCourse(caSrc.getTotalDoseAdministeredThisCourse());
    caDest.setFormulation(caSrc.getFormulation());
    caDest.setLotNumber(caSrc.getLotNumber());
  }
コード例 #5
0
  /*
   * (non-Javadoc)
   * @see mivc.System.ImageGetter#getReconstructedImage(int, mivc.System.Study, int, int)
   */
  @Override
  public BufferedImage getReconstructedImage(int index, Study study, int min, int max) {
    BufferedImage retVal =
        new BufferedImage(study.getMaxX(), study.getMaxY(), BufferedImage.TYPE_INT_RGB);

    for (int x = 0; x < retVal.getWidth(); x++) {
      for (int y = 0; y < retVal.getHeight(); y++) {
        // Store the current x, y data into the array
        retVal.setRGB(x, y, study.getPixel(x, y, index));
      }
    }

    if (min > 0 || max < 255) {
      return ImageUtil.windowImage(retVal, min, max);
    } else {
      return retVal;
    }
  }
コード例 #6
0
ファイル: LimsDAO.java プロジェクト: adwaitpatil/miso-lims
  @Test
  public void testStudies() {
    try {
      // get row count of experiments in the dataset
      int expected = getDataSet().getTable("Study").getRowCount();

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

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

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

      for (Study d : random(getStudyDAO(), actual, 5)) {
        TestCase.assertNotNull(d);
        TestCase.assertNotNull(d.getId());
      }
    } catch (Exception e) {
      e.printStackTrace();
      TestCase.fail();
    }
  }
コード例 #7
0
ファイル: DeltaIteratorTest.java プロジェクト: NCIP/psc
  public void testRemoveDetachedNodesWhileIterating() {
    Study s = Fixtures.createReleasedTemplate();
    Delta pc = Delta.createDeltaFor(s.getPlannedCalendar());
    Delta epoch2 = Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0));
    StudySegment segment1 = s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(1);
    Delta ss1 = Delta.createDeltaFor(segment1);
    Delta ss2 =
        Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(2));
    List<Delta<?>> deltaList = new ArrayList<Delta<?>>();
    deltaList.add(ss1);
    deltaList.add(epoch2);
    deltaList.add(pc);
    deltaList.add(ss2);

    expect(templateService.findEquivalentChild(s, pc.getNode())).andReturn(pc.getNode());
    expect(templateService.findEquivalentChild(s, epoch2.getNode())).andReturn(epoch2.getNode());
    expect(templateService.findEquivalentChild(s, ss1.getNode())).andReturn(ss1.getNode());
    expect(templateService.findEquivalentChild(s, ss2.getNode())).andReturn(ss2.getNode());

    replayMocks();
    DeltaIterator di = new DeltaIterator(deltaList, s, templateService, false);
    List<Delta> encountered = new LinkedList<Delta>();
    while (di.hasNext()) {
      Delta delta = di.next();
      encountered.add(delta);

      if (delta == epoch2) {
        segment1.setParent(null);
      }
    }

    assertEquals("Wrong number of deltas encountered: " + encountered, 3, encountered.size());
    assertEquals("Wrong delta 0", pc, encountered.get(0));
    assertEquals("Wrong delta 1", epoch2, encountered.get(1));
    assertEquals("Wrong delta 2", ss2, encountered.get(2));
    verifyMocks();
  }
コード例 #8
0
  @Test
  public void testRoundtripVersionInfo() throws MalformedURLException {
    Study study = new Study();
    Assert.assertNull(study.getVersionInfo());
    study.setVersionInfo("1");
    URL resource = StudyClient.upload(study, new URL(TEST_SERVER));

    Study roundtripped = StudyClient.download(resource);
    Assert.assertNotNull(roundtripped.getVersionInfo());
    Assert.assertEquals("1", roundtripped.getVersionInfo());
  }
コード例 #9
0
  @Test
  public void testRoundtripAbstract() throws MalformedURLException {
    Study study = new Study();
    Assert.assertNull(study.getAbstract());
    study.setAbstract("This is an abstract");
    URL resource = StudyClient.upload(study, new URL(TEST_SERVER));

    Study roundtripped = StudyClient.download(resource);
    Assert.assertNotNull(roundtripped.getAbstract());
    Assert.assertEquals(19, roundtripped.getAbstract().length());
  }
コード例 #10
0
  @Test
  public void testRoundtripKeywords() throws MalformedURLException {
    Study study = new Study();
    Assert.assertEquals(0, study.getKeywords().size());
    study.addKeyword("foo");
    URL resource = StudyClient.upload(study, new URL(TEST_SERVER));

    Study roundtripped = StudyClient.download(resource);
    Assert.assertEquals(1, roundtripped.getKeywords().size());
    Assert.assertTrue(roundtripped.getKeywords().contains("foo"));
  }
コード例 #11
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;
  }
コード例 #12
0
ファイル: Meeting.java プロジェクト: seungbeomi/springsprout
 public Meeting(Study study) {
   this();
   this.study = study;
   this.maximum = study.getMaximum();
 }
コード例 #13
0
ファイル: DeltaIteratorTest.java プロジェクト: NCIP/psc
  public void testDetailOrder() {
    Study s = Fixtures.createReleasedTemplate();
    Period period = Fixtures.createPeriod("period1", 1, 10, 2);
    PlannedActivity plannedActivity = Fixtures.createPlannedActivity("activity", 3);
    PlannedActivityLabel plannedActivityLabel = Fixtures.createPlannedActivityLabel("label");
    period.addPlannedActivity(plannedActivity);
    plannedActivity.addPlannedActivityLabel(plannedActivityLabel);
    s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(0).getPeriods().add(period);

    Delta studyDelta = Delta.createDeltaFor(s.getPlannedCalendar().getStudy());
    Delta epochDelta = Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0));
    Delta studySegmentDelta =
        Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(1));
    Delta periodDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .last());
    Delta plannedActivityDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .first()
                .getPlannedActivities()
                .get(0));
    Delta plannedActivityLabelDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .first()
                .getPlannedActivities()
                .get(0)
                .getPlannedActivityLabels()
                .first());

    List<Delta<?>> listOfDeltas = new ArrayList<Delta<?>>();
    listOfDeltas.add(plannedActivityDelta);
    listOfDeltas.add(periodDelta);
    listOfDeltas.add(epochDelta);
    listOfDeltas.add(studyDelta);
    listOfDeltas.add(studySegmentDelta);
    listOfDeltas.add(plannedActivityLabelDelta);

    expect(templateService.findEquivalentChild(s, studyDelta.getNode())).andReturn(s);
    expect(templateService.findEquivalentChild(s, periodDelta.getNode())).andReturn(null);
    expect(templateService.findEquivalentChild(s, epochDelta.getNode()))
        .andReturn(epochDelta.getNode());
    expect(templateService.findEquivalentChild(s, studySegmentDelta.getNode()))
        .andReturn(studySegmentDelta.getNode());
    expect(templateService.findEquivalentChild(s, plannedActivityDelta.getNode())).andReturn(null);
    expect(templateService.findEquivalentChild(s, plannedActivityLabelDelta.getNode()))
        .andReturn(plannedActivityLabelDelta.getNode());
    replayMocks();
    DeltaIterator di = new DeltaIterator(listOfDeltas, s, templateService, false);

    assertSame("studyDelta is not the first element", studyDelta, di.next());
    assertSame("epochDelta is not the second element", epochDelta, di.next());
    assertSame("studySegmentDelta is not the third element", studySegmentDelta, di.next());
    assertSame("periodDelta is not the forth element", plannedActivityLabelDelta, di.next());
    assertFalse("deltaIterator has more elements ", di.hasNext());
    verifyMocks();
  }
コード例 #14
0
  public void resolveNames(Long batchSize) {
    StopWatch watchForEntireRun = new StopWatch();
    watchForEntireRun.start();
    StopWatch watchForBatch = new StopWatch();
    watchForBatch.start();
    Long count = 0L;

    Index<Node> studyIndex = graphService.index().forNodes("studies");
    IndexHits<Node> studies = studyIndex.query("title", "*");
    for (Node studyNode : studies) {
      final Study study1 = new Study(studyNode);
      final Iterable<Relationship> specimens = study1.getSpecimens();
      for (Relationship collected : specimens) {
        Specimen specimen = new Specimen(collected.getEndNode());
        final Relationship classifiedAs =
            specimen
                .getUnderlyingNode()
                .getSingleRelationship(RelTypes.CLASSIFIED_AS, Direction.OUTGOING);
        if (classifiedAs == null) {
          final Relationship describedAs =
              specimen
                  .getUnderlyingNode()
                  .getSingleRelationship(RelTypes.ORIGINALLY_DESCRIBED_AS, Direction.OUTGOING);
          final TaxonNode describedAsTaxon = new TaxonNode(describedAs.getEndNode());
          try {
            if (taxonFilter.shouldInclude(describedAsTaxon)) {
              TaxonNode resolvedTaxon = taxonIndex.getOrCreateTaxon(describedAsTaxon);
              if (resolvedTaxon != null) {
                specimen.classifyAs(resolvedTaxon);
              }
            }
          } catch (NodeFactoryException e) {
            LOG.warn(
                "failed to create taxon with name ["
                    + describedAsTaxon.getName()
                    + "] and id ["
                    + describedAsTaxon.getExternalId()
                    + "]",
                e);
          } finally {
            count++;
            if (count % batchSize == 0) {
              watchForBatch.stop();
              final long duration = watchForBatch.getTime();
              if (duration > 0) {
                LOG.info(
                    "resolved batch of ["
                        + batchSize
                        + "] names in "
                        + getProgressMsg(batchSize, duration));
              }
              watchForBatch.reset();
              watchForBatch.start();
            }
          }
        }
      }
    }
    studies.close();
    watchForEntireRun.stop();
    LOG.info(
        "resolved [" + count + "] names in " + getProgressMsg(count, watchForEntireRun.getTime()));
  }