public Participant buildParticipantB(psidev.psi.mi.xml.model.Interactor xmlInteractor, BinaryInteraction binaryInteraction, int index) throws XmlConversionException { psidev.psi.mi.tab.model.Interactor mitabInteractor = binaryInteraction.getInteractorB(); return buildParticipant(xmlInteractor, mitabInteractor); }
public NullCrossReference(BinaryInteraction binaryInteraction) { this.identifier = binaryInteraction.getInteractorA().getIdentifiers().iterator().next() +"_"+binaryInteraction.getInteractorB().getIdentifiers().iterator().next(); }
/** * Alters the order of interactorA and interactorB of a binary interaction, according to a comparator. * @param binaryInteraction the binary interaction * @param comparator the comparator to use */ public static void reorderInteractors(BinaryInteraction binaryInteraction, Comparator<Interactor> comparator) { if (binaryInteraction == null) throw new NullPointerException("binaryInteraction is null"); if (comparator == null) throw new NullPointerException("comparator is null"); Interactor interactorA = binaryInteraction.getInteractorA(); Interactor interactorB = binaryInteraction.getInteractorB(); if (comparator.compare(interactorA, interactorB) < 0) { binaryInteraction.setInteractorA(interactorB); binaryInteraction.setInteractorB(interactorA); } } }
private Boolean isIntraMolecular(BinaryInteraction<?> binaryInteraction) { Interactor A = binaryInteraction.getInteractorA(); Interactor B = binaryInteraction.getInteractorB(); if ((A == null && B != null && !B.isEmpty())) { //We have only one participant in mitab so we don't need to check the stoichiometry. return true; } else if (B == null && A != null && !A.isEmpty()) { return true; } return false; }
private void invertInteractors(BinaryInteraction binaryInteraction) { Interactor a = binaryInteraction.getInteractorA(); Interactor b = binaryInteraction.getInteractorB(); binaryInteraction.setInteractorA(b); binaryInteraction.setInteractorB(a); }
@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; }
@Override public BinaryInteraction process(BinaryInteraction item) throws Exception { if (item == null){ return null; } Interactor interactorA = item.getInteractorA(); Interactor interactorB = item.getInteractorB(); String firstInteractor = extractInteractorIdentifier(interactorA); String secondInteractor = extractInteractorIdentifier(interactorB); if (firstInteractor == null){ firstInteractor = secondInteractor; } else if (secondInteractor == null){ secondInteractor = firstInteractor; } BinaryPair currentPair = new BinaryPair(firstInteractor, secondInteractor); if (scores.containsKey(currentPair)){ Double score = scores.get(currentPair); Confidence conf = new ConfidenceImpl(miScoreLabel, scoreFormatter.format(score)); item.getConfidenceValues().add(conf); } return item; }
@Override public boolean canExportBinaryInteraction(BinaryInteraction interaction, ExportContext context) throws UniprotExportException { double score = FilterUtils.getMiClusterScoreFor(interaction); if (score >= positive_export_threshold){ Set<String> intactInteractions = new HashSet<String>(); intactInteractions.addAll(FilterUtils.extractIntactAcFrom(interaction.getInteractionAcs())); if (intactInteractions.isEmpty()){ throw new UniprotExportException("The interaction :" + interaction.getInteractorA().toString() + "-" + interaction.getInteractorB().toString() +" doesn't have any references to IntAct."); } for (String ac : intactInteractions){ if (!context.getSpokeExpandedInteractions().contains(ac)){ String type = context.getInteractionToMethod_type().get(ac).getType(); if (!type.equals(COLOCALIZATION)){ logger.info("The negative interaction " + ac + " passed the export rules with score = " + score); return true; } } } } return false; }
public T merge(T bi1, T bi2) { T merged = cloneBinaryInteraction(bi1); merged.setInteractorA(mergeInteractorA(bi1.getInteractorA(), bi2.getInteractorA())); merged.setInteractorB(mergeInteractorB(bi1.getInteractorB(), bi2.getInteractorB())); populateBinaryInteraction(bi2, merged); return merged; }
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); } } }
private Reaction createAssembly(BinaryInteraction binaryInteraction) { Reaction assembly = new Reaction(Reaction.ReactionType.ASSEMBLY); // Common properties setInteractionCommonProperties(binaryInteraction, assembly); // name assembly.setName("assembly_" + assembly.getId()); // reactants String idA = binaryInteraction.getInteractorA().getIdentifiers().get(0).getIdentifier(); String idB = binaryInteraction.getInteractorB().getIdentifiers().get(0).getIdentifier(); assembly.getReactants().add(idA); assembly.getReactants().add(idB); // product String productId = idA + "_" + idB; assembly.getProducts().add(productId); // adding product to participants assembly.getParticipants().add(productId); // 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()); assembly.getStoichiometry().add(stoichiometryA); Map stoichiometryB = new HashMap<String, Object>(); stoichiometryB.put("component", binaryInteraction.getInteractorB().getIdentifiers().get(0).getIdentifier()); stoichiometryB.put("coefficient", binaryInteraction.getInteractorB().getStoichiometry()); assembly.getStoichiometry().add(stoichiometryB); } return assembly; }
throw new UniprotExportException("The interaction :" + interaction.getInteractorA().toString() + "-" + interaction.getInteractorB().toString() +" doesn't have any references to IntAct.");
@Override public void enrich(BinaryInteraction binaryInteraction) throws Exception { // enrich interactors enrich(binaryInteraction.getInteractorA()); enrich(binaryInteraction.getInteractorB()); // enrich xrefs of interaction enrich(binaryInteraction.getXrefs()); }
public T cloneBinaryInteraction(T interaction) { T clone = newBinaryInteraction(cloneInteractor(interaction.getInteractorA()), cloneInteractor(interaction.getInteractorB())); populateBinaryInteraction(interaction, clone); return clone; }
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (clusteredMitabFile == null){ throw new ItemStreamException("The Mitab cluster score item processor needs a clustered mitab file containing the scores to be able to process the non clustered MITAB file"); } PsimiTabReader mitabReader = new PsimiTabReader(); try { Iterator<BinaryInteraction> binaryInteractionIterator = mitabReader.iterate(clusteredMitabFile); while (binaryInteractionIterator.hasNext()){ BinaryInteraction binary = binaryInteractionIterator.next(); Interactor interactorA = binary.getInteractorA(); Interactor interactorB = binary.getInteractorB(); List<Confidence> confidences = binary.getConfidenceValues(); String firstInteractor = extractInteractorIdentifier(interactorA); String secondInteractor = extractInteractorIdentifier(interactorB); Double score = extractClusterScoreFrom(confidences); if (score != null){ scores.put(new BinaryPair(firstInteractor, secondInteractor), score); } } } catch (IOException e) { throw new ItemStreamException("Impossible to read the clustered mitab file " + clusteredMitabFile.getAbsolutePath(), e); } }
public void processParticipantDetectionMethod(Experiment exp, BinaryInteraction binary){ // process participant detection method if (exp != null && exp.getCvIdentification() != null){ CrossReference detMethod = cvObjectConverter.toCrossReference(exp.getCvIdentification()); Interactor interactorA = binary.getInteractorA(); Interactor interactorB = binary.getInteractorB(); processParticipantDetectionMethodFor(interactorA, detMethod); processParticipantDetectionMethodFor(interactorB, detMethod); } }
public BinaryInteraction process(BinaryInteraction item) throws Exception { if (enricher == null) { if (ontologiesSolrUrl == null) { throw new ItemStreamException("ontologiesSolrUrl is null"); } HttpSolrServer ontologiesSolrServer = createSolrServer(); OntologySearcher ontologySearcher = new OntologySearcher(ontologiesSolrServer); enricher = new OntologyCrossReferenceEnricher(ontologySearcher); } if (!processOnlyInteractors){ enricher.enrich(item); } else { if (item.getInteractorA() != null){ enricher.enrich(item.getInteractorA()); } if (item.getInteractorB() != null){ enricher.enrich(item.getInteractorB()); } } return item; }
private void copyPublicationAndExperimentDetailsTo(BinaryInteraction binary, boolean isFirst, Experiment exp){ if (binary != null && this.binaryTemplate != null){ // we override all the shared collections of the expanded binary interactions excepted annotations (can come from publication and interactions) // experiment details binary.setDetectionMethods(binaryTemplate.getDetectionMethods()); binary.setHostOrganism(binaryTemplate.getHostOrganism()); if (binary.getInteractorA() != null && binary.getInteractorA().getParticipantIdentificationMethods().isEmpty()){ experimentConverter.addParticipantDetectionMethodForInteractor(exp, binary.getInteractorA()); } if (binary.getInteractorB() != null && binary.getInteractorB().getParticipantIdentificationMethods().isEmpty()){ experimentConverter.addParticipantDetectionMethodForInteractor(exp, binary.getInteractorB()); } // publication details binary.setPublications(binaryTemplate.getPublications()); binary.setAuthors(binaryTemplate.getAuthors()); binary.setSourceDatabases(binaryTemplate.getSourceDatabases()); binary.setCreationDate(binaryTemplate.getCreationDate()); // we don't need to update all the interactions as they all share the same annotation collection if (isFirst){ binary.getAnnotations().addAll(binaryTemplate.getAnnotations()); } } }
public void enrich(BinaryInteraction binaryInteraction) throws Exception { enrich(binaryInteraction.getInteractorA()); enrich(binaryInteraction.getInteractorB()); enrich(binaryInteraction.getInteractionTypes()); enrich(binaryInteraction.getDetectionMethods()); if (binaryInteraction instanceof IntactBinaryInteraction) { IntactBinaryInteraction ibi = (IntactBinaryInteraction) binaryInteraction; enrich(ibi.getHostOrganism()); } }
public void enrich(BinaryInteraction binaryInteraction) throws Exception { // enrich interactors enrich(binaryInteraction.getInteractorA()); enrich(binaryInteraction.getInteractorB()); // enrich cvs of interaction enrich(binaryInteraction.getDetectionMethods()); enrich(binaryInteraction.getInteractionTypes()); enrich(binaryInteraction.getSourceDatabases()); enrich(binaryInteraction.getComplexExpansion()); // enrich xrefs of interaction enrich(binaryInteraction.getXrefs()); // enrich organism of interaction if (binaryInteraction.getHostOrganism() != null){ enrich(binaryInteraction.getHostOrganism().getIdentifiers()); } }