/** * Resolve Gene primaryId from a symbol. * * @param primaryId the fly gene primaryId * @param symbol the fly gene symbol * @return gene primaryId * @throws ObjectStoreException */ private String createGene(String primaryId, String symbol) throws ObjectStoreException { if (primaryId == null) { // for miRNA case if ("mlc-c_in1".endsWith(symbol)) { symbol = "Mlc-c"; } if ("mir-iab-4as".endsWith(symbol)) { symbol = "mir-iab-8"; } IdResolver resolver = resolverFactory.getIdResolver(); int resCount = resolver.countResolutions(FLY_TAXON_ID, symbol); if (resCount != 1) { LOG.info( "RESOLVER: failed to resolve gene to one identifier, ignoring gene: " + symbol + " count: " + resCount + " FBgn: " + resolver.resolveId(FLY_TAXON_ID, symbol)); } primaryId = resolver.resolveId(FLY_TAXON_ID, symbol).iterator().next(); } if (!geneItems.containsKey(primaryId)) { createBioEntity("Gene", primaryId, symbol); } return primaryId; }
private String getGene(String identifierType, String id, String taxonId) throws ObjectStoreException { String identifier = id; if (rslv != null && rslv.hasTaxon(taxonId)) { identifier = resolveGene(identifier, taxonId); if (identifier == null) { return null; } } String refId = identifiersToGenes.get(identifier); if (refId == null) { Item gene = createItem("Gene"); refId = gene.getIdentifier(); gene.setAttribute(identifierType, identifier); gene.setReference("organism", getOrganism(taxonId)); identifiersToGenes.put(identifier, refId); try { store(gene); } catch (ObjectStoreException e) { throw new ObjectStoreException(e); } } return refId; }
private String resolveGene(String originalId, String taxonId) { String primaryIdentifier = null; int resCount = rslv.countResolutions(taxonId, originalId); if (resCount != 1) { LOG.info( "RESOLVER: failed to resolve gene to one identifier, ignoring " + "gene: " + originalId + " for organism " + taxonId + " count: " + resCount + " found ids: " + rslv.resolveId(taxonId, originalId) + "."); } else { primaryIdentifier = rslv.resolveId(taxonId, originalId).iterator().next(); LOG.info("RESOLVER found gene " + primaryIdentifier + " for original id: " + originalId); } return primaryIdentifier; }
private String resolveTerm(String identifier) { String goId = identifier; IdResolver resolver = ontologyResolverFactory.getIdResolver(false); if (resolver != null) { int resCount = resolver.countResolutions("0", identifier); if (resCount > 1) { LOG.info( "RESOLVER: failed to resolve ontology term to one identifier, " + "ignoring term: " + identifier + " count: " + resCount + " : " + resolver.resolveId("0", identifier)); return null; } if (resCount == 1) { goId = resolver.resolveId("0", identifier).iterator().next(); } } return goId; }
private String newProduct( String identifier, String type, Item organism, String dataSourceCode, boolean createOrganism, String field) throws ObjectStoreException { String idField = field; String accession = identifier; String clsName = null; // find gene attribute first to see if organism should be part of key if ("gene".equalsIgnoreCase(type)) { clsName = "Gene"; String taxonId = organism.getAttribute("taxonId").getValue(); if (idField == null) { idField = configs.get(taxonId).identifier; if (idField == null) { throw new RuntimeException( "Could not find a identifier property for taxon: " + taxonId + " check properties file: " + PROP_FILE); } } // if a Dmel gene we need to use FlyBaseIdResolver to find a current id if ("7227".equals(taxonId)) { IdResolver resolver = flybaseResolverFactory.getIdResolver(false); if (resolver != null) { int resCount = resolver.countResolutions(taxonId, accession); if (resCount != 1) { LOG.info( "RESOLVER: failed to resolve gene to one identifier, " + "ignoring gene: " + accession + " count: " + resCount + " FBgn: " + resolver.resolveId(taxonId, accession)); return null; } accession = resolver.resolveId(taxonId, accession).iterator().next(); } } } else if ("protein".equalsIgnoreCase(type)) { // TODO use values in config clsName = "Protein"; idField = "primaryAccession"; } else { String typeCls = TypeUtil.javaiseClassName(type); if (getModel().getClassDescriptorByName(typeCls) != null) { Class<?> cls = getModel().getClassDescriptorByName(typeCls).getType(); if (BioEntity.class.isAssignableFrom(cls)) { clsName = typeCls; } } if (clsName == null) { throw new IllegalArgumentException("Unrecognised annotation type '" + type + "'"); } } boolean includeOrganism; if ("primaryIdentifier".equals(idField) || "protein".equals(type)) { includeOrganism = false; } else { includeOrganism = createOrganism; } String key = makeProductKey(accession, type, organism, includeOrganism); // Have we already seen this product somewhere before? // if so, return the product rather than creating a new one... if (productMap.containsKey(key)) { return productMap.get(key); } // if a Dmel gene we need to use FlyBaseIdResolver to find a current id Item product = createItem(clsName); if (organism != null && createOrganism) { product.setReference("organism", organism.getIdentifier()); } product.setAttribute(idField, accession); String dataSetIdentifier = getDataset(dataSourceCode); product.addToCollection("dataSets", dataSetIdentifier); Integer storedProductId = store(product); storedProductIds.put(product.getIdentifier(), storedProductId); productMap.put(key, product.getIdentifier()); return product.getIdentifier(); }