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;
}
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;
}
Aggregations