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; }
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); } } }
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; }
/** * Searches for gene symbol in Xref. * @param xref Xref to search * @return gene symbol */ private String extractGeneSymbol(Xref xref) { if (xref.getDb() != null && ( xref.getDb().equalsIgnoreCase("HGNC Symbol") || xref.getDb().equalsIgnoreCase("Gene Symbol") || xref.getDb().equalsIgnoreCase("HGNC"))) { String ref = xref.getId(); if (ref != null) { ref = ref.trim(); if (ref.contains(":")) ref = ref.substring(ref.indexOf(":") + 1); if (ref.contains("_")) ref = ref.substring(ref.indexOf("_") + 1); // if the reference is an HGNC ID, then convert it to a symbol if (!HGNC.containsSymbol(ref) && Character.isDigit(ref.charAt(0))) { ref = HGNC.getSymbol(ref); } } return ref; } return null; }
private org.opencb.bionetdb.core.models.Rna createRna(BioPAXElement bioPAXElement) { org.opencb.bionetdb.core.models.Rna rna = new org.opencb.bionetdb.core.models.Rna(); Rna rnaBP = (Rna) bioPAXElement; // Common properties setPhysicalEntityCommonProperties(rnaBP, rna); // Rna properties if (rnaBP.getEntityReference() != null) { EntityReference entityReference = rnaBP.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); rna.setXref(xref); } // description rna.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()); rna.setXref(x); } } return rna; }
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; }
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());
/** * Searches for the gene symbol of the given EntityReference. * @param pr to search for a symbol * @return symbol */ protected String getGeneSymbol(ProteinReference pr) { for (Xref xr : pr.getXref()) { String db = xr.getDb(); if (db != null) { db = db.toLowerCase(); if (db.startsWith("hgnc")) { String id = xr.getId(); if (id != null) { String symbol = HGNC.getSymbol(id); if (symbol != null && !symbol.isEmpty()) { return symbol; } } } } } return null; }
private static void createSpecialXrefAttribute(BioPAXElement resource, CyNetwork network, CyNode node, Xref link) { final String db = link.getDb().toUpperCase().trim(); final String id = link.getId().trim(); if(db.equalsIgnoreCase("HGNC SYMBOL") //- official primary db name || db.startsWith("HGNC") || db.startsWith("HUGO GENE") || db.startsWith("GENE SYMBOL") || db.startsWith("GENE NAME")) { String exists = network.getRow(node).get("GENE SYMBOL", String.class); //won't replace any existing value (added first) if (exists == null && !id.startsWith("HGNC:")) //ignore HGNC:12345 IDs AttributeUtil.set(network, node, "GENE SYMBOL", id, String.class); } else if(db.equalsIgnoreCase("NCBI GENE") //main (official) db name || db.equalsIgnoreCase("ENTREZ GENE") || db.equalsIgnoreCase("GENE ID")) { String exists = network.getRow(node).get("NCBI GENE", String.class); //won't replace any existing value (added first) if (exists == null) AttributeUtil.set(network, node, "NCBI GENE", id, String.class); } else if(db.startsWith("UNIPROT") || db.startsWith("SWISSPROT") || db.startsWith("SWISS-PROT")) { String exists = network.getRow(node).get("UNIPROT", String.class); //won't replace if found if (exists == null) AttributeUtil.set(network, node, "UNIPROT", id, String.class); } }
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); } } } }
public void check(Xref x, boolean fix) { String db = x.getDb(); if (db != null) {
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); } } } }
String source = null; db = x.getDb(); id = x.getId(); if(x instanceof RelationshipXref) {
String source = null; db = x.getDb(); String ver = x.getIdVersion();
db = x.getDb(); String ver = x.getIdVersion();
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); } */ } } }