001package org.biopax.paxtools.pattern.constraint; 002 003import org.biopax.paxtools.pattern.Match; 004import org.biopax.paxtools.model.BioPAXElement; 005import org.biopax.paxtools.model.level3.Conversion; 006import org.biopax.paxtools.model.level3.PhysicalEntity; 007 008import java.util.Collection; 009import java.util.Collections; 010import java.util.HashSet; 011 012/** 013 * Given Conversion and its one of the participants (at the left or right), traverses to the other 014 * participants that are at the other side. 015 * 016 * var0 is a PE (PE1) 017 * var1 is a Conv 018 * var2 is a PE (PE2) 019 * 020 * Prerequisite: PE1 is either at left or right of Conv 021 * 022 * @deprecated 023 * @see org.biopax.paxtools.pattern.constraint.ConversionSide 024 * 025 * @author Ozgun Babur 026 */ 027public class OtherSide extends ConstraintAdapter 028{ 029 /** 030 * Constructor. 031 */ 032 public OtherSide() 033 { 034 super(3); 035 } 036 037 /** 038 * This is a generative constraint. 039 * @return true 040 */ 041 @Override 042 public boolean canGenerate() 043 { 044 return true; 045 } 046 047 /** 048 * Checks which side is the first PhysicalEntity, and gathers participants on the other side. 049 * @param match current pattern match 050 * @param ind mapped indices 051 * @return participants at the other side 052 */ 053 @Override 054 public Collection<BioPAXElement> generate(Match match, int... ind) 055 { 056 assertIndLength(ind); 057 058 PhysicalEntity pe1 = (PhysicalEntity) match.get(ind[0]); 059 Conversion conv = (Conversion) match.get(ind[1]); 060 061 if (conv.getLeft().contains(pe1)) 062 { 063 return new HashSet<BioPAXElement>(conv.getRight()); 064 } 065 else if (conv.getRight().contains(pe1)) 066 { 067 return new HashSet<BioPAXElement>(conv.getLeft()); 068 } 069 return Collections.emptySet(); 070 } 071}