Exemple #1
0
    public static void ChangeSubtype(ObjectsOnDNA toChange, string newSub)
    {
        //toDelete.StartPosition has to be converted to nucleotide location
        float convertPos   = 0;
        float tempStartPos = 0;

        if (toChange.MainType == "'Nucleosome'")
        {
            tempStartPos = toChange.StartPosition + (toChange.Length / 4);
            convertPos   = (tempStartPos / 3.5f) - .6f;

            NucleosomeClass.ChangeNuc(toChange, newSub, convertPos);
        }
        else if (toChange.MainType == "'Transcription_Factor'")
        {
            tempStartPos = toChange.StartPosition + (toChange.Length / 3.5f);
            convertPos   = (tempStartPos / 3.5f) - .6f;
        }
        else if (toChange.MainType == "'Transcriptional_Machinery'")
        {
            tempStartPos = toChange.StartPosition + (toChange.Length / 3.5f);
            convertPos   = (tempStartPos / 3.5f) - .6f;

            TranscriptionalMachineryClass.ChangeTM(toChange, newSub, convertPos);
        }
    }
Exemple #2
0
    // TEMPORARY HANDLING OF ANIMATION
    public IEnumerator TempAni(List <InstructionObject> toAnimate)
    {
        foreach (InstructionObject joe in toAnimate)
        {
            if (joe.instruction == "NucleosomeClass.CreateNucleosome")
            {
                NucleosomeClass.CreateNucleosome(joe.TranscriptionSimObject);
            }
            else if (joe.instruction == "TranscriptionFactorClass.CreateTranscriptionFactor")
            {
                TranscriptionFactorClass.CreateTranscriptionFactor(joe.TranscriptionSimObject);
            }
            else if (joe.instruction == "TranscriptionalMachineryClass.CreateTranscriptionalMachinery")
            {
                TranscriptionalMachineryClass.CreateTranscriptionalMachinery(joe.TranscriptionSimObject);
            }

            if (joe.instruction == "ObjectsOnDNA.DeleteObject")
            {
                ObjectsOnDNA.DeleteObject(joe.TranscriptionSimObject);
            }

            if ((joe.instruction.Contains("0") || joe.instruction.Contains("1") || joe.instruction.Contains("2") ||
                 joe.instruction.Contains("3") || joe.instruction.Contains("4") || joe.instruction.Contains("5") ||
                 joe.instruction.Contains("6") || joe.instruction.Contains("7") || joe.instruction.Contains("8") ||
                 joe.instruction.Contains("9")) && !joe.instruction.Contains("Init"))
            {
                var xPos = Convert.ToSingle(joe.instruction);

                ObjectsOnDNA.MoveObject(joe.TranscriptionSimObject, xPos);
            }


            if (joe.instruction == "'Binding'" || joe.instruction == "'Unbinding'" || joe.instruction == "'Stable'")
            {
                ObjectsOnDNA.ChangeSubtype(joe.TranscriptionSimObject, joe.instruction);
            }
            else if (joe.instruction.Contains("Crick") || joe.instruction.Contains("Watson"))
            {
                ObjectsOnDNA.ChangeSubtype(joe.TranscriptionSimObject, joe.instruction);
            }

            if (joe.instruction == "WAIT")
            {
                ObjectsOnDNA.MakeWait(joe.TranscriptionSimObject);
            }
        }

        yield return(0);
    }
Exemple #3
0
    public static IEnumerator CreateObjectList(List <string> TimeStep, string whichTime)
    {
        var thisTime = new List <ObjectsOnDNA>();

        if (whichTime == "Current")
        {
            ObjectsInCurrentTime = new List <ObjectsOnDNA> ();
            thisTime             = ObjectsInCurrentTime;
        }
        else if (whichTime == "Future")
        {
            ObjectsInFutureTime = new List <ObjectsOnDNA> ();
            thisTime            = ObjectsInFutureTime;
        }
        else if (whichTime == "TwoAhead")
        {
            ObjectsTwoAhead = new List <ObjectsOnDNA> ();
            thisTime        = ObjectsTwoAhead;
        }
        else if (whichTime == "ThreeAhead")
        {
            ObjectsThreeAhead = new List <ObjectsOnDNA> ();
            thisTime          = ObjectsThreeAhead;
        }


        // Then Repopulate list for new timestep
        for (int i = 0; i < (TimeStep.Count); i += 4)
        {
            if (TimeStep [i] == "'Nucleosome'")
            {
                NucleosomeClass AwesomeNuc = new NucleosomeClass(TimeStep [i], TimeStep [i + 1], Convert.ToInt64(TimeStep [i + 2]), Convert.ToInt64(TimeStep [i + 3]));
                thisTime.Add(AwesomeNuc);
                yield return(thisTime);
            }
            else if (TimeStep [i] == "'Transcription_Factor'")
            {
                TranscriptionFactorClass AwesomeTF = new TranscriptionFactorClass(TimeStep[i], TimeStep [i + 1], Convert.ToInt64(TimeStep [i + 2]), Convert.ToInt64(TimeStep [i + 3]));
                thisTime.Add(AwesomeTF);
                yield return(thisTime);
            }
            else if (TimeStep [i] == "'Transcriptional_Machinery'")
            {
                TranscriptionalMachineryClass AwesomeTM = new TranscriptionalMachineryClass(TimeStep[i], TimeStep [i + 1], Convert.ToInt64(TimeStep [i + 2]), Convert.ToInt64(TimeStep [i + 3]));
                thisTime.Add(AwesomeTM);
                yield return(thisTime);
            }
        }
    }
Exemple #4
0
    public IEnumerator parseList(LinkedList <List <InstructionObject> > ll)
    {
        LinkedListNode <List <InstructionObject> > cursor;

        cursor = ll.First;


        while (cursor != null)
        {
//			yield return StartCoroutine_Auto (TimeStep.instance.JustWait ());

            foreach (InstructionObject current in cursor.Value)
            {
                int  x;
                bool isNumeric = int.TryParse(current.instruction, out x);
                Debug.Log("CHAAAAAAAAAAAAAAAAAAAD" + x);

                //Create TF
                if (current.instruction == "TranscriptionFactorClass.CreateTranscriptionFactor")
                {
                    yield return(TranscriptionFactorClass.CreateTranscriptionFactor(current.TranscriptionSimObject));
                }

                //Create Nucleosome
                if (current.instruction == "NucleosomeClass.CreateNucleosome")
                {
                    yield return(NucleosomeClass.CreateNucleosome(current.TranscriptionSimObject));
                }

                //Create TM
                if (current.instruction == "TranscriptionalMachineryClass.CreateTranscriptionalMachinery")
                {
                    yield return(TranscriptionalMachineryClass.CreateTranscriptionalMachinery(current.TranscriptionSimObject));
                }

                //Delete ObjectsOnDNA
                if (current.instruction == "ObjectsOnDNA.DeleteObject")
                {
                    Debug.Log("Here " + current.TranscriptionSimObject.MainType);
                    ObjectsOnDNA.DeleteObject(current.TranscriptionSimObject);
                    yield return(0);
                }

                //Move Handling
                else if (isNumeric)
                {
                    //Extract coordinates and place into xyz array


                    GameObject[] nucleosomes                = GameObject.FindGameObjectsWithTag("Nucleosome");
                    GameObject[] transcriptionFactors       = GameObject.FindGameObjectsWithTag("TranscriptionFactor");
                    GameObject[] transcriptionalMachineries = GameObject.FindGameObjectsWithTag("TranscriptionalMachinery");

                    float convertPos = (current.TranscriptionSimObject.StartPosition / 3.5f) - .6f;

                    //Nucleosome move handling
                    if (current.TranscriptionSimObject.MainType == "Nucleosome")
                    {
                        foreach (GameObject nuc in nucleosomes)
                        {
                            if (convertPos == nuc.transform.position.x)
                            {
                                Debug.Log("Nuc positions equal");

                                syncList.Add(new syncObj(nuc, x));
                                //iTween.MoveTo(nuc, iTween.Hash("x", x, "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                nuc.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                            else
                            {
                                Debug.Log("Nucleosomes not equal");
                                Debug.Log("ConvertPos = " + convertPos + " Current.start = " + current.TranscriptionSimObject.StartPosition + " Nuc.start = " + nuc.transform.position.x);
                            }
                        }
                    }

                    //Transcription Factor move handling
                    if (current.TranscriptionSimObject.MainType == "Transcription_Factor")
                    {
                        foreach (GameObject tf in transcriptionFactors)
                        {
                            if (convertPos == tf.transform.position.x)
                            {
                                Debug.Log("TF positions equal");

                                syncList.Add(new syncObj(tf, x));
                                //iTween.MoveTo(tf, iTween.Hash("x", xyz[0], "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                tf.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                        }
                    }

                    //Transcriptional Machinery move handling
                    if (current.TranscriptionSimObject.MainType == "Transcriptional_Machinery")
                    {
                        foreach (GameObject tm in transcriptionalMachineries)
                        {
                            if (convertPos == tm.transform.position.x)
                            {
                                Debug.Log("TM positions equal");

                                syncList.Add(new syncObj(tm, x));

                                //iTween.MoveTo(tm, iTween.Hash("x", convertPos, "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                tm.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                            else
                            {
                                Debug.Log("ConvertPos = " + convertPos + " Current.start = " + current.TranscriptionSimObject.StartPosition + " TM.start = " + tm.transform.position.x);
                            }
                        }
                    }
                }

                if (current.instruction == "JustWait")
                {
                    Debug.Log("KNOWS TO WAIT");
                    yield return(TimeStep.instance.JustWait());

                    Debug.Log("TRIED TO WAIT");
                }

                foreach (syncObj s in syncList)
                {
                    Debug.Log("obj shit" + s.gObj.name);
                    iTween.MoveTo(s.gObj, iTween.Hash("x", s.coord, "time", 5));
                    Debug.Log("Sync coords: " + s.coord);
                }
            }
            yield return(new WaitForSeconds(6));

            syncList.Clear();
            cursor = cursor.Next;
        }
    }