Search in sources :

Example 1 with ExternalDatabaseStatisticsValueObject

use of ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject in project Gemma by PavlidisLab.

the class PhenotypeAssociationDaoImpl method loadStatisticsOnExternalDatabases.

@Override
public Collection<ExternalDatabaseStatisticsValueObject> loadStatisticsOnExternalDatabases(String downloadPath) {
    HashMap<String, ExternalDatabaseStatisticsValueObject> externalDatabasesStatistics = new HashMap<>();
    // noinspection unchecked
    List<Object[]> numEvidence = this.getHibernateTemplate().find("select p.evidenceSource.externalDatabase, count (*), p.lastUpdated from PhenotypeAssociation " + "as p group by p.evidenceSource.externalDatabase order by p.lastUpdated desc");
    for (Object[] o : numEvidence) {
        ExternalDatabase externalDatabase = (ExternalDatabase) o[0];
        Long count = (Long) o[1];
        ExternalDatabaseStatisticsValueObject externalDatabaseStatistics = new ExternalDatabaseStatisticsValueObject();
        externalDatabaseStatistics.setDescription(externalDatabase.getDescription());
        externalDatabaseStatistics.setName(externalDatabase.getName());
        externalDatabaseStatistics.setPathToDownloadFile(downloadPath + externalDatabase.getName().replaceAll(" ", "") + ".tsv");
        externalDatabaseStatistics.setLastUpdateDate((Date) o[2]);
        externalDatabaseStatistics.setWebUri(externalDatabase.getWebUri());
        externalDatabaseStatistics.setNumEvidence(count);
        externalDatabasesStatistics.put(externalDatabase.getName(), externalDatabaseStatistics);
    }
    // noinspection unchecked
    List<Object[]> numGenes = this.getHibernateTemplate().find("select p.evidenceSource.externalDatabase.name, count (distinct g) from Gene as g join g.phenotypeAssociations " + "as p group by p.evidenceSource.externalDatabase");
    for (Object[] o : numGenes) {
        String externalDatabaseName = (String) o[0];
        externalDatabasesStatistics.get(externalDatabaseName).setNumGenes((Long) o[1]);
    }
    // noinspection unchecked
    List<Object[]> numPhenotypes = this.getHibernateTemplate().find("select p.evidenceSource.externalDatabase.name, count (distinct c.valueUri) " + "from PhenotypeAssociation as p join p.phenotypes as c " + "group by p.evidenceSource.externalDatabase");
    for (Object[] o : numPhenotypes) {
        String externalDatabaseName = (String) o[0];
        externalDatabasesStatistics.get(externalDatabaseName).setNumPhenotypes((Long) o[1]);
    }
    // noinspection unchecked
    List<Object[]> numPublications = this.getHibernateTemplate().find("select p.evidenceSource.externalDatabase.name, count (distinct pub.citation.pubAccession.accession) " + "from PhenotypeAssociation as p join p.phenotypeAssociationPublications as pub" + " group by p.evidenceSource.externalDatabase");
    for (Object[] o : numPublications) {
        String externalDatabaseName = (String) o[0];
        externalDatabasesStatistics.get(externalDatabaseName).addNumPublications((Long) o[1]);
    }
    return externalDatabasesStatistics.values();
}
Also used : ExternalDatabaseStatisticsValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject) ExternalDatabase(ubic.gemma.model.common.description.ExternalDatabase) ExternalDatabaseStatisticsValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) PhenotypeValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.PhenotypeValueObject) GeneEvidenceValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)

Example 2 with ExternalDatabaseStatisticsValueObject

use of ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject in project Gemma by PavlidisLab.

the class PhenotypeAssociationDaoImpl method loadStatisticsOnManualCuration.

/**
 * @param downloadFile file
 * @return find statistics for manual curation (numGene, numPhenotypes, etc.)
 */
@Override
public ExternalDatabaseStatisticsValueObject loadStatisticsOnManualCuration(String downloadFile) {
    Long numEvidence = (Long) this.getHibernateTemplate().find("select count (p) from PhenotypeAssociation as p where p.evidenceSource is null").iterator().next();
    Long numGenes = (Long) this.getHibernateTemplate().find("select count (distinct g) from Gene as g inner join g.phenotypeAssociations as p where p.evidenceSource is null").iterator().next();
    Long numPhenotypes = (Long) this.getHibernateTemplate().find("select count (distinct c.valueUri) from PhenotypeAssociation as p inner join p.phenotypes as c where p.evidenceSource is null").iterator().next();
    HibernateTemplate tpl = new HibernateTemplate(this.getSessionFactory());
    tpl.setMaxResults(1);
    List<?> result = tpl.find("select p.lastUpdated from PhenotypeAssociation as p " + "where p.evidenceSource is null order by p.lastUpdated desc");
    Date lastUpdatedDate = null;
    if (!result.isEmpty()) {
        lastUpdatedDate = (Timestamp) result.get(0);
    }
    // find all secondary pubmed for ExperimentalEvidence
    // noinspection unchecked
    Collection<String> publications = this.getHibernateTemplate().find("select distinct pub.citation.pubAccession.accession from PhenotypeAssociation as p " + "join p.phenotypeAssociationPublications as pub where p.evidenceSource is null");
    Long numPublications = (long) publications.size();
    return new ExternalDatabaseStatisticsValueObject("Manual curation", "Evidence curated manually through literature review", "", numEvidence, numGenes, numPhenotypes, numPublications, lastUpdatedDate, downloadFile);
}
Also used : ExternalDatabaseStatisticsValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate)

Aggregations

ExternalDatabaseStatisticsValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject)2 HibernateTemplate (org.springframework.orm.hibernate3.HibernateTemplate)1 ExternalDatabase (ubic.gemma.model.common.description.ExternalDatabase)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)1 GeneEvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject)1 PhenotypeValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.PhenotypeValueObject)1