package affectors; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Vector; import main.Node; import main.Cell; import main.Globals; /** EnhancerRegion surrounds other enhancers and multiplies them by the scaling (characteristicTime / halfLife). This scaling needs to be used outside of all transcription terms once. When transcriptional terms are nested, as with Sum, Product, or MultiEnhancer, then they often can't include the scaling within the transcription term itself since it might be nested inside another term. So EnhancerRegion is used as an outside wrapper. EnhancerRegionAff will only wrap a single other affector, which will usually be either a MultiEnhancer or Product.

In some cases, you may not need to wrap other meta-affectors inside of this one. For instance, ProductAff can be used to multiply one of the standard transcription affectors times inhibitory terms. Since the standard transcription affectors already contain the proper scaling, that combination needs no further wrapping. For this all to become clear, you will probably need to work through the math yourself a bit, but as a rule of thumb, if you are using TxnSiteActivator or MultiEnhancer within your enhancer term, you need to wrap the whole term with an EnhancerRegion.

Note - this is also the base class for all other meta-affectors. If you make your own meta-affector, subclass it from EnhancerRegion.

Formula
dnodex/dt = (characteristicTime / H_nodex) * SubAffectorValue

Parameters
Half-life [H_nodex] The half-life of the target mRNA

Usage
&nodex

&EnhancerRegionAff nodex H_nodex
&MultiEnhancerAff
[in here are some other affectors]
&endMultiEnhancerAff
&endEnhancerRegionAff
&endnodex */ public class EnhancerRegionAff extends Affector { // This is an array so that subclasses can have more than one affector without all needing to // re-implement methods to deal with that. This class only uses affectors[0] Affector [] affectors = new Affector[3]; // Probably usually won't be more than 3 combined together ? int numAffectors = 0; int halfLifeParam; static final String desc = "Wraps other meta-affectors"; static final String [] paramDescriptions = {"Half-life"}; static final int [] whichSides = { -1 }; public EnhancerRegionAff() { } /** half life param */ protected void setLabelsAndTypes() { setDescriptions(this.desc, null, paramDescriptions); setSided(true, whichSides); this.Type[GUI_CAPABLE] = 0; this.Type[CERTIFICATION] = Affector.RETURNS_DERIV; this.Type[MATHTYPE] = Affector.FF; // ???? None really fit this.Type[TERMTYPE] = Affector.PRODUCTION; } public void setParameterNumbers(int [] param_nums) { halfLifeParam = param_nums[0]; } /** Overrides Affector.getValue() to return the value of the wrapped enhancer multiplied by the scaling characteristicTime / halfLife */ public float getValue(Node which_node) { float value = affectors[0].getValue(which_node); return (Globals.characteristicTime / params[halfLifeParam]) * value; } /** Overrides Affector.getNCValue() to return the value of the wrapped enhancer multiplied by the scaling characteristicTime / halfLife */ public float getNCValue(Node which_node) { if(containsTarget) { float value = affectors[0].getNCValue(which_node); return (Globals.characteristicTime / params[halfLifeParam]) * value; } else return super.getNCValue(which_node); } /** This function is used to add regular affectors to be used by the meta-affector. The EnhancerRegionAff only uses the first affector added, but other meta-affectors may be able to take more than one sub-affector. */ public void addAffector(Affector aff) { if(numAffectors == affectors.length) { Affector [] temp = new Affector[affectors.length + 3]; for(int i = 0; i < numAffectors; i++) temp[i] = affectors[i]; affectors = temp; } affectors[numAffectors] = aff; numAffectors++; if(aff.containsTarget) setContainsTarget(true); if(numAffectors == 1) affectorType = aff.affectorType; } public Affector getSubaffector(int num) { return affectors[num]; } /* The rest of these functions are overrides of Affector functions so that they work right for this class. */ public void setSide(int side) { int i; this.side = side; otherSide = getOtherSide(side); if(sides != null) { for(i = 0; i < sides.length; i++) if(sides[i] != -1) sides[i] = side; } for(i = 0; i < numAffectors; i++) affectors[i].setSide(side); } public Node [] getNodes() { int i, num_nodes = 0; for(i = 0; i < numAffectors; i++) num_nodes += affectors[i].getNodes().length; Node [] nodes = new Node[num_nodes]; num_nodes = 0; for(i = 0; i < numAffectors; i++) { Node [] temp = affectors[i].getNodes(); for(int j = 0; j < temp.length; j++) { nodes[num_nodes] = temp[j]; num_nodes++; } } return nodes; } public Affector copy() { EnhancerRegionAff element = null; try { element = (EnhancerRegionAff)this.clone(); } catch(CloneNotSupportedException e) { System.out.println("Error cloning EnhancerRegionAff: " + e.toString()); } element.affectors = new Affector[1]; element.affectors[0] = affectors[0].copy(); return element; } }