Search in sources :

Example 1 with GOEvidenceCode

use of ubic.gemma.model.association.GOEvidenceCode in project Gemma by PavlidisLab.

the class NCBIGene2GOAssociationParser method mapFromGene2GO.

/**
 * Note that "-" means a missing value, which in practice only occurs in the "qualifier" and "pubmed" columns.
 *
 * @param line line
 * @return Object
 */
// Possible external use
@SuppressWarnings({ "unused", "WeakerAccess" })
public Gene2GOAssociation mapFromGene2GO(String line) {
    String[] values = StringUtils.splitPreserveAllTokens(line, "\t");
    if (line.startsWith(NCBIGene2GOAssociationParser.COMMENT_INDICATOR))
        return null;
    if (values.length < 8)
        return null;
    Integer taxonId;
    try {
        taxonId = Integer.parseInt(values[TAX_ID]);
    } catch (NumberFormatException e) {
        throw new RuntimeException(e);
    }
    if (!taxaNcbiIds.containsKey(taxonId)) {
        return null;
    }
    Gene gene = Gene.Factory.newInstance();
    gene.setNcbiGeneId(Integer.parseInt(values[GENE_ID]));
    gene.setTaxon(taxaNcbiIds.get(taxonId));
    VocabCharacteristic oe = VocabCharacteristic.Factory.newInstance();
    String value = values[GO_ID].replace(":", "_");
    oe.setValueUri(GeneOntologyService.BASE_GO_URI + value);
    oe.setValue(value);
    // g2GOAss.setSource( ncbiGeneDb );
    GOEvidenceCode evcode = null;
    String evidenceCode = values[EVIDENCE_CODE];
    if (!(StringUtils.isBlank(evidenceCode) || evidenceCode.equals("-"))) {
        if (NCBIGene2GOAssociationParser.ignoredEvidenceCodes.contains(evidenceCode)) {
            return null;
        }
        evcode = GOEvidenceCode.fromString(evidenceCode);
    }
    Gene2GOAssociation g2GOAss = Gene2GOAssociation.Factory.newInstance(gene, oe, evcode);
    try {
        queue.put(g2GOAss);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    return g2GOAss;
}
Also used : Gene(ubic.gemma.model.genome.Gene) GOEvidenceCode(ubic.gemma.model.association.GOEvidenceCode) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) Gene2GOAssociation(ubic.gemma.model.association.Gene2GOAssociation)

Example 2 with GOEvidenceCode

use of ubic.gemma.model.association.GOEvidenceCode in project Gemma by PavlidisLab.

the class PhenotypeAssociationDaoImpl method findGenesForPhenotype.

@Override
public Map<GeneValueObject, OntologyTerm> findGenesForPhenotype(OntologyTerm term, Long taxon, boolean includeIEA) {
    Collection<OntologyTerm> children = term.getChildren(false);
    Map<String, OntologyTerm> uris = new HashMap<>();
    uris.put(term.getUri(), term);
    for (OntologyTerm c : children) {
        uris.put(c.getUri(), c);
    }
    assert !uris.isEmpty();
    Session sess = this.getSessionFactory().getCurrentSession();
    String q = "select distinct ph.gene, p.valueUri, p.evidenceCode " + " from PhenotypeAssociation ph join ph.phenotypes p where p.valueUri in (:t)";
    Query query = sess.createQuery(q);
    Map<GeneValueObject, OntologyTerm> result = new HashMap<>();
    query.setParameterList("t", uris.keySet());
    List<?> list = query.list();
    for (Object o : list) {
        Object[] oa = (Object[]) o;
        Gene g = (Gene) oa[0];
        if (!taxon.equals(g.getTaxon().getId()))
            continue;
        String uri = (String) oa[1];
        GOEvidenceCode ev = (GOEvidenceCode) oa[2];
        if (!includeIEA && ev != null && ev.equals(GOEvidenceCode.IEA)) {
            continue;
        }
        GeneValueObject gvo = new GeneValueObject(g);
        OntologyTerm otForUri = uris.get(uri);
        assert otForUri != null;
        /*
             * only clobber if this term is more specific
             */
        if (result.containsKey(gvo) && otForUri.getParents(false).contains(otForUri)) {
            continue;
        }
        result.put(gvo, otForUri);
    }
    return result;
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Gene(ubic.gemma.model.genome.Gene) GOEvidenceCode(ubic.gemma.model.association.GOEvidenceCode) 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)

Aggregations

GOEvidenceCode (ubic.gemma.model.association.GOEvidenceCode)2 Gene (ubic.gemma.model.genome.Gene)2 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)1 Gene2GOAssociation (ubic.gemma.model.association.Gene2GOAssociation)1 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)1 ExternalDatabaseStatisticsValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.ExternalDatabaseStatisticsValueObject)1 GeneEvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject)1 PhenotypeValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.PhenotypeValueObject)1