Ejemplo n.º 1
0
 //This works
 void VisualiseMultiDigest(int multiDigestIndex)
 {
     for (int i = 0; i < multiDigests[multiDigestIndex].digestCutPositions.Length; i++)
     {
         visualisation.CreateLine(((float)multiDigests[multiDigestIndex].digestCutPositions[i].position / genomeSize) * 360, enzymes[multiDigests[multiDigestIndex].digestCutPositions[i].enzymeIndexID].name + " " + multiDigests[multiDigestIndex].digestCutPositions[i].position, Color.red);
     }
 }
Ejemplo n.º 2
0
    void Start()
    {
        genomeSize = 400;
        //Enzymes
        int digestNumber = 0;

        enzymes = new Enzyme[3];
        enzymes[digestNumber].name              = "HindIII";
        enzymes[digestNumber].indexID           = 0;
        enzymes[digestNumber].numberOfFragments = 2;
        enzymes[digestNumber].fragmentSizes     = new int[2] {
            382, 18
        };
        enzymes[digestNumber].cutPositions         = CreateCutPositions(enzymes[digestNumber].fragmentSizes);
        enzymes[digestNumber].originalCutPositions = new int[enzymes[digestNumber].cutPositions.Length];
        enzymes[digestNumber].cutPositions.CopyTo(enzymes[digestNumber].originalCutPositions, 0);

        digestNumber = 1;
        enzymes[digestNumber].name              = "BamHI";
        enzymes[digestNumber].indexID           = 1;
        enzymes[digestNumber].numberOfFragments = 2;
        enzymes[digestNumber].fragmentSizes     = new int[2] {
            235, 165
        };
        enzymes[digestNumber].cutPositions         = CreateCutPositions(enzymes[digestNumber].fragmentSizes);
        enzymes[digestNumber].originalCutPositions = new int[enzymes[digestNumber].cutPositions.Length];
        enzymes[digestNumber].cutPositions.CopyTo(enzymes[digestNumber].originalCutPositions, 0);

        digestNumber = 2;
        enzymes[digestNumber].name              = "EcoRI";
        enzymes[digestNumber].indexID           = 2;
        enzymes[digestNumber].numberOfFragments = 2;
        enzymes[digestNumber].fragmentSizes     = new int[2] {
            300, 100
        };
        enzymes[digestNumber].cutPositions         = CreateCutPositions(enzymes[digestNumber].fragmentSizes);
        enzymes[digestNumber].originalCutPositions = new int[enzymes[digestNumber].cutPositions.Length];
        enzymes[digestNumber].cutPositions.CopyTo(enzymes[digestNumber].originalCutPositions, 0);


        //MultiDigests
        digestNumber = 0;
        multiDigests = new Digest[3];
        multiDigests[digestNumber].name = "HindIII & BamHI";
        multiDigests[digestNumber].numberOfFragments = 4;
        multiDigests[digestNumber].fragmentSizes     = new int[4] {
            235, 120, 27, 18
        };
        multiDigests[digestNumber].enzymesInDigest = new int[2] {
            0, 1
        };
        multiDigests[digestNumber].digestCutPositions = new CutPosition[multiDigests[digestNumber].numberOfFragments];

        digestNumber = 1;
        multiDigests[digestNumber].name = "HindIII & EcoRI";
        multiDigests[digestNumber].numberOfFragments = 4;
        multiDigests[digestNumber].fragmentSizes     = new int[4] {
            187, 100, 95, 18
        };
        multiDigests[digestNumber].enzymesInDigest = new int[2] {
            0, 2
        };
        multiDigests[digestNumber].digestCutPositions = new CutPosition[multiDigests[digestNumber].numberOfFragments];

        digestNumber = 2;
        multiDigests[digestNumber].name = "BamHI & EcoRI";
        multiDigests[digestNumber].numberOfFragments = 4;
        multiDigests[digestNumber].fragmentSizes     = new int[4] {
            160, 140, 75, 25
        };
        multiDigests[digestNumber].enzymesInDigest = new int[2] {
            1, 2
        };
        multiDigests[digestNumber].digestCutPositions = new CutPosition[multiDigests[digestNumber].numberOfFragments];

        genomeSize = CalculateGenomeSize(enzymes[0].fragmentSizes);

        //Complete all multidigests
        #region Instructions
        for (int i = 0; i < multiDigests.Length; i++)
        {
            bool isSuccessful  = false;
            int  attemptNumber = 1;
            if (MultiDigestCutPositionsFromSingleDigests(i))
            {
                isSuccessful = true;
                attemptNumber++;
            }
            else
            {
                FlipEnzymeCutPositions(enzymes[multiDigests[i].enzymesInDigest[1]].cutPositions).CopyTo(enzymes[multiDigests[i].enzymesInDigest[1]].cutPositions, 0);
                ResetCutPositions(multiDigests[i].enzymesInDigest[0]);
                if (MultiDigestCutPositionsFromSingleDigests(i))
                {
                    isSuccessful = true;
                    attemptNumber++;
                }
            }

            if (isSuccessful)
            {
                //Debug.Log("Success " + i + " Attempt " + attemptNumber);
                for (int x = 0; x < multiDigests[i].enzymesInDigest.Length; x++)
                {
                    PrintArray(enzymes[multiDigests[i].enzymesInDigest[x]].name + ": ", enzymes[multiDigests[i].enzymesInDigest[x]].cutPositions);
                }
            }
            else
            {
                //Debug.Log("multidigest " + i + " Failed");
            }
        }
        #endregion



        AlignDigestsBasedOnCommonEnzymes(1, 0);
        AlignDigestsBasedOnCommonEnzymes(2, 1);
        FlipMultiDigestCutPositions(2);
        AlignDigestsBasedOnCommonEnzymes(2, 0);
        FlipMultiDigestCutPositions(1);
        AlignDigestsBasedOnCommonEnzymes(1, 0);

        PrintCutPositionArray("MultiDigest 0: ", multiDigests[0].digestCutPositions);
        PrintCutPositionArray("MultiDigest 1: ", multiDigests[1].digestCutPositions);
        PrintCutPositionArray("MultiDigest 2: ", multiDigests[2].digestCutPositions);

        LoadFinalCutPositonsForEnzymes();

        PrintArray(enzymes[0].name + " CutPositions: ", enzymes[0].cutPositions);
        PrintArray(enzymes[1].name + " CutPositions: ", enzymes[1].cutPositions);
        PrintArray(enzymes[2].name + " CutPositions: ", enzymes[2].cutPositions);

        //VisualiseMultiDigest(0);


        if (CheckAllMultiDigests())
        {
            Debug.Log("F*****G DONE IT SON.");
        }
        else
        {
            Debug.Log("haha, you thought you were done");
        }

        for (int i = 0; i < enzymes.Length; i++)
        {
            for (int x = 0; x < enzymes[i].cutPositions.Length; x++)
            {
                visualisation.CreateLine(((float)enzymes[i].cutPositions[x] / genomeSize) * 360, enzymes[i].name, Color.red);
            }
        }
    }