// construtor public boundReceptorPair(Receptor3 irecA, Receptor3 irecB) { recA = irecA; recB = irecB; // binding receptors recA.bound = true; recB.bound = true; // Report binding to cell output values /*recA.cell.outputValues.reportBinding(recA.receptorId, recA.recPosition - recA.cell.transform.position); * recB.cell.outputValues.reportBinding(recB.receptorId, recB.recPosition - recB.cell.transform.position); */ // if both cells visible, display a line between them. if (bothRecsVisible()) { lineObject = GameObject.Instantiate(Resources.Load("LineBetweenReceptors", typeof(LineRenderer))) as LineRenderer; // Draw the line itself lineObject.SetPosition(0, recA.recPosition); lineObject.SetPosition(1, recB.recPosition); lineObject.SetWidth(0.01f, 0.01f); //Debug.Log ("//// BOUND visual receptors: cell: " + recA.cell.gameObject.name + " rec id: " + recA.receptorId + " position: " + recA.recPosition + " , cell: " + recB.cell.gameObject.name + " rec id: " + recB.receptorId + " position: " + recB.recPosition); } /* haloA = (Behaviour)recA.GetComponent("Halo"); * haloB = (Behaviour)recB.GetComponent("Halo"); * haloA.enabled = true; * haloB.enabled = true; * * particleA = recA.GetComponent<ParticleSystem>(); * particleB = recB.GetComponent<ParticleSystem>();*/ }
// Update is called once per frame void FixedUpdate() { allCellsReady(); // CANCELING THE TIME EFFECT - EXP SHOULD RUN AS FAST AS IT CAN //elapsedTime = Time.time - latestBioTickTime; // Rounding biotick time to prevent problems with running in wrong times ? if (Mathf.Abs(elapsedTime - timeStepsInSeconds) < 1E-06) { elapsedTime = timeStepsInSeconds; } // Are we ready for the next timestep (in bioticks) if ((biotick > -1) && (biotick < steps)) //&& (elapsedTime >= timeStepsInSeconds) { Profiler.BeginSample("update interaction radius"); // Moving the cell output biotick initalization to here, for now... (because a new biotick is first run here, and we may need to add values to the output arrays, so we have to initalize them here). /*cell1.outputValues.updateBiotick(biotick); * cell2.outputValues.updateBiotick(biotick);*/ // update receptors within interaction radius for both interacting cells: cellInteraction.updateReceptorsInInteractionRadius(); Profiler.EndSample(); Profiler.BeginSample("binding"); /*Debug.Log("num of cell in int area A " + cellInteraction.cellA_receptorsInInteractionRadius_listLength); * Debug.Log("aera B " + cellInteraction.cellB_receptorsInInteractionRadius_listLength);*/ for (int j = 0; j < cellInteraction.cellA_receptorsInInteractionRadius_listLength; j++) { recA = cellInteraction.cellA_receptorsInInteractionRadius[j]; if (!recA.bound) // receptor can bind only if not currently bound { for (int k = 0; k < cellInteraction.cellB_receptorsInInteractionRadius_listLength; k++) { recB = cellInteraction.cellB_receptorsInInteractionRadius[k]; if (!recB.bound) // receptor can bind only if not currently bound { if (rand.NextDouble() <= bindingProbability) // What's the probability for binding? // only perform check if we passed the probabily check, which is cheaper computationally. { if (closeEnough(recA.recPosition, recB.recPosition)) { // receptors bound! boundReceptors.Add(new boundReceptorPair(recA, recB)); // After binding two receptors, we of course have to break, so that rec A wouldn't bind any other receptors (we've already passed the "is it bound" check, so it's a risk) break; } } } } } } Profiler.EndSample(); Profiler.BeginSample("removing bound receptors"); // running all receptor pairs - should they release signal, should they unbind? Doing this first so to not bind and then instantly unbind a receptor pair. for (int i = 0; i < boundReceptors.Count; i++) { // if returned true, remove from bound receptors list. if (boundReceptors[i].runReceptorsForBiotick(this, rand)) { // Using i-- after removing an element from the list, all the other elements go back by 1. Decrementing i will cause us to check the same index again (because it increments again in the for), which is actually the next memeber on the list. boundReceptors.RemoveAt(i--); } } Profiler.EndSample(); // reports before end of biotick //cell1.outputValues.reportReceptorAmount(cell1.receptors.Count); //cell2.outputValues.reportReceptorAmount(cell2.receptors.Count); biotick++; receptorNumbersText.text = "Delta receptors (visible): " + cell1.receptors.Count + " (" + cell1.receptorMeshVertices.Count() / 4 + ")" + "\nNotch receptors (visible): " + cell2.receptors.Count + " (" + cell2.receptorMeshVertices.Count() / 4 + ")"; totalSignalText.text = "Number of bound receptors: " + boundReceptors.Count + "\nTotal signal released: " + totalSignal; timeText.text = "" + Mathf.Floor(biotick * timeStepsInSeconds); //latestBioTickTime = Mathf.Floor(Time.time * 10)/10 ; latestBioTickTime = Time.time; //Debug.Log ("t: " + Time.time + " biotick: " + biotick); // + " Sim time: " + biotick/10.0 } else if (biotick == steps) { // REPORTS // After sim finished, save everything //float diffusionLengthScale = Utils.calcDiffusionLengthScale(diffusion_in_micrometers_squared_per_second, endocytosisRate); // endocytosis rate of both cells is equal! //// Save signal per biotick //cell1.outputValues.saveSignal(interactionRadius, diffusionLengthScale); //cell2.outputValues.saveSignal(interactionRadius, diffusionLengthScale); //// Save the number of receptors per each biotick //cell1.outputValues.saveReceptorAmounts(interactionRadius, diffusionLengthScale); //cell2.outputValues.saveReceptorAmounts(interactionRadius, diffusionLengthScale); //// Report AND save locations of all receptors in last biotick (steady state) for receptor profiles. //foreach (Receptor3 rec in cell1.receptors) { // cell1.outputValues.reportReceptorPositionInSS(rec.receptorId, rec.recPosition, rec.bound); //} // //cell1.outputValues.saveDistanceOfTypeFromInteractionPoint(interactionRadius, diffusionLengthScale); // //cell1.outputValues.saveForCovarianceCalculationsAtLastBiotick(cell1.randomSeedForReceptorMovement, diffusionLengthScale); //foreach (Receptor3 rec in cell2.receptors) { // cell2.outputValues.reportReceptorPositionInSS(rec.receptorId, rec.recPosition, rec.bound); //} // //cell2.outputValues.saveDistanceOfTypeFromInteractionPoint(interactionRadius, diffusionLengthScale); // //cell2.outputValues.saveForCovarianceCalculationsAtLastBiotick(cell2.randomSeedForReceptorMovement, diffusionLengthScale); // // Diffusion calculations - distance of all receptor in EACH BIOTICK (SUPER WASTEFUL) // DONT FORGET TO BRING BACK ALL POSITION REPORTING! / ALSO BRING BACK INIT IN cellOutputValues / COMMENT THIS WHEN NO DIFF CALCULATIONS // //cell1.outputValues.saveSquaredSDForDiffusionCalculations(cell1.randomSeedForReceptorMovement); // //cell1.outputValues.saveAverageForDiffusionCalculations(cell1.randomSeedForReceptorMovement); // //cell2.outputValues.saveSquaredSDForDiffusionCalculations(cell2.randomSeedForReceptorMovement); // //cell2.outputValues.saveAverageForDiffusionCalculations(cell2.randomSeedForReceptorMovement); // // FOR DLS calculations - Variance of distances from origin at last biotick // /*cell1.outputValues.saveForDiffusionCalculationsAtLastBiotick(cell1.randomSeedForReceptorMovement, diffusionLengthScale); //cell2.outputValues.saveForDiffusionCalculationsAtLastBiotick(cell2.randomSeedForReceptorMovement, diffusionLengthScale);*/ // int outerLoopLength = 0; //if (autoDiffusion) { // outerLoopLength = diffusionValues.Length; //} // else { // outerLoopLength = exoEndoRates.endocytosisRates.Length; //} //// Advancing the indices //if (valueCounterLS < outerLoopLength) { // if (valueCounterIR < interactionRadii.Length) { // resetExp(valueCounterLS, valueCounterIR); // valueCounterIR++; // } else { // valueCounterIR = 0; // valueCounterLS++; // if (valueCounterLS < outerLoopLength) { // resetExp(valueCounterLS, valueCounterIR); // valueCounterIR++; // } // } //} //Debug.Log("outer loop length: " + outerLoopLength); //// If we've gone through all the values //if (valueCounterLS == outerLoopLength) { // // Create diffusion length scale list: // foreach(float diffusion in diffusionValues) { // //foreach(float endoRate in exoEndoRates.endocytosisRates) { // diffusionLengthScales.Add (Utils.calcDiffusionLengthScale(diffusion, endocytosisRate)); // //diffusionLengthScales.Add (Utils.getDiffusionLengthScale(speed_in_micrometers_per_second, endoRate, timeStepsInSeconds)); // } // cell1.outputValues.saveDiffLengthScaleAndInteractionRadiiLists(interactionRadii, diffusionLengthScales.ToArray()); // // Move to the next biotick to stop operation // biotick++; //} } /* if (showInteractionRadius) { * for (int i=0; i<8; i++) { * // Setup vector * radiusVector = Math3d. * } * }*/ }