public void onMIIdentifierUpdate(CvTerm cv, String oldMI) { if (oldMI == null){ cvChangeLogger.log(Level.INFO, "The MI identifier " + cv.getMIIdentifier() + " has been added to the cv term " + cv.toString()); } else if (cv.getMIIdentifier() == null){ cvChangeLogger.log(Level.INFO, "The MI identifier "+ oldMI+ " has been removed from the cv term " + cv.toString()); } else { cvChangeLogger.log(Level.INFO, "The MI identifier "+oldMI+" has been updated with " + cv.getMIIdentifier() + " in the cv term " + cv.toString()); } }
public Sentence(CvTerm interactionType, CvTerm detMethod){ if (interactionType == null || interactionType.getMIIdentifier() == null){ throw new IllegalArgumentException("The interaction type cannot be null and must have a valid identifier."); } if (detMethod == null || detMethod.getMIIdentifier() == null){ throw new IllegalArgumentException("The interaction detection method cannot be null and must have a valid identifier."); } interactorsObject = new ArrayList<SimpleInteractor>(); interactorsSubject = new ArrayList<SimpleInteractor>(); interactionAcs = new ArrayList<String>(); this.interactionTypeMI = interactionType.getMIIdentifier(); this.detMethod = detMethod; }
public static Xref getPsiMiReference(CvTerm term){ if (term == null){ return null; } else if (term.getMIIdentifier() == null){ return null; } else{ return XrefUtils.collectFirstIdentifierWithDatabaseAndId(term.getIdentifiers(), CvTerm.PSI_MI_MI, CvTerm.PSI_MI, term.getMIIdentifier()); } }
/** * * @param role * @return true if the role is a role with a psi MI identifier mi or a psi Mi short label shortLabel */ private boolean checkParticipantRole(CvTerm role, String mi, String shortLabel){ if (role.getMIIdentifier() != null){ if (role.getMIIdentifier().equals(mi)){ return true; } } else { if (role.getShortName().equalsIgnoreCase(shortLabel)){ return true; } } return false; }
public void onPARIdentifierUpdate(CvTerm cv, String oldPAR) { if (oldPAR == null){ cvChangeLogger.log(Level.INFO, "The PAR identifier " + cv.getPARIdentifier() + " has been added to the cv term " + cv.toString()); } else if (cv.getMIIdentifier() == null){ cvChangeLogger.log(Level.INFO, "The PAR identifier "+ oldPAR+ " has been removed from the cv term " + cv.toString()); } else { cvChangeLogger.log(Level.INFO, "The PAR identifier "+oldPAR+" has been updated with " + cv.getPARIdentifier() + " in the cv term " + cv.toString()); } }
public void onMODIdentifierUpdate(CvTerm cv, String oldMOD) { if (oldMOD == null){ cvChangeLogger.log(Level.INFO, "The MOD identifier " + cv.getMODIdentifier() + " has been added to the cv term " + cv.toString()); } else if (cv.getMIIdentifier() == null){ cvChangeLogger.log(Level.INFO, "The MOD identifier "+ oldMOD+ " has been removed from the cv term " + cv.toString()); } else { cvChangeLogger.log(Level.INFO, "The MOD identifier "+oldMOD+" has been updated with " + cv.getMODIdentifier() + " in the cv term " + cv.toString()); } }
/** * To know if the participant evidence does have a specific experimental role * @param participant * @param roleId * @param roleName * @return true if the participant has the experimental role with given name/identifier */ public static boolean doesParticipantHaveExperimentalRole(ParticipantEvidence participant, String roleId, String roleName){ if (participant == null || (roleName == null && roleId == null)){ return false; } CvTerm role = participant.getExperimentalRole(); // we can compare identifiers if (roleId != null && role.getMIIdentifier() != null){ // we have the same topic id return role.getMIIdentifier().equals(roleId); } // we need to compare topic names else if (roleName != null) { return roleName.equalsIgnoreCase(role.getShortName()); } return false; }
/** * To check if a checksum does have a specific method * @param checksum the checksum * @param methodId the checksum MI identifier * @param methodName the checksum method name * @return true if the checksum has the method with given name/identifier */ public static boolean doesChecksumHaveMethod(Checksum checksum, String methodId, String methodName){ if (checksum == null || (methodName == null && methodId == null)){ return false; } CvTerm method = checksum.getMethod(); // we can compare identifiers if (methodId != null && method.getMIIdentifier() != null){ // we have the same method id return method.getMIIdentifier().equals(methodId); } // we need to compare methodNames else if (methodName != null) { return methodName.equalsIgnoreCase(method.getShortName()); } return false; }
@Override protected boolean isParticipantPrey(Participant component) { return getPreyMi().contains(((ParticipantEvidence) component) .getExperimentalRole().getMIIdentifier()); }
/** * To know if the annotation does have a specific topic * @param annotation : the annotation * @param topicId : the topic MI identifier * @param topicName : the topic name * @return true if the annotation has the topic with given name/identifier */ public static boolean doesAnnotationHaveTopic(Annotation annotation, String topicId, String topicName){ if (annotation == null || (topicName == null && topicId == null)){ return false; } CvTerm topic = annotation.getTopic(); // we can compare identifiers if (topicId != null && topic.getMIIdentifier() != null){ // we have the same topic id return topic.getMIIdentifier().equals(topicId); } // we need to compare topic names else if (topicName != null) { return topicName.equalsIgnoreCase(topic.getShortName()); } return false; }
@Override protected boolean isParticipantBait(Participant component) { return getBaitMi().contains(((ParticipantEvidence) component) .getExperimentalRole().getMIIdentifier()); }
private String buildDbList( Collection<Xref> identities ) { StringBuilder sb = new StringBuilder( 128 ); for ( Iterator<Xref> dbReferenceIterator = identities.iterator(); dbReferenceIterator.hasNext(); ) { Xref ref = dbReferenceIterator.next(); final String db = ref.getDatabase().getShortName(); final String dbAc = ref.getDatabase().getMIIdentifier(); if( db != null && db.length() > 0 ) { sb.append( db ).append(" ,"); } else if( dbAc != null && dbAc.length() > 0 ) { sb.append( dbAc ).append(" ,"); } } int length = sb.length(); if( length > 0 ) { length = length - 2; // gets rid of the last comma } return sb.substring( 0, length ); }
/** * Check if the CvTerm natches the MI term and/or the name if no MI term exist * @param term : the term to check * @param mi : the mi id to compare * @param name : the name to compare * @return true if the CvTerm natches the MI term and/or the name */ public static boolean isCvTerm(CvTerm term, String mi, String name){ if (term.getMIIdentifier() != null && mi != null){ return term.getMIIdentifier().equals(mi); } else{ if (term.getShortName().equalsIgnoreCase(name) || (term.getFullName() != null && term.getFullName().equalsIgnoreCase(name))){ return true; } else { return false; } } }
public static Term buildTerm( CvTerm cv ) { if (cv == null){ return null; } final String id = cv.getMIIdentifier(); if( id == null ) { return null; } return new Term( id, cv.getShortName() ); }
/** * Collect all Xrefs having specific databases * @param xrefs * @param dbMiRefs * @param dbRefs * @return */ public static Collection<Xref> searchAllXrefsHavingDatabases(Collection<Xref> xrefs, Collection<String> dbMiRefs, Collection<String> dbRefs) { if (xrefs == null || xrefs.isEmpty() || (dbMiRefs.isEmpty() && dbRefs.isEmpty())){ return Collections.EMPTY_LIST; } Collection<Xref> refs = new ArrayList<Xref>(xrefs.size()); for ( Xref ref : xrefs ) { if (ref.getDatabase().getMIIdentifier() != null && !dbMiRefs.isEmpty()) { if (!dbMiRefs.contains( ref.getDatabase().getMIIdentifier() )){ continue; } } else if (!dbRefs.contains( ref.getDatabase().getShortName() )){ continue; } refs.add( ref ); } return refs; }
/** * Return the proper instance of the interactor if the database is recognized. It returns null otherwise. * @param database : the database * @param name : the name * @return the proper instance of the interactor if the database is recognized. It returns null otherwise. */ public Interactor createInteractorFromDatabase(CvTerm database, String name){ if (database == null){ return null; } String databaseName = database.getShortName().toLowerCase().trim(); String databaseMI = database.getMIIdentifier(); if (databaseMI != null && this.deterministicInteractorIdMap.containsKey(databaseMI)){ InteractorCategory recognizedType = this.deterministicInteractorIdMap.get(databaseMI); return createInteractorFromRecognizedCategory(recognizedType, name, null); } else if (databaseMI == null && this.deterministicInteractorNameMap.containsKey(databaseName)){ InteractorCategory recognizedType = this.deterministicInteractorNameMap.get(databaseName); return createInteractorFromRecognizedCategory(recognizedType, name, null); } return null; }
/** * Method to know if a Xref is a potential identifier. * It can be an identity xref or a secondary xref. * @param ref : the Xref * @return true if the Xref has a qualifier identity or secondary-ac */ public static boolean isXrefAnIdentifier(Xref ref){ if (ref == null || ref.getQualifier() == null){ return false; } String qualifierMI = ref.getQualifier().getMIIdentifier(); if (qualifierMI != null){ return (Xref.IDENTITY_MI.equals(qualifierMI) || Xref.SECONDARY_MI.equals(qualifierMI)); } else { String qualifier = ref.getQualifier().getShortName(); return (Xref.IDENTITY.equalsIgnoreCase(qualifier) || Xref.SECONDARY.equalsIgnoreCase(qualifier)); } }
protected void buildInteractionkey(I interaction) { this.stringBuilder.setLength(0); this.interactorAcs.clear(); // read ordered set of interactor acs for (Object obj : interaction.getParticipants()) { Participant component = (Participant)obj; interactorAcs.add(component.getInteractor() instanceof IntactInteractor ? ((IntactInteractor) component.getInteractor()).getAc() : component.getInteractor().getShortName()); } for (String prL : interactorAcs) { stringBuilder.append(" "); stringBuilder.append(prL); } // interaction type stringBuilder.append(interaction.getInteractionType().getMIIdentifier()); // experiment CvTerm method = extractInteractionDetectionMethodFrom(interaction); if (method != null) { stringBuilder.append(" "); stringBuilder.append(method.getMIIdentifier()); } }
protected T createNewTerm(Term t) { T ontologyTerm = instantiateNewTerm(t.getName(), XrefUtils.createIdentityXref(getOntologyDatabase().getShortName(), getOntologyDatabase().getMIIdentifier(), t.getIdentifier())); // load synonyms (alias and shortlabel) processSynonyms(t, ontologyTerm); // set shortlabel in case it was not set with synonyms processShortLabel(t, ontologyTerm); // load db xrefs processXrefs(t, ontologyTerm); // load definition, url, obsolete message processDefinition(t, ontologyTerm); // load annotations processAnnotations(t, ontologyTerm); return ontologyTerm; }
@Override protected IdentificationResults identifyProtein( Xref xrefToMap, IdentificationContext context) throws BridgeFailedException { String value = xrefToMap.getId(); String database = null; String databaseName = null; //Find a way to identify the database if(xrefToMap.getDatabase() != null){ database = xrefToMap.getDatabase().getMIIdentifier(); databaseName = xrefToMap.getDatabase().getShortName(); } //If there's an identity do a search - else return an empty result. if((database != null || databaseName != null) && value != null){ String key = "IDENTIFY_XREF_DB_"+(database != null ? database : databaseName)+"_"+value+(context.getOrganism() != null ? context.getOrganism().getTaxId() : ""); Object o = getFromCache(key); if (o != null){ return (IdentificationResults)o; } IdentificationResults res = super.identifyProtein(xrefToMap, context); storeInCache(key, res); return res; } return null; }