public boolean isEmpty() { //We don not want to have a empty interactor, we prefer a null interactor return (this.getIdentifiers() == null || this.getIdentifiers().isEmpty()) && (this.getAlternativeIdentifiers() == null || this.getAlternativeIdentifiers().isEmpty()) && (this.getAliases() == null || this.getAliases().isEmpty()) && (!this.hasOrganism() || (this.hasOrganism() && this.getOrganism().getIdentifiers().isEmpty() && this.getOrganism().getTaxid() == null || this.getOrganism().getTaxid().isEmpty()) ) && (this.getBiologicalRoles() == null || this.getBiologicalRoles().isEmpty()) && (this.getExperimentalRoles() == null || this.getExperimentalRoles().isEmpty()) && (this.getInteractorTypes() == null || this.getInteractorTypes().isEmpty()) && (this.getXrefs() == null || this.getXrefs().isEmpty()) && (this.getChecksums() == null || this.getChecksums().isEmpty()) && (this.getFeatures() == null || this.getFeatures().isEmpty()) && (this.getStoichiometry() == null || this.getStoichiometry().isEmpty()) && (this.getParticipantIdentificationMethods() == null || this.getParticipantIdentificationMethods().isEmpty()); } /////////////////////////////
public Interactor newInteractor(List<CrossReference> identifiers) { return new Interactor(identifiers); } }
protected void populateInteractor(Interactor source, Interactor target) { if (target != null && source != null){ target.getAlternativeIdentifiers().addAll(source.getAlternativeIdentifiers()); target.getAliases().addAll(source.getAliases()); if ( !target.hasOrganism() ) { target.setOrganism(new OrganismImpl()); } if( source.hasOrganism() ) { target.getOrganism().getIdentifiers().addAll(source.getOrganism().getIdentifiers()); } target.getAnnotations().addAll(source.getAnnotations()); target.getBiologicalRoles().addAll(source.getBiologicalRoles()); target.getChecksums().addAll(source.getChecksums()); target.getFeatures().addAll(source.getFeatures()); target.getInteractorTypes().addAll(source.getInteractorTypes()); target.getParticipantIdentificationMethods().addAll(source.getParticipantIdentificationMethods()); target.getStoichiometry().addAll(source.getStoichiometry()); target.getXrefs().addAll(source.getXrefs()); } } }
public SimpleInteractor( Interactor interactor ) { if ( interactor == null ) { this.identifiers = new ArrayList<CrossReference>(); } else { this.identifiers = interactor.getIdentifiers(); if ( interactor.hasOrganism() ) { for ( CrossReference cr : interactor.getOrganism().getIdentifiers() ) { if ( cr.getDatabase().equals( "taxid" ) ) { taxid = new Integer( cr.getIdentifier() ); } } } } }
if (!interactor.getAliases().isEmpty()) { label = pickFirstRelevantAlias(interactor.getAliases(), new AliasByTypeComparator(), true); } else if (!interactor.getAlternativeIdentifiers().isEmpty()) { final IdentifierByTextComparator comparator = new IdentifierByTextComparator(); CrossReference cr = pickFirstRelevantIdentifier(interactor.getAlternativeIdentifiers(), comparator, true); if (cr != null) label = cr.getIdentifier(); if (!interactor.getAliases().isEmpty()) { label = pickFirstRelevantAlias(interactor.getAliases(), new AliasByIncreasingLengthComparator(), true); } else if (!interactor.getIdentifiers().isEmpty()) { final CrossReferenceComparator comparator = new IdentifierByDatabaseComparator(); CrossReference cr = pickFirstRelevantIdentifier(interactor.getIdentifiers(), comparator, false); if (cr != null) label = cr.getIdentifier(); } else if (!interactor.getAlternativeIdentifiers().isEmpty()) { final CrossReference cr = interactor.getAlternativeIdentifiers().iterator().next(); label = cr.getIdentifier();
hasFoundIdentity = true; mitabInteractor.getIdentifiers().add(identity); CrossReference identity = xRefConverter.createCrossReference(ref, false); if (identity != null){ mitabInteractor.getAlternativeIdentifiers().add(identity); CrossReference identity = xRefConverter.createCrossReference(ref, false); if (identity != null){ mitabInteractor.getAlternativeIdentifiers().add(identity); CrossReference xref = xRefConverter.createCrossReference(ref, true); if (xref != null){ mitabInteractor.getXrefs().add(xref);
Interactor interactorA = new Interactor(); Interactor interactorB = new Interactor(); interactorA.setIdentifiers(splitCrossReferences(line[PsimiTabColumns.ID_INTERACTOR_A.ordinal()])); interactorA.setAlternativeIdentifiers(splitCrossReferences(line[PsimiTabColumns.ALTID_INTERACTOR_A.ordinal()])); interactorA.setAliases(splitAliases(line[PsimiTabColumns.ALIAS_INTERACTOR_A.ordinal()])); interactorA.setOrganism(splitOrganism(line[PsimiTabColumns.TAXID_A.ordinal()])); interactorB.setIdentifiers(splitCrossReferences(line[PsimiTabColumns.ID_INTERACTOR_B.ordinal()])); interactorB.setAlternativeIdentifiers(splitCrossReferences(line[PsimiTabColumns.ALTID_INTERACTOR_B.ordinal()])); interactorB.setAliases(splitAliases(line[PsimiTabColumns.ALIAS_INTERACTOR_B.ordinal()])); interactorB.setOrganism(splitOrganism(line[PsimiTabColumns.TAXID_B.ordinal()])); interactorA.setBiologicalRoles(splitCrossReferences(line[PsimiTabColumns.BIOROLE_A.ordinal()])); interactorA.setExperimentalRoles(splitCrossReferences(line[PsimiTabColumns.EXPROLE_A.ordinal()])); interactorA.setInteractorTypes(splitCrossReferences(line[PsimiTabColumns.INTERACTOR_TYPE_A.ordinal()])); interactorA.setXrefs(splitCrossReferences(line[PsimiTabColumns.XREFS_A.ordinal()])); interactorA.setAnnotations(splitAnnotations(line[PsimiTabColumns.ANNOTATIONS_A.ordinal()])); interactorA.setChecksums(splitChecksums(line[PsimiTabColumns.CHECKSUM_A.ordinal()])); interactorB.setBiologicalRoles(splitCrossReferences(line[PsimiTabColumns.BIOROLE_B.ordinal()])); interactorB.setExperimentalRoles(splitCrossReferences(line[PsimiTabColumns.EXPROLE_B.ordinal()])); interactorB.setInteractorTypes(splitCrossReferences(line[PsimiTabColumns.INTERACTOR_TYPE_B.ordinal()])); interactorB.setXrefs(splitCrossReferences(line[PsimiTabColumns.XREFS_B.ordinal()])); interactorB.setAnnotations(splitAnnotations(line[PsimiTabColumns.ANNOTATIONS_B.ordinal()])); interactorB.setChecksums(splitChecksums(line[PsimiTabColumns.CHECKSUM_B.ordinal()])); interactorA.setFeatures(splitFeatures(line[PsimiTabColumns.FEATURES_A.ordinal()])); interactorA.setStoichiometry(splitStoichiometries(line[PsimiTabColumns.STOICHIOMETRY_A.ordinal()]));
psidev.psi.mi.tab.model.Interactor mitabInteractor = new psidev.psi.mi.tab.model.Interactor(); MitabInteractor convertedInteractorResult = new MitabInteractor(mitabInteractor); mitabInteractor.getAnnotations().add(annotField); mitabInteractor.setOrganism(bioSourceField); CrossReference type = cvObjectConverter.toCrossReference(interactorType); if (type != null){ mitabInteractor.getInteractorTypes().add(type); mitabInteractor.getBiologicalRoles().add(bioRole); CrossReference expRoleField = cvObjectConverter.toCrossReference(expRole); if (expRoleField != null){ mitabInteractor.getExperimentalRoles().add(expRoleField); if (mitabInteractor.getExperimentalRoles().isEmpty()){ CrossReference expRoleField = new CrossReferenceImpl(CvDatabase.PSI_MI, CvExperimentalRole.UNSPECIFIED_PSI_REF, CvExperimentalRole.UNSPECIFIED); mitabInteractor.getExperimentalRoles().add(expRoleField); psidev.psi.mi.tab.model.Feature featureField = featureConverter.intactToMitab(feature); if (featureField != null){ mitabInteractor.getFeatures().add(featureField); mitabInteractor.getStoichiometry().add((int) participant.getStoichiometry()); mitabInteractor.getParticipantIdentificationMethods().clear();
public void enrich(Interactor interactor) throws Exception { if (interactor == null){ return; } // enrich organisms if (interactor.getOrganism() != null) { enrich(interactor.getOrganism().getIdentifiers()); } // enrich biological role if (interactor.getBiologicalRoles() != null) { enrich(interactor.getBiologicalRoles()); } // enrich experimental roles if (interactor.getExperimentalRoles() != null) { enrich(interactor.getExperimentalRoles()); } // enrich interactor types if (interactor.getInteractorTypes()!= null) { enrich(interactor.getInteractorTypes()); } // enrich xrefs if (interactor.getXrefs()!= null) { enrich(interactor.getXrefs()); } // enrich participant detection methods if (interactor.getParticipantIdentificationMethods()!= null) { enrich(interactor.getParticipantIdentificationMethods()); } }
if (tabInteractor.hasOrganism()) { psidev.psi.mi.tab.model.Organism o = tabInteractor.getOrganism(); Collection<CrossReference> tabIdentifiers = tabInteractor.getIdentifiers(); String primaryDatabase; String primaryId; if (!tabInteractor.getXrefs().isEmpty()) { for (CrossReference secondaryIdentifier : tabInteractor.getXrefs()) { DbReference secondaryRef = createSecondaryRef(secondaryIdentifier); secondaryRefs.add(secondaryRef); if (tabInteractor.getInteractorTypes() != null && !tabInteractor.getInteractorTypes().isEmpty()) { Collection<CrossReference> interactorTypes = tabInteractor.getInteractorTypes(); interactorType = cvConverter.fromMitab(interactorTypes, InteractorType.class); if (tabInteractor.getAnnotations() != null) { if (!tabInteractor.getAnnotations().isEmpty()) { for (Annotation annotation : tabInteractor.getAnnotations()) { Attribute attribute = new Attribute(annotation.getTopic(), annotation.getText()); xmlInteractor.getAttributes().add(attribute); Collection<Checksum> checksums = tabInteractor.getChecksums(); if (!checksums.isEmpty()) { for (Checksum checksum : checksums) {
private void setPhysicalEntityCommonProperties(Interactor interactor, PhysicalEntity physicalEntity) { physicalEntity.setId(interactor.getIdentifiers().get(0).getIdentifier()); cRList.addAll(interactor.getXrefs()); cRList.addAll(interactor.getAlternativeIdentifiers()); for (CrossReference cR : cRList) { if (cR.getDatabase() != null) { for (Alias alias : interactor.getAliases()) { Xref xref = new Xref(); xref.setSource(alias.getDbSource()); physicalEntity.setXref(xref); for (CrossReference id : interactor.getIdentifiers()) { Xref xref = new Xref(); xref.setSource(id.getDatabase()); for (Annotation annotation : interactor.getAnnotations()) { String comment = annotation.getText(); if (comment != null && (comment.equals("mint") || comment.equals("homomint") || comment.equals("domino"))) {
public NullCrossReference(BinaryInteraction binaryInteraction) { this.identifier = binaryInteraction.getInteractorA().getIdentifiers().iterator().next() +"_"+binaryInteraction.getInteractorB().getIdentifiers().iterator().next(); }
if ( interactor.getAlternativeIdentifiers() != null ) { for ( CrossReference altIdentifier : interactor.getAlternativeIdentifiers() ) { if ( "gene name".equals( altIdentifier.getText() ) ) { if ( "uniprotkb".equals( altIdentifier.getDatabase() ) ) { if ( interactor.hasOrganism() ) { for ( CrossReference organism : interactor.getOrganism().getIdentifiers() ) { String name = organism.getText(); if ( name != null ) { if ( !interactor.getAliases().isEmpty() && interactorName != null ) { for ( psidev.psi.mi.tab.model.Alias tabAlias : interactor.getAliases() ) { String type = tabAlias.getAliasType(); String value = tabAlias.getName();
if (!interactor.getIdentifiers().isEmpty()){ if (interactor.getIdentifiers().size() > 1){ log.warn("Interactor with more than one identifiers : " + interactor.toString() + ". Only the first identifier is taken into account"); return interactor.getIdentifiers().iterator().next().getIdentifier(); else if (!interactor.getAlternativeIdentifiers().isEmpty()){ if (interactor.getAlternativeIdentifiers().size() > 1){ log.warn("Interactor with more than one identifiers : " + interactor.toString() + ". Only the first identifier is taken into account"); return interactor.getAlternativeIdentifiers().iterator().next().getIdentifier(); throw new IllegalStateException("Interactor without identifiers : " + interactor.toString() + ". This interactor will be ignored"); else if (!interactor.getAlternativeIdentifiers().isEmpty() || !interactor.getIdentifiers().isEmpty()){ for (CrossReference ref : interactor.getIdentifiers()){ if (ref.getDatabase() != null && ref.getDatabase().equalsIgnoreCase(db)){ return ref.getIdentifier(); log.warn("The unique identifiers of interactor " + interactor.toString() + " are not recognized. We will look at the alternative identifiers"); if (!interactor.getAlternativeIdentifiers().isEmpty()){ for (String db : databasesForUniqIdentifier){ for (CrossReference ref : interactor.getAlternativeIdentifiers()){ if (ref.getDatabase() != null && ref.getDatabase().equalsIgnoreCase(db)){ return ref.getIdentifier();
/** * Pick the first relevant identifier available. * * @param interactor * @return */ protected CrossReference pickIdentifier(Interactor interactor) { CrossReference identifier = null; if (!interactor.getIdentifiers().isEmpty()) { final CrossReferenceComparator comparator = new IdentifierByDatabaseComparator(); identifier = pickFirstRelevantIdentifier(interactor.getIdentifiers(), comparator, true); } else if (!interactor.getAlternativeIdentifiers().isEmpty()) { final CrossReferenceComparator comparator = new IdentifierByDatabaseComparator(); identifier = pickFirstRelevantIdentifier(interactor.getAlternativeIdentifiers(), comparator, true); } // get less strict and just pick the first thing available in identifier or alt. identifier. if (identifier == null) { log.debug("WARNING - Could not find a relevant identifier for interactor: " + interactor); if (!interactor.getIdentifiers().isEmpty()) { identifier = interactor.getIdentifiers().iterator().next(); } else if (!interactor.getAlternativeIdentifiers().isEmpty()) { identifier = interactor.getAlternativeIdentifiers().iterator().next(); } } if (identifier == null) { throw new IllegalStateException("Can't find an Identifier for interactor " + interactor); } return identifier; }
Interactor psiInteractorA = new Interactor(); psiInteractorA.setIdentifiers(psiIdentifierA); psiInteractorA.setAlternativeIdentifiers(psiAlternativeIdentifierA); psiInteractorA.setAliases(psiAliasA); psiInteractorA.setOrganism(psiOrganismA); Interactor psiInteractorB = new Interactor(); psiInteractorB.setIdentifiers(psiIdentifierB); psiInteractorB.setAlternativeIdentifiers(psiAlternativeIdentifierB); psiInteractorB.setAliases(psiAliasB); psiInteractorB.setOrganism(psiOrganismB);
Collection<CrossReference> biologicalRoles = mitabInteractor.getBiologicalRoles(); BiologicalRole biologicalRole; Collection<CrossReference> experimentalRoles = mitabInteractor.getExperimentalRoles(); ExperimentalRole experimentalRole; Collection<Feature> features = mitabInteractor.getFeatures(); if (!features.isEmpty()) { for (Feature mitabFeature : features) { Collection<Integer> stoichiometry = mitabInteractor.getStoichiometry(); if (!stoichiometry.isEmpty()) { for (Integer integer : stoichiometry) { List<CrossReference> participantIdentificationMethods = mitabInteractor.getParticipantIdentificationMethods(); if (!participantIdentificationMethods.isEmpty()) {
@Deprecated private Reaction createReaction(BinaryInteraction binaryInteraction) { Reaction reaction = new Reaction(Reaction.ReactionType.REACTION); // Common properties setInteractionCommonProperties(binaryInteraction, reaction); // name reaction.setName("reaction_" + reaction.getId()); // Stoichiometry if (!binaryInteraction.getInteractorA().getStoichiometry().isEmpty() && !binaryInteraction.getInteractorB().getStoichiometry().isEmpty()) { Map stoichiometryA = new HashMap<String, Object>(); stoichiometryA.put("component", binaryInteraction.getInteractorA().getIdentifiers().get(0).getIdentifier()); stoichiometryA.put("coefficient", binaryInteraction.getInteractorA().getStoichiometry()); reaction.getStoichiometry().add(stoichiometryA); Map stoichiometryB = new HashMap<String, Object>(); stoichiometryB.put("component", binaryInteraction.getInteractorB().getIdentifiers().get(0).getIdentifier()); stoichiometryB.put("coefficient", binaryInteraction.getInteractorB().getStoichiometry()); reaction.getStoichiometry().add(stoichiometryB); } return reaction; }
if (!interactor.getIdentifiers().isEmpty()){ String shortLabel = null; for (CrossReference identifier : interactor.getIdentifiers()){ if (identifier.getDatabase().equals("uniprotkb")){ shortLabel = identifier.getIdentifier(); interactorName.setShortLabel(shortLabel); } else { log.debug("No valid uniprot interactorName found. default : 1.interactor identifier of db = "+interactor.getIdentifiers().iterator().next().getDatabase()); interactorName.setShortLabel(interactor.getIdentifiers().iterator().next().getIdentifier()); if (!interactor.getAliases().isEmpty() && interactorName != null){ for (psidev.psi.mi.tab.model.Alias tabAlias : interactor.getAliases()){ String type = tabAlias.getAliasType(); String value = tabAlias.getName();
private void processClustering(MiClusterContext context, List<BinaryInteraction> interactionToProcess, BinaryInteraction<Interactor> interaction, String intactAc, Interactor interactorA, String uniprotA, Interactor interactorB, String uniprotB, boolean excludedSpokeExpanded, boolean isNegative) { if (!this.interactionsToExclude.contains(intactAc)){ FilterUtils.processGeneNames(interactorA, uniprotA, interactorB, uniprotB, context); processMiTerms(interaction, context, intactAc); removeNonPubmedPublicationsFrom(interaction); if (interactorA != null){ removeNonIntactXrefsFrom(interaction.getInteractorA().getAlternativeIdentifiers()); interaction.getInteractorA().getAliases().clear(); } if (interactorB != null){ removeNonIntactXrefsFrom(interaction.getInteractorB().getAlternativeIdentifiers()); interaction.getInteractorB().getAliases().clear(); } if (!interaction.getComplexExpansion().isEmpty() && !excludedSpokeExpanded){ logger.info(intactAc + " passes the filters"); interactionToProcess.add(interaction); context.getSpokeExpandedInteractions().add(intactAc); } else if (interaction.getComplexExpansion().isEmpty()) { logger.info(intactAc + " passes the filters"); interactionToProcess.add(interaction); } else if (!interaction.getComplexExpansion().isEmpty()){ context.getSpokeExpandedInteractions().add(intactAc); } } }