Search in sources :

Example 1 with ObservedEvidenceRole

use of gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole in project nci-ctd2-dashboard by CBIIT.

the class ControlledVocabularyPerColumnFieldSetMapper method mapFieldSet.

public ControlledVocabulary mapFieldSet(FieldSet fieldSet) throws BindException {
    String templateName = fieldSet.readString(TEMPLATE_NAME);
    ObservationTemplate observationTemplate = observationTemplateNameMap.get(templateName);
    if (observationTemplate == null)
        return new ControlledVocabulary(null, null, null);
    if (subjectRoleCache == null)
        subjectRoleCache = new HashMap<String, SubjectRole>();
    if (evidenceRoleCache == null)
        evidenceRoleCache = new HashMap<String, EvidenceRole>();
    String subject = fieldSet.readString(SUBJECT);
    String evidence = fieldSet.readString(EVIDENCE);
    if (subject.length() > 0) {
        String subjectRoleStr = fieldSet.readString(ROLE);
        SubjectRole subjectRole = subjectRoleCache.get(subjectRoleStr);
        if (subjectRole == null) {
            subjectRole = dashboardFactory.create(SubjectRole.class);
            subjectRole.setDisplayName(subjectRoleStr);
            subjectRoleCache.put(subjectRoleStr, subjectRole);
        }
        ObservedSubjectRole observedSubjectRole = dashboardFactory.create(ObservedSubjectRole.class);
        observedSubjectRole.setSubjectRole(subjectRole);
        observedSubjectRole.setColumnName(fieldSet.readString(COLUMN_NAME));
        observedSubjectRole.setDisplayText(fieldSet.readString(DISPLAY_TEXT));
        observedSubjectRole.setObservationTemplate(observationTemplate);
        return new ControlledVocabulary(observationTemplate, subjectRole, observedSubjectRole);
    } else if (evidence.length() > 0) {
        String evidenceRoleStr = fieldSet.readString(ROLE);
        EvidenceRole evidenceRole = evidenceRoleCache.get(evidenceRoleStr);
        if (evidenceRole == null) {
            evidenceRole = dashboardFactory.create(EvidenceRole.class);
            evidenceRole.setDisplayName(evidenceRoleStr);
            evidenceRoleCache.put(evidenceRoleStr, evidenceRole);
        }
        ObservedEvidenceRole observedEvidenceRole = dashboardFactory.create(ObservedEvidenceRole.class);
        observedEvidenceRole.setEvidenceRole(evidenceRole);
        observedEvidenceRole.setColumnName(fieldSet.readString(COLUMN_NAME));
        observedEvidenceRole.setDisplayText(fieldSet.readString(DISPLAY_TEXT));
        observedEvidenceRole.setObservationTemplate(observationTemplate);
        observedEvidenceRole.setAttribute(getObservedEvidenceRoleAttribute(fieldSet.readString(MIME_TYPE), fieldSet.readString(NUMERIC_UNITS)));
        return new ControlledVocabulary(observationTemplate, evidenceRole, observedEvidenceRole);
    }
    return new ControlledVocabulary(null, null, null);
}
Also used : HashMap(java.util.HashMap) ObservedSubjectRole(gov.nih.nci.ctd2.dashboard.model.ObservedSubjectRole) SubjectRole(gov.nih.nci.ctd2.dashboard.model.SubjectRole) ObservationTemplate(gov.nih.nci.ctd2.dashboard.model.ObservationTemplate) ObservedSubjectRole(gov.nih.nci.ctd2.dashboard.model.ObservedSubjectRole) ObservedEvidenceRole(gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole) ObservedEvidenceRole(gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole) EvidenceRole(gov.nih.nci.ctd2.dashboard.model.EvidenceRole)

Example 2 with ObservedEvidenceRole

use of gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole in project nci-ctd2-dashboard by CBIIT.

the class DashboardDaoImpl method findObservedEvidenceRole.

@Override
public ObservedEvidenceRole findObservedEvidenceRole(String templateName, String columnName) {
    List<ObservedEvidenceRole> list = new ArrayList<ObservedEvidenceRole>();
    // first grab observation template name
    List<ObservationTemplate> otList = queryWithClass("from ObservationTemplateImpl where displayName = :templateName", "templateName", templateName);
    for (ObservationTemplate ot : otList) {
        List<ObservedEvidenceRole> oerList = query2ParamsWithClass("from ObservedEvidenceRoleImpl as oer where columnName = :columnName and " + "oer.observationTemplate = :ot", "columnName", columnName, "ot", ot);
        for (ObservedEvidenceRole o : oerList) {
            list.add(o);
        }
    }
    assert list.size() <= 1;
    return (list.size() == 1) ? list.iterator().next() : null;
}
Also used : ArrayList(java.util.ArrayList) ObservationTemplate(gov.nih.nci.ctd2.dashboard.model.ObservationTemplate) ObservedEvidenceRole(gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole)

Example 3 with ObservedEvidenceRole

use of gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole in project nci-ctd2-dashboard by CBIIT.

the class AdminTest method importerTest.

@Test
public void importerTest() throws Exception {
    // import taxonomy data
    jobExecution = executeJob("taxonomyDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("Organism count", 2, dashboardDao.countEntities(Organism.class).intValue());
    List<Organism> organisms = dashboardDao.findOrganismByTaxonomyId("9606");
    assertEquals(1, organisms.size());
    assertEquals("Homo sapiens", organisms.iterator().next().getDisplayName());
    // animal model
    jobExecution = executeJob("animalModelImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("AnimalModel count", 1, dashboardDao.countEntities(AnimalModel.class).intValue());
    List<AnimalModel> models = dashboardDao.findAnimalModelByName("[FVB/N x SPRET/Ei] x FVB/N");
    assertEquals("AnimalModel found by name", 1, models.size());
    assertEquals("10090", models.iterator().next().getOrganism().getTaxonomyId());
    // import some cell line data
    jobExecution = executeJob("cellLineDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("CellSample count", 3, dashboardDao.countEntities(CellSample.class).intValue());
    List<CellSample> cellSamples = dashboardDao.findCellSampleByAnnoSource("COSMIC (Sanger)");
    assertEquals("CellSample found by source", 3, cellSamples.size());
    cellSamples = dashboardDao.findCellSampleByAnnoType("primary_site");
    assertEquals(3, cellSamples.size());
    cellSamples = dashboardDao.findCellSampleByAnnoName("acute_lymphoblastic_B_cell_leukaemia");
    assertEquals("CellSample size", 1, cellSamples.size());
    CellSample cellSample = (CellSample) cellSamples.iterator().next();
    assertEquals(8, cellSample.getAnnotations().size());
    assertEquals("CellSamples synonyms size", 2, cellSample.getSynonyms().size());
    Annotation annotation = cellSample.getAnnotations().iterator().next();
    cellSamples = dashboardDao.findCellSampleByAnnotation(annotation);
    assertEquals(1, cellSamples.size());
    assertEquals(cellSample, cellSamples.iterator().next());
    List<Subject> cellSampleSubjects = dashboardDao.findSubjectsBySynonym("5637", true);
    assertEquals(1, cellSampleSubjects.size());
    cellSample = (CellSample) cellSampleSubjects.iterator().next();
    assertEquals("M", cellSample.getGender());
    // import some compound data
    jobExecution = executeJob("compoundDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("Compound count", 10, dashboardDao.countEntities(Compound.class).intValue());
    List<Subject> compoundSubjects = dashboardDao.findSubjectsByXref(CompoundsFieldSetMapper.BROAD_COMPOUND_DATABASE, "411739");
    assertEquals(1, compoundSubjects.size());
    List<Compound> compounds = dashboardDao.findCompoundsBySmilesNotation("CCCCCCCCC1OC(=O)C(=C)C1C(O)=O");
    assertEquals(1, compounds.size());
    assertEquals(3, compounds.iterator().next().getSynonyms().size());
    List<Subject> compoundSubjectsWithImage = dashboardDao.findSubjectsByXref(CompoundsFieldSetMapper.COMPOUND_IMAGE_DATABASE, "BRD-A01145011.png");
    assertEquals(1, compoundSubjectsWithImage.size());
    assertEquals("zebularine", compoundSubjectsWithImage.iterator().next().getDisplayName());
    // import some gene data
    jobExecution = executeJob("geneDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("Gene count", 19, dashboardDao.countEntities(Gene.class).intValue());
    List<Gene> genes = dashboardDao.findGenesByEntrezId("7529");
    assertEquals(1, genes.size());
    assertEquals("synonym number for 7529", 12, genes.iterator().next().getSynonyms().size());
    List<Subject> geneSubjects = dashboardDao.findSubjectsBySynonym("RB1", true);
    assertEquals(1, geneSubjects.size());
    // import some protein data
    jobExecution = executeJob("proteinDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("Protein count", 15, dashboardDao.countEntities(Protein.class).intValue());
    List<Protein> proteins = dashboardDao.findProteinsByUniprotId("P31946");
    assertEquals(1, proteins.size());
    // some transcripts get created along with proteins
    assertEquals(35, dashboardDao.countEntities(Transcript.class).intValue());
    List<Transcript> transcripts = dashboardDao.findTranscriptsByRefseqId("NM_003404");
    assertEquals(1, transcripts.size());
    // import some shrna
    jobExecution = executeJob("TRCshRNADataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("ShRna count", 1, dashboardDao.countEntities(ShRna.class).intValue());
    List<Subject> shRNASubjects = dashboardDao.findSubjectsByXref("BROAD_SHRNA", "TRCN0000000001");
    assertEquals(1, shRNASubjects.size());
    ShRna shRNA = (ShRna) shRNASubjects.get(0);
    assertEquals("CCCTGCCAAACAAGCTAATAT", shRNA.getDisplayName());
    assertEquals("CCCTGCCAAACAAGCTAATAT", shRNA.getTargetSequence());
    // import some tissue sample data
    jobExecution = executeJob("tissueSampleDataImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    assertEquals("TissueSample count", 2, dashboardDao.countEntities(TissueSample.class).intValue());
    List<TissueSample> tissueSamples = dashboardDao.findTissueSampleByName("neoplasm by morphology");
    assertEquals(1, tissueSamples.size());
    TissueSample tissueSample = tissueSamples.get(0);
    assertEquals(1, tissueSample.getSynonyms().size());
    assertEquals("Xrefs size", 2, tissueSample.getXrefs().size());
    // check tissue xref import
    tissueSamples = dashboardDao.findTissueSampleByName("neoplasm");
    assertEquals(1, tissueSamples.size());
    String doid = "not found";
    for (Xref xref : tissueSamples.get(0).getXrefs()) {
        if ("DISEASE ONTOLOGY".equals(xref.getDatabaseName())) {
            doid = xref.getDatabaseId();
        }
    }
    assertEquals("DOID:14566", doid);
    tissueSamples = dashboardDao.findTissueSampleByName("neoplasm by morphology");
    assertEquals(1, tissueSamples.size());
    doid = "not found";
    for (Xref xref : tissueSamples.get(0).getXrefs()) {
        if ("DISEASE ONTOLOGY".equals(xref.getDatabaseName())) {
            doid = xref.getDatabaseId();
        }
    }
    assertEquals("not found", doid);
    // import controlled vocabulary
    jobExecution = executeJob("controlledVocabularyImporterJob");
    assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
    // we get some subject/observed subject roles
    assertEquals("SubjectRole count", 18, dashboardDao.countEntities(SubjectRole.class).intValue());
    assertEquals("ObservedSubjectRole count", 75, dashboardDao.countEntities(ObservedSubjectRole.class).intValue());
    assertTrue("findObservedSubjectRole", dashboardDao.findObservedSubjectRole("broad_cpd_sens_lineage_enrich", "compound_name") != null);
    // we get some evidence/observed evidence roles
    assertEquals("countEntities EvidenceRole", 9, dashboardDao.countEntities(EvidenceRole.class).intValue());
    assertEquals("countEntities ObservedEvidenceRole", 186, dashboardDao.countEntities(ObservedEvidenceRole.class).intValue());
    assertTrue(dashboardDao.findObservedEvidenceRole("broad_cpd_sens_lineage_enrich", "cell_line_subset") != null);
    // we get observation template data
    assertEquals("countEntities ObservationTemplate", 25, dashboardDao.countEntities(ObservationTemplate.class).intValue());
    ObservationTemplate observationTemplate = dashboardDao.findObservationTemplateByName("broad_cpd_sens_lineage_enrich");
    assertNotNull(observationTemplate);
    assertFalse(observationTemplate.getIsSubmissionStory());
    assertEquals(0, observationTemplate.getSubmissionStoryRank().intValue());
    observationTemplate = dashboardDao.findObservationTemplateByName("broad_beta-catenin_navitoclax");
    assertNotNull(observationTemplate);
    assertFalse(observationTemplate.getIsSubmissionStory());
    assertEquals(0, observationTemplate.getSubmissionStoryRank().intValue());
    // check compound xref import
    compounds = dashboardDao.findCompoundsByName("navitoclax");
    assertEquals(1, compounds.size());
    String drugBankId = "not found";
    for (Xref xref : compounds.get(0).getXrefs()) {
        if ("DRUG BANK".equals(xref.getDatabaseName())) {
            drugBankId = xref.getDatabaseId();
        }
    }
    assertEquals("DB12340", drugBankId);
    compoundSubjects = dashboardDao.findSubjectsByXref("DRUG BANK", "DB12025");
    assertEquals(1, compoundSubjects.size());
}
Also used : Transcript(gov.nih.nci.ctd2.dashboard.model.Transcript) Organism(gov.nih.nci.ctd2.dashboard.model.Organism) AnimalModel(gov.nih.nci.ctd2.dashboard.model.AnimalModel) CellSample(gov.nih.nci.ctd2.dashboard.model.CellSample) Compound(gov.nih.nci.ctd2.dashboard.model.Compound) Annotation(gov.nih.nci.ctd2.dashboard.model.Annotation) Subject(gov.nih.nci.ctd2.dashboard.model.Subject) Protein(gov.nih.nci.ctd2.dashboard.model.Protein) TissueSample(gov.nih.nci.ctd2.dashboard.model.TissueSample) ShRna(gov.nih.nci.ctd2.dashboard.model.ShRna) Xref(gov.nih.nci.ctd2.dashboard.model.Xref) Gene(gov.nih.nci.ctd2.dashboard.model.Gene) ObservationTemplate(gov.nih.nci.ctd2.dashboard.model.ObservationTemplate) Test(org.junit.Test)

Example 4 with ObservedEvidenceRole

use of gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole in project nci-ctd2-dashboard by CBIIT.

the class ControlledVocabularyPerColumnWriter method write.

public void write(List<? extends ControlledVocabulary> items) throws Exception {
    if (entityCache == null)
        entityCache = new HashSet<DashboardEntity>();
    if (entities == null)
        entities = new ArrayList<DashboardEntity>();
    for (ControlledVocabulary controlledVocabulary : items) {
        String observedRoleName = "";
        if (controlledVocabulary.observedRole instanceof ObservedSubjectRole) {
            observedRoleName = ((ObservedSubjectRole) controlledVocabulary.observedRole).getColumnName();
        } else if (controlledVocabulary.observedRole instanceof ObservedEvidenceRole) {
            observedRoleName = ((ObservedEvidenceRole) controlledVocabulary.observedRole).getColumnName();
        }
        log.info("Storing Observed Role: " + observedRoleName);
        if (!entityCache.contains(controlledVocabulary.role)) {
            entityCache.add(controlledVocabulary.role);
            entities.add(controlledVocabulary.role);
        }
        ObservationTemplate ot = (ObservationTemplate) controlledVocabulary.observationTemplate;
        if (!entityCache.contains(ot.getSubmissionCenter())) {
            SubmissionCenter submissionCenter = dashboardDao.findSubmissionCenterByName(ot.getSubmissionCenter().getDisplayName());
            if (submissionCenter == null) {
                entities.add(ot.getSubmissionCenter());
            }
            entityCache.add(ot.getSubmissionCenter());
        }
        if (!entityCache.contains(controlledVocabulary.observationTemplate)) {
            entityCache.add(controlledVocabulary.observationTemplate);
            entities.add(controlledVocabulary.observationTemplate);
        }
        if (!entityCache.contains(controlledVocabulary.observedRole)) {
            entityCache.add(controlledVocabulary.observedRole);
            entities.add(controlledVocabulary.observedRole);
        }
    }
    dashboardDao.batchSave(entities, batchSize);
}
Also used : SubmissionCenter(gov.nih.nci.ctd2.dashboard.model.SubmissionCenter) ArrayList(java.util.ArrayList) ObservedSubjectRole(gov.nih.nci.ctd2.dashboard.model.ObservedSubjectRole) ObservationTemplate(gov.nih.nci.ctd2.dashboard.model.ObservationTemplate) ObservedEvidenceRole(gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole) HashSet(java.util.HashSet)

Example 5 with ObservedEvidenceRole

use of gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole in project nci-ctd2-dashboard by CBIIT.

the class ObservationDataFactoryImpl method createObservedFileEvidence.

@Override
public ObservedEvidence createObservedFileEvidence(String evidenceValue, String columnName, String templateName, Observation observation) {
    ObservedEvidence observedEvidence = dashboardFactory.create(ObservedEvidence.class);
    observedEvidence.setDisplayName(evidenceValue);
    observedEvidence.setObservation(observation);
    ObservedEvidenceRole observedEvidenceRole = getObservedEvidenceRole(templateName, columnName);
    if (observedEvidenceRole != null)
        observedEvidence.setObservedEvidenceRole(observedEvidenceRole);
    Evidence evidence = dashboardFactory.create(FileEvidence.class);
    evidence.setDisplayName(String.valueOf(evidenceValue));
    File file = new File(evidenceValue);
    ((FileEvidence) evidence).setFileName(file.getName());
    ((FileEvidence) evidence).setFilePath(file.getPath());
    /* This may result in unintended behavior on Windows platform.
			The string filePath is meant to be part of a remote URL instead of a local path. */
    if (observedEvidenceRole != null && observedEvidenceRole.getAttribute().length() > 0) {
        ((FileEvidence) evidence).setMimeType(observedEvidenceRole.getAttribute());
    }
    observedEvidence.setEvidence(evidence);
    if (file.getName().endsWith(".mra")) {
        String stableURL = new StableURL().createURLWithPrefix("mra", file.getName());
        observedEvidence.setStableURL(stableURL);
    }
    return observedEvidence;
}
Also used : StableURL(gov.nih.nci.ctd2.dashboard.util.StableURL) File(java.io.File)

Aggregations

ObservationTemplate (gov.nih.nci.ctd2.dashboard.model.ObservationTemplate)4 ObservedEvidenceRole (gov.nih.nci.ctd2.dashboard.model.ObservedEvidenceRole)3 ObservedSubjectRole (gov.nih.nci.ctd2.dashboard.model.ObservedSubjectRole)2 ArrayList (java.util.ArrayList)2 AnimalModel (gov.nih.nci.ctd2.dashboard.model.AnimalModel)1 Annotation (gov.nih.nci.ctd2.dashboard.model.Annotation)1 CellSample (gov.nih.nci.ctd2.dashboard.model.CellSample)1 Compound (gov.nih.nci.ctd2.dashboard.model.Compound)1 EvidenceRole (gov.nih.nci.ctd2.dashboard.model.EvidenceRole)1 Gene (gov.nih.nci.ctd2.dashboard.model.Gene)1 Organism (gov.nih.nci.ctd2.dashboard.model.Organism)1 Protein (gov.nih.nci.ctd2.dashboard.model.Protein)1 ShRna (gov.nih.nci.ctd2.dashboard.model.ShRna)1 Subject (gov.nih.nci.ctd2.dashboard.model.Subject)1 SubjectRole (gov.nih.nci.ctd2.dashboard.model.SubjectRole)1 SubmissionCenter (gov.nih.nci.ctd2.dashboard.model.SubmissionCenter)1 TissueSample (gov.nih.nci.ctd2.dashboard.model.TissueSample)1 Transcript (gov.nih.nci.ctd2.dashboard.model.Transcript)1 Xref (gov.nih.nci.ctd2.dashboard.model.Xref)1 StableURL (gov.nih.nci.ctd2.dashboard.util.StableURL)1