use of gov.nih.nci.ctd2.dashboard.model.Annotation in project nci-ctd2-dashboard by CBIIT.
the class DashboardDaoImpl method findCellSampleByAnnotationField.
private List<CellSample> findCellSampleByAnnotationField(String field, String value) {
List<CellSample> cellSamples = new ArrayList<CellSample>();
List<Annotation> annoList = queryWithClass("from AnnotationImpl where " + field + " = :value", "value", value);
for (Annotation anno : annoList) {
List<CellSample> list = queryWithClass("from CellSampleImpl as cs where :anno member of cs.annotations", "anno", anno);
for (CellSample cellSample : list) {
if (!cellSamples.contains(cellSample)) {
cellSamples.add(cellSample);
}
}
}
return cellSamples;
}
use of gov.nih.nci.ctd2.dashboard.model.Annotation in project nci-ctd2-dashboard by CBIIT.
the class CellLineSampleFieldSetMapper method mapFieldSet.
public CellSample mapFieldSet(FieldSet fieldSet) throws BindException {
String cellSampleId = fieldSet.readString(CELL_SAMPLE_ID);
String taxonomyId = fieldSet.readString(TAXONOMY_ID);
String gender = fieldSet.readString(GENDER);
CellSample cellSample = dashboardFactory.create(CellSample.class);
// display name will be set in next step
Organism organism = getOrganism(taxonomyId);
if (organism != null)
cellSample.setOrganism(organism);
if (gender != null && gender.length() > 0)
cellSample.setGender(gender);
if (cellLineAnnotationSampleMap.containsKey(cellSampleId)) {
cellSample.setAnnotations(cellLineAnnotationSampleMap.get(cellSampleId));
} else {
cellSample.setAnnotations(new HashSet<Annotation>());
}
// optimization - avoid persisting CellSamples
// - place in map and pass to cellLineNameStep
cellSampleMap.put(cellSampleId, cellSample);
return cellSample;
}
use of gov.nih.nci.ctd2.dashboard.model.Annotation in project nci-ctd2-dashboard by CBIIT.
the class DashboardDaoImpl method summarizePerSubject.
private Summary summarizePerSubject(Class<? extends Subject> subjectClass, String label) {
String tableName = "";
Class<?> implClass = subjectClass.isInterface() ? dashboardFactory.getImplClass(subjectClass) : subjectClass;
java.lang.annotation.Annotation[] annotation = implClass.getAnnotationsByType(javax.persistence.Table.class);
if (annotation.length == 1) {
javax.persistence.Table table = (javax.persistence.Table) annotation[0];
tableName = table.name();
} else {
return new Summary("exception", 0, 0, 0, 0);
}
Session session = getSession();
@SuppressWarnings("unchecked") org.hibernate.query.Query<BigInteger> query = session.createNativeQuery("SELECT count(DISTINCT submission_id) FROM " + tableName + " JOIN observed_subject ON observed_subject.subject_id=" + tableName + ".id" + " JOIN observation ON observation.id=observed_subject.observation_id");
BigInteger submissions = query.getSingleResult();
String tierQuery = "SELECT tier, COUNT(DISTINCT observation_id) FROM " + tableName + " JOIN observed_subject ON observed_subject.subject_id=" + tableName + ".id" + " JOIN observation ON observation.id=observed_subject.observation_id" + " JOIN submission ON submission.id=observation.submission_id" + " JOIN observation_template ON observation_template.id=submission.observationTemplate_id" + " GROUP BY tier";
@SuppressWarnings("unchecked") org.hibernate.query.Query<Object[]> query2 = session.createNativeQuery(tierQuery);
int[] tierCount = new int[3];
List<Object[]> result = query2.list();
for (Object[] obj : result) {
Integer tier = (Integer) obj[0];
BigInteger count = (BigInteger) obj[1];
tierCount[tier - 1] = count.intValue();
}
session.close();
return new Summary(label, submissions.intValue(), tierCount[0], tierCount[1], tierCount[2]);
}
use of gov.nih.nci.ctd2.dashboard.model.Annotation 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());
}
use of gov.nih.nci.ctd2.dashboard.model.Annotation in project nci-ctd2-dashboard by CBIIT.
the class CellLineAnnotationSampleFieldSetMapper method mapFieldSet.
public Annotation mapFieldSet(FieldSet fieldSet) throws BindException {
String cellSampleId = fieldSet.readString(CELL_SAMPLE_ID);
if (!cellLineAnnotationSampleMap.containsKey(cellSampleId)) {
cellLineAnnotationSampleMap.put(cellSampleId, new HashSet<Annotation>());
}
Annotation annotation = dashboardFactory.create(Annotation.class);
if (cellLineAnnotationNameMap.containsKey(fieldSet.readString(CELL_ANNO_NAME_ID))) {
annotation.setDisplayName(cellLineAnnotationNameMap.get(fieldSet.readString(CELL_ANNO_NAME_ID)));
}
if (cellLineAnnotationTypeMap.containsKey(fieldSet.readString(CELL_ANNO_TYPE_ID))) {
annotation.setType(cellLineAnnotationTypeMap.get(fieldSet.readString(CELL_ANNO_TYPE_ID)));
}
if (cellLineAnnotationSourceMap.containsKey(fieldSet.readString(CELL_ANNO_SOURCE_ID))) {
annotation.setSource(cellLineAnnotationSourceMap.get(fieldSet.readString(CELL_ANNO_SOURCE_ID)));
}
cellLineAnnotationSampleMap.get(cellSampleId).add(annotation);
// if we don't return something, spring batch will think EOF has been reached
return annotation;
}
Aggregations