private void collectXrefIdIfDbLike(final Xref x, final String dbStartsWith, final Set<String> set) { String db = x.getDb(); String id = x.getId(); if (db != null && id != null && !id.isEmpty()) { db = db.toLowerCase(); if (db.startsWith(dbStartsWith)) { //for a (PR/NAR) HGNC case, call HGNC.getSymbol(id) mapping if (db.startsWith("hgnc")) id = HGNC.getSymbol(id); if (id != null) set.add(id); } } }
for(Xref ref : xrefs) { String db = ref.getDb(); String id = ref.getId(); log.error(ref.getModelInterface().getSimpleName() + " " + ref.getRDFId() + " - 'db' property is empty! " + extraInfo()); continue; // skip it log.error(ref.getModelInterface().getSimpleName() + " - 'id' property is empty! " + extraInfo()); ref.setDb(db); } catch (IllegalArgumentException e) { if(log.isWarnEnabled()) log.warn("Unknown db: " + db + ". Cannot replace " + ref.getDb() + " with a standard name! " + ref.getRDFId() + "; " + e + "; " + extraInfo()); String rdfid = generateURIForXref(db, id, ref.getIdVersion(), (Class<? extends Xref>) ref.getModelInterface());
if (xref.getDb() != null) { String source = xref.getDb().toLowerCase(); if (source.equals("sbo") || source.equals("go") || source.equals("mi") || source.equals("ec")) { interaction.setOntology(new Ontology(xref.getDb(), xref.getDbVersion(), xref.getId(), xref.getIdVersion())); } else if (source.equals("pubmed")) { interaction.setPublication(new Publication(xref.getDb(), xref.getId())); } else { interaction.setXref(new org.opencb.bionetdb.core.models.Xref(xref.getDb(), xref.getDbVersion(), xref.getId(), xref.getIdVersion()));
public void check(final Validation validation, Xref x) { String db = x.getDb(); if (db != null) { String id = x.getId(); if (id != null) { if (!xrefHelper.canCheckIdFormatIn(preferedDbName)) { x.setDb("UniProt Isoform"); x.setId(id.toUpperCase()); x.setDb("PSI-MOD"); x.setId(id.toUpperCase()); String newId = id.substring(0, i); if (xrefHelper.checkIdFormat(preferedDbName, newId)) { x.setId(newId); x.setIdVersion(id.substring(i + 1)); x.setId(newId); error(validation, x, "invalid.id.format", true); if (logger.isDebugEnabled()) logger.debug(x.getModelInterface() .getSimpleName() + " " + x + " 'id' auto-fixed! (was: " + id + ")"); x.setId(newId); error(validation, x, "invalid.id.format", true); if (logger.isDebugEnabled()) logger.debug(x.getModelInterface()
public void check(Xref x, boolean fix) { String db = x.getDb(); if (db != null) { String id = x.getId(); if (id != null) { if (!xrefHelper.canCheckIdFormatIn(preferedDbName)) { String newId = id.substring(0, i); if (xrefHelper.checkIdFormat(preferedDbName, newId)) { x.setId(newId); x.setIdVersion(id.substring(i + 1)); if (logger.isDebugEnabled()) logger.debug("auto-fix: split id and idVersion for xref: " + x + " " + x.getRDFId()); x.setId(newId); error(x, "invalid.id.format", true); if (logger.isDebugEnabled()) logger.debug(x.getModelInterface() .getSimpleName() + " " + x + " 'id' auto-fixed! (was: " + id + ")");
String source = null; db = x.getDb(); String ver = x.getIdVersion(); id = x.getId(); // + ((ver!=null) ? "_" + ver : ""); if(x instanceof RelationshipXref) { RelationshipTypeVocabulary v = ((RelationshipXref)x).getRelationshipType();
/** * Gets the NCBI Taxonomy ID. * * @param bpe BioPAX element * @return taxonomyId, or -1, if not available. */ private static int getOrganismTaxonomyId(CyNetwork network, BioPAXElement bpe) { int taxonomyId = -1; try { Object bs = getValue(bpe, "organism"); if (bs instanceof BioSource) { Set<Xref> xrefs = ((BioSource)bs).getXref(); if(!xrefs.isEmpty()) { Xref tx = xrefs.iterator().next(); taxonomyId = Integer.parseInt(tx.getId()); } } } catch (Exception e) { taxonomyId = -1; } return taxonomyId; }
public void check(Provenance p, boolean fix) { // check standardName or displayName is valid String db = null; if(p.getStandardName() != null) db = xrefHelper.getPrimaryDbName(p.getStandardName()); if (db == null) { // was null or unknown name; try displayName - if(p.getDisplayName() != null) { db = xrefHelper.getPrimaryDbName(p.getDisplayName()); if (db == null) { error(p, "unknown.db", false, p.getDisplayName() + " or " + p.getStandardName()); } } else { error(p, "cardinality.violated", false, "standardName or displayName", 1); } } // check unif.xrefs for (Xref x : p.getXref()) { if (x instanceof UnificationXref) { error(x, "not.allowed.xref", false, x.getDb(), p, "Provenance", "- Miriam or PubMed but not a bioentities db!"); /* if(fix) { p.removeXref(x); } */ } } }
public void check(EntityReference er, boolean fix) { if(er.getMemberEntityReference().isEmpty()) { // for non-generic ERs only if (er.getXref().isEmpty()) { error(er, "no.xrefs", false); } else { boolean present = false; for (Xref x : er.getXref()) { Class<? extends BioPAXElement> face = x.getModelInterface(); if (UnificationXref.class.equals(face)) { present = true; } } if (!present) { error(er, "no.unification.xref", false); } } } }
private org.opencb.bionetdb.core.models.Dna createDna(BioPAXElement bioPAXElement) { org.opencb.bionetdb.core.models.Dna dna = new org.opencb.bionetdb.core.models.Dna(); Dna dnaBP = (Dna) bioPAXElement; // Common properties setPhysicalEntityCommonProperties(dnaBP, dna); // Dna properties if (dnaBP.getEntityReference() != null) { EntityReference entityReference = dnaBP.getEntityReference(); // altIds for (String name : entityReference.getName()) { org.opencb.bionetdb.core.models.Xref xref = new org.opencb.bionetdb.core.models.Xref(); xref.setSource(REACTOME_FEAT + "biopax"); xref.setId(name); dna.setXref(xref); } // description dna.setDescription(new ArrayList<>(entityReference.getComment())); // xref Set<Xref> xrefs = entityReference.getXref(); for (Xref xref : xrefs) { org.opencb.bionetdb.core.models.Xref x = new org.opencb.bionetdb.core.models.Xref(); x.setSource(xref.getDb()); x.setSourceVersion(xref.getDbVersion()); x.setId(xref.getId()); x.setIdVersion(xref.getIdVersion()); dna.setXref(x); } } return dna; }
db = x.getDb(); String ver = x.getIdVersion(); id = x.getId(); // + ((ver!=null) ? "_" + ver : ""); if(x instanceof RelationshipXref) { RelationshipTypeVocabulary v = ((RelationshipXref)x).getRelationshipType();
public void check(Xref x, boolean fix) { String db = x.getDb(); if (db == null) { return; // another (cardinality) rule reports } String primary = xrefHelper.getPrimaryDbName(db); // if primary is null, do nothing, - another rule (XrefRule) reports this if (primary != null && !primary.equalsIgnoreCase(db)) { // report only if it is definitely not official db synonym if (xrefHelper.isUnofficialOrMisspelledDbName(db)) error(x, "db.name.spelling", fix, db, primary); // fix, sometimes w/o error message, anyway ;) if(fix) { x.setDb((String) primary); } } } }
/** * Gets the NCBI Taxonomy ID. * @param bpe BioPAX element * * @return taxonomyId, or -1, if not available. */ public static int getOrganismTaxonomyId(BioPAXElement bpe) { int taxonomyId = -1; try { Object bs = getValue(bpe, "organism"); if (bs instanceof BioSource) { Set<Xref> xrefs = ((BioSource)bs).getXref(); if(!xrefs.isEmpty()) { Xref tx = xrefs.iterator().next(); taxonomyId = Integer.parseInt(tx.getId()); } } } catch (Exception e) { taxonomyId = -1; } return taxonomyId; }
public void check(EntityReference er, boolean fix) { if(!er.getMemberEntityReference().isEmpty()) { if (er.getXref().isEmpty()) { error(er, "no.xrefs", false); } else { boolean present = false; for (Xref x : er.getXref()) { Class<? extends BioPAXElement> face = x.getModelInterface(); if (UnificationXref.class.equals(face)) { present = true; } } if (!present) { error(er, "no.unification.xref", false); } } } }
private org.opencb.bionetdb.core.models.Protein createProtein(BioPAXElement bioPAXElement) { org.opencb.bionetdb.core.models.Protein protein = new org.opencb.bionetdb.core.models.Protein(); Protein proteinBP = (Protein) bioPAXElement; // Common properties setPhysicalEntityCommonProperties(proteinBP, protein); // Protein properties if (proteinBP.getEntityReference() != null) { EntityReference entityReference = proteinBP.getEntityReference(); // altIds for (String name : entityReference.getName()) { org.opencb.bionetdb.core.models.Xref xref = new org.opencb.bionetdb.core.models.Xref(); xref.setSource(REACTOME_FEAT + "biopax"); xref.setId(name); protein.setXref(xref); } // description protein.setDescription(new ArrayList<>(entityReference.getComment())); // xref Set<Xref> xrefs = entityReference.getXref(); for (Xref xref : xrefs) { org.opencb.bionetdb.core.models.Xref x = new org.opencb.bionetdb.core.models.Xref(); x.setSource(xref.getDb()); x.setSourceVersion(xref.getDbVersion()); x.setId(xref.getId()); x.setIdVersion(xref.getIdVersion()); protein.setXref(x); } } return protein; }
private Map<String, String> calculateIdMapings(Model model) { Map<String, String> idMappings = new HashMap<String, String>(); final Set<SimplePhysicalEntity> proteins = model.getObjects(SimplePhysicalEntity.class); for (SimplePhysicalEntity protein : proteins) { final String protRefId = protein.getEntityReference().getRDFId(); for (Xref xref : protein.getXref()) { if ("uniprotkb".equals(xref.getDb())) { String newId = IDENTIFIERS_ORG + "uniprot/" + xref.getId(); idMappings.put(protRefId, newId); break; } else if ("chebi".equals(xref.getDb())) { String newId = IDENTIFIERS_ORG + xref.getDb() + "/" + xref.getId(); idMappings.put(protRefId, newId); break; } } } return idMappings; }
public void check(final Validation validation, Xref x) { String db = x.getDb(); if (db == null) { return; // another (cardinality) rule reports } String primary = xrefHelper.getPrimaryDbName(db); // if primary is null, do nothing, - another rule (XrefRule) reports this if (primary != null && !primary.equalsIgnoreCase(db)) { // report only if it is definitely not official db synonym if (xrefHelper.isUnofficialOrMisspelledDbName(db)) error(validation, x, "db.name.spelling", validation.isFix(), db, primary); // fix, sometimes w/o error message, anyway ;) if (validation.isFix()) { x.setDb(primary); } } } }
/** * Gets the NCBI Taxonomy ID. * * @param bpe BioPAX element * @return taxonomyId, or -1, if not available. */ public static int getOrganismTaxonomyId(BioPAXElement bpe) { int taxonomyId = -1; if(bpe instanceof physicalEntityParticipant) { return getOrganismTaxonomyId(((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY()); } try { Object bs = getValue(bpe, "ORGANISM", "organism"); if (bs instanceof BioSource) { Set<Xref> xrefs = ((BioSource)bs).getXref(); if(!xrefs.isEmpty()) { Xref tx = xrefs.iterator().next(); taxonomyId = Integer.parseInt(tx.getId()); } } else if(bs instanceof bioSource){ taxonomyId = Integer.parseInt(((bioSource)bs).getTAXON_XREF().getID()); } } catch (Exception e) { taxonomyId = -1; } return taxonomyId; }
public void check(final Validation validation, EntityReference er) { if(!er.getMemberEntityReference().isEmpty()) { if (er.getXref().isEmpty()) { error(validation, er, "no.xrefs", false); } else { boolean present = false; for (Xref x : er.getXref()) { Class<? extends BioPAXElement> face = x.getModelInterface(); if (UnificationXref.class.equals(face)) { present = true; } } if (!present) { error(validation, er, "no.unification.xref", false); } } } }