Esempio n. 1
0
    public NucleotideCouple buildHalfCoupleChainFromOneSingle(Nucleotide chain)
    {
        if (chain.isPaired)
        {
            return(null);
        }

        chain = getHeadOfSingleChain(chain);
        Nucleotide nhead = chain;

        NucleotideCouple n    = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
        NucleotideCouple head = n;

        n.setLeftColor(chain.getColor());
        n.setType(chain.type, Nucleotide.Type.Empty);
        n.needHelix = false;
        while (chain.next)
        {
            chain  = chain.next;
            n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
            n.next.setLeftColor(chain.getColor());
            n.next.setType(chain.type, Nucleotide.Type.Empty);
            n.next.prev               = n;
            n.next.needHelix          = false;
            n.next.transform.rotation = nhead.transform.rotation;
            n = n.next;
        }
        head.transform.rotation = nhead.transform.rotation;
        head.transform.position = nhead.transform.position;
        head.broadcastUpdateTransform();
        destroySingleChain(chain);
        return(head);
    }
Esempio n. 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "NucleotideCouple")
     {
         Debug.Log("duplicate");
         NucleotideCouple chain = other.gameObject.GetComponent <NucleotideCouple>();
         NucleotideDirector.getInstance().duplicateCoupleChain(chain);
     }
 }
Esempio n. 3
0
    public void helixCoupleChain(NucleotideCouple chain)
    {
        NucleotideCouple n = getHeadOfCoupleChain(chain);

        while (n)
        {
            n.needHelix = true;
            n           = n.next;
        }
    }
Esempio n. 4
0
    public void duplicateCoupleChain(NucleotideCouple chain)
    {
        if (duplicating)
        {
            return;
        }
        duplicating = true;
        NucleotideCouple head = getHeadOfCoupleChain(chain);

        StartCoroutine(duplicateCoupleChainRoutine(head));
    }
Esempio n. 5
0
    public NucleotideCouple getHeadOfCoupleChain(NucleotideCouple n)
    {
        NucleotideCouple head = n;

        while (head.prev)
        {
            head = head.prev;
        }

        return(head);
    }
Esempio n. 6
0
 public IEnumerator fillHalfCoupleChainRoutine(NucleotideCouple head, float timeGap = 0.1F)
 {
     while (head)
     {
         head.setType(head.nucleotide1.type, getPairType(head.nucleotide1.type));
         head.setRightColor(Color.white);
         head.needHelix = true;
         head           = head.next;
         yield return(new WaitForSeconds(timeGap));
     }
 }
Esempio n. 7
0
    public NucleotideCouple buildCoupleChainFromOneSingleAnimation(Nucleotide chain, float timeGap = 0.8F)
    {
        NucleotideCouple head = buildHalfCoupleChainFromOneSingle(chain);

        if (head == null)
        {
            return(null);
        }
        StartCoroutine(fillHalfCoupleChainRoutine(head, timeGap));
        return(head);
    }
Esempio n. 8
0
    public string CoupleChain2String(NucleotideCouple chain)
    {
        NucleotideCouple n      = getHeadOfCoupleChain(chain);
        string           result = "2";

        while (n)
        {
            result += Type2Char(n.getLeftType()) + Type2Char(n.getRightType());
            n       = n.next;
        }
        return(result);
    }
Esempio n. 9
0
    public void destroyCoupleChain(NucleotideCouple chain)
    {
        NucleotideCouple prev, head = getHeadOfCoupleChain(chain);

        while (head)
        {
            prev = head;
            head = head.next;
            Destroy(prev.gameObject);
        }
        Debug.Log("Destroyed");
    }
Esempio n. 10
0
    public List <Nucleotide> buildSingleChainsFromCouple(NucleotideCouple head)
    {
        Nucleotide       leftHead, left, rightTail, right;
        NucleotideCouple curr = head;

        leftHead  = left = (Instantiate(singlePrefab) as GameObject).GetComponent <Nucleotide>();
        rightTail = right = (Instantiate(singlePrefab) as GameObject).GetComponent <Nucleotide>();
        left.setType(curr.getLeftType());
        left.setColor(curr.getLeftColor());
        right.setType(curr.getRightType());
        right.setColor(curr.getRightColor());

        leftHead.transform.rotation  = curr.nucleotide1.transform.rotation;
        leftHead.transform.position  = curr.nucleotide1.transform.position + leftHead.transform.rotation * Vector3.left * 2.0F;
        rightTail.transform.rotation = curr.nucleotide2.transform.rotation;
        rightTail.transform.position = curr.nucleotide2.transform.position + rightTail.transform.rotation * Vector3.left * 2.0F;

        curr = curr.next;
        while (curr)
        {
            Nucleotide leftPrev, rightPrev;
            leftPrev      = left;
            left          = (Instantiate(singlePrefab) as GameObject).GetComponent <Nucleotide>();
            leftPrev.next = left;
            left.prev     = leftPrev;
            left.setType(curr.getLeftType());
            left.setColor(curr.getLeftColor());

            rightPrev      = right;
            right          = (Instantiate(singlePrefab) as GameObject).GetComponent <Nucleotide>();
            right.next     = rightPrev;
            rightPrev.prev = right;
            right.setType(curr.getRightType());
            right.setColor(curr.getRightColor());

            curr = curr.next;

            /*if (head)
             *      Destroy(head.prev);*/
        }
        leftHead.broadcastUpdateTransform();
        rightTail.broadcastUpdateTransform();

        destroyCoupleChain(head);

        List <Nucleotide> result = new List <Nucleotide>();

        result.Add(leftHead);
        result.Add(rightTail);
        return(result);
    }
Esempio n. 11
0
    public void deHelix()
    {
        NucleotideCouple pre = prev;
        NucleotideCouple nex = next;

        while (pre != null)
        {
            pre.needHelix = false;
            pre           = pre.prev;
        }
        while (nex != null)
        {
            nex.needHelix = false;
            nex           = nex.next;
        }
    }
Esempio n. 12
0
    public NucleotideCouple buildCoupleChainFromTwoSingles(Nucleotide c1, Nucleotide c2, Vector3 position = default(Vector3))
    {
        if (c1.isPaired || c2.isPaired)
        {
            return(null);
        }

        if (getLengthOfSingleChain(c1) != getLengthOfSingleChain(c2))
        {
            return(null);
        }

        c1 = getHeadOfSingleChain(c1);
        if (c1 == getHeadOfSingleChain(c2))
        {
            return(null);
        }

        c2 = getTailOfSingleChain(c2);

        NucleotideCouple n    = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
        NucleotideCouple head = n;

        n.setLeftColor(c1.getColor());
        n.setRightColor(c2.getColor());
        n.setType(c1.type, c2.type);
        while (c1.next)
        {
            c1     = c1.next;
            c2     = c2.prev;
            n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
            n.next.setLeftColor(c1.getColor());
            n.next.setRightColor(c2.getColor());
            n.next.setType(c1.type, c2.type);
            n.next.prev = n;
            n           = n.next;
        }
        head.transform.position = position;
        head.broadcastUpdateTransform();
        destroySingleChain(c1);
        destroySingleChain(c2);
        return(n);
    }
Esempio n. 13
0
    //核苷酸之间氢键角度不知道怎么归位,deHelix先注释掉了
    //public void deHelix(NucleotideCouple n)
    //{
    //    if(n.needHelix == true)
    //    {
    //        n.needHelix = false;
    //    }
    //}

    public NucleotideCouple buildCoupleChainFromOneSingle(Nucleotide n, bool reverse = false)
    {
        if (n.isPaired)
        {
            return(null);
        }

        Nucleotide head = getHeadOfSingleChain(n);
        Nucleotide next = head.next;

        if (next == null)
        {
            return(buildCoupleFromOneSingle(head));
        }
        else
        {
            NucleotideCouple coupleHead = buildCoupleFromOneSingle(head);
            NucleotideCouple couple     = coupleHead;

            while (next.next)
            {
                next             = next.next;
                couple.next      = buildCoupleFromOneSingle(next.prev, reverse);
                couple.next.prev = couple;

                couple = couple.next;
            }
            couple.next = buildCoupleFromOneSingle(next);

            couple.next.prev = couple;
            if (!reverse)
            {
                coupleHead.broadcastUpdateTransform();
            }
            else
            {
                couple.next.broadcastUpdateTransform();
            }
            return(coupleHead);
        }
    }
Esempio n. 14
0
    public void updateTransform(Vector3 position, Quaternion rotation, NucleotideCouple from, bool updateRotation = false)
    {
        this.transform.position = position;
        if (updateRotation)
        {
            this.transform.rotation = rotation;
        }

        if (prev && from != prev)
        {
            Quaternion prevRotation = rotation;
            Vector3    prevPosition = position + rotation * Vector3.up * gap;
            prev.updateTransform(prevPosition, prevRotation, this, updateRotation);
        }
        if (next && from != next)
        {
            Quaternion nextRotation = rotation;
            Vector3    nextPosition = position + rotation * Vector3.down * gap;
            next.updateTransform(nextPosition, nextRotation, this, updateRotation);
        }
    }
Esempio n. 15
0
    public NucleotideCouple String2CoupleChain(string s, Vector3 position = default(Vector3))
    {
        if (s[0] != '2')
        {
            return(null);
        }

        NucleotideCouple n    = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
        NucleotideCouple head = n;

        n.setType(Char2Type(s[1]), Char2Type(s[2]));
        for (int i = 3; i < s.Length; i += 2)
        {
            n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
            n.next.setType(Char2Type(s[i]), Char2Type(s[i + 1]));
            n.next.prev = n;
            n           = n.next;
        }
        head.transform.position = position;
        head.broadcastUpdateTransform();
        return(n);
    }
Esempio n. 16
0
    IEnumerator duplicateCoupleChainRoutine(NucleotideCouple head)
    {
        Debug.Log("DeHelix");
        deHelixCoupleChain(head);
        yield return(new WaitForSeconds(5));

        Debug.Log("Build Single Chain");
        List <Nucleotide> singles = buildSingleChainsFromCouple(head);

        yield return(new WaitForSeconds(5));

        NucleotideCouple c1 = buildCoupleChainFromOneSingleAnimation(singles[0]);
        NucleotideCouple c2 = buildCoupleChainFromOneSingleAnimation(singles[1]);

        deHelixCoupleChain(c1);
        deHelixCoupleChain(c2);
        yield return(new WaitForSeconds(2));

        helixCoupleChain(c1);
        helixCoupleChain(c2);
        duplicating = false;
    }