Example #1
0
        //
        public bool Detailed_checkObjList(List <Object> listObjs)
        {
            int ntelends = 0;

            foreach (Object o in listObjs)
            {
                foreach (Free_end fe in o.md.f_e)
                {
                    if (fe.FE_type == MetaData.FreeEndType.telomeric)
                    {
                        ntelends++;
                    }
                }
            }
            if (ntelends != IntactHumanGenome.nObjs * 2)
            {
                return(false);
            }

            foreach (Object o in listObjs)
            {
                if (o.Length <= 0)
                {
                    return(false);
                }
            }

            int itemp = 0;

            foreach (Object o in listObjs)
            {
                itemp += o.Length;
            }

            if (itemp != IntactHumanGenome.WholeGenome())
            {
                return(false);
            }

            foreach (Object o in listObjs)
            {
                if (o.md.f_e.Count < 2 && o.md.O_type != MetaData.ObjectType.ring)
                {
                    return(false);
                }
            }

            foreach (Object o in listObjs)
            {
                foreach (Band b in o.md.chromo_bands)
                {
                    if (b.Size == 0)
                    {
                        MessageBox.Show("Band Of 0-size. Do something!");
                    }
                }
            }

            return(true);
        }
Example #2
0
        public DSBs(string s)
        {
            Random random = new Random();

            for (int i = 0; i < 20; i++)
            {
                P = DSBcomplP[1];
                double   R           = 6.0;
                double   lattice_dim = 0.02;
                int      rnucleus    = Convert.ToInt32(R / lattice_dim);
                Location l;
                while (true)
                {
                    l.X = random.Next(0, 2 * rnucleus) - rnucleus;
                    l.Y = random.Next(0, 2 * rnucleus) - rnucleus;
                    l.Z = random.Next(0, 2 * rnucleus) - rnucleus;
                    double a = 1.0 / 2.0, b = 1.0 / 2.0, c = 4.0;                                                                                                          // nucleus parameters for elliptic nucleus // zzz GUI input
                    if (a * (l.X - rnucleus) * (l.X - rnucleus) + b * (l.Y - rnucleus) * (l.Y - rnucleus) + c * (l.Z - rnucleus) * (l.Z - rnucleus) < rnucleus * rnucleus) // elliptic nucleus
                    {
                        break;
                    }
                }
                DSBstruct random_DSB = new DSBstruct()
                {
                    ndsb        = i,
                    random_time = 0.0, //  SimpleRNG.GetUniform(), // hrs
                    position    = random.Next(0, IntactHumanGenome.WholeGenome()),
                    L           = l
                };
                listDSBs.Add(random_DSB);
            }
        }
Example #3
0
        //
        public bool CheckObjList(List <Object> listObjs)
        {
            int ntelends = 0;

            foreach (Object o in listObjs)
            {
                foreach (Free_end fe in o.md.f_e)
                {
                    if (fe.FE_type == MetaData.FreeEndType.telomeric)
                    {
                        ntelends++;
                    }
                }
            }
            if (ntelends != IntactHumanGenome.nObjs * 2)
            {
                return(false);
            }

            foreach (Object o in listObjs)
            {
                if (o.Length <= 0)
                {
                    return(false);
                }

                foreach (Band b in o.md.chromo_bands)
                {
                    if (b.Downstream_end_position >= b.Upstream_end_position)
                    {
                        return(false);
                    }
                }
            }
            int itemp = 0;

            foreach (Object o in listObjs)
            {
                itemp += o.Length;
            }

            if (itemp != IntactHumanGenome.WholeGenome())
            {
                return(false);
            }

            return(true);
        }
                public static void DoWork()
                {
                    RandomWalk rw        = new RandomWalk();
                    int        nmonomers = IntactHumanGenome.WholeGenome();

                    rw.LL       = new Location[nmonomers];
                    rw.nmonomer = new int[nmonomers];
                    Random random   = new Random();
                    int    rnucleus = Convert.ToInt32(R / lattice_dim);
                    int    j        = 0;

                    for (int chn = nThread * IntactHumanGenome.nObjs / nThreads; chn < (nThread + 1) * IntactHumanGenome.nObjs / nThreads; chn++)
                    {
                        while (true)
                        {
                            rw.LL[j].X = random.Next(0, 2 * rnucleus) - rnucleus; // RW random origin
                            rw.LL[j].Y = random.Next(0, 2 * rnucleus) - rnucleus;
                            rw.LL[j].Z = random.Next(0, 2 * rnucleus) - rnucleus;
                            if (InsideEllipsoid(rw.LL[j]))
                            {
                                break;
                            }
                        } // zzz666 these RWs don't have loops or domains yet
                        rw.nmonomer[j] = j;
                        j++;
                        for (int i = 0; i < Convert.ToInt32(IntactHumanGenome.NC[chn] / IntactHumanGenome.monomerSize) - 1; i++)
                        {
                            Location l_temp;
                            switch (random.Next(0, 3))
                            {
                            case 0:
                            {
                                l_temp.X = rw.LL[j - 1].X + (2 * random.Next(0, 2) - 1);
                                l_temp.Y = rw.LL[j - 1].Y;
                                l_temp.Z = rw.LL[j - 1].Z;
                                if (InsideEllipsoid(l_temp))
                                {
                                    rw.LL[j] = l_temp;
                                }
                            }
                            break;

                            case 1:
                            {
                                l_temp.X = rw.LL[j - 1].X;
                                l_temp.Y = rw.LL[j - 1].Y + (2 * random.Next(0, 2) - 1);
                                l_temp.Z = rw.LL[j - 1].Z;
                                if (InsideEllipsoid(l_temp))
                                {
                                    rw.LL[j] = l_temp;
                                }
                            }
                            break;

                            case 2:
                            {
                                l_temp.X = rw.LL[j - 1].X;
                                l_temp.Y = rw.LL[j - 1].Y;
                                l_temp.Z = rw.LL[j - 1].Z + (2 * random.Next(0, 2) - 1);
                                if (InsideEllipsoid(l_temp))
                                {
                                    rw.LL[j] = l_temp;
                                }
                            }
                            break;

                            default:
                                break;
                            }
                            rw.nmonomer[j] = j;
                            j++;
                        }
                    }
                    ApplyRad2RWs(rs, rw, DSBdata); // collect all sets of DSBs and put them into a list
                }
            //
            public bool PrepairDSBpositionsInGenome(RadiationSchema rs, DSBs DSBdata)
            {
                bool bParallel = false; // zzz666

                try
                {
                    RandomWalk rw        = new RandomWalk();
                    int        nmonomers = IntactHumanGenome.WholeGenome();
                    rw.LL       = new Location[nmonomers];
                    rw.nmonomer = new int[nmonomers];
                    Random random   = new Random();
                    int    rnucleus = Convert.ToInt32(R / lattice_dim);
                    int    j        = 0;
                    if (!bParallel)
                    {
                        for (int chn = 0; chn < IntactHumanGenome.nObjs; chn++) // zzz666 split these into subtasks
                        {
                            while (true)
                            {
                                rw.LL[j].X = random.Next(0, 2 * rnucleus) - rnucleus; // RW random origin
                                rw.LL[j].Y = random.Next(0, 2 * rnucleus) - rnucleus;
                                rw.LL[j].Z = random.Next(0, 2 * rnucleus) - rnucleus;
                                if (InsideEllipsoid(rw.LL[j]))
                                {
                                    break;
                                }
                            } // zzz666 these RWs don't have loops or domains yet
                            rw.nmonomer[j] = j;
                            j++;
                            for (int i = 0; i < Convert.ToInt32(IntactHumanGenome.NC[chn] / IntactHumanGenome.monomerSize) - 1; i++)
                            {
                                Location l_temp;
                                switch (random.Next(0, 3))
                                {
                                case 0:
                                {
                                    l_temp.X = rw.LL[j - 1].X + (2 * random.Next(0, 2) - 1);
                                    l_temp.Y = rw.LL[j - 1].Y;
                                    l_temp.Z = rw.LL[j - 1].Z;
                                    if (InsideEllipsoid(l_temp))
                                    {
                                        rw.LL[j] = l_temp;
                                    }
                                }
                                break;

                                case 1:
                                {
                                    l_temp.X = rw.LL[j - 1].X;
                                    l_temp.Y = rw.LL[j - 1].Y + (2 * random.Next(0, 2) - 1);
                                    l_temp.Z = rw.LL[j - 1].Z;
                                    if (InsideEllipsoid(l_temp))
                                    {
                                        rw.LL[j] = l_temp;
                                    }
                                }
                                break;

                                case 2:
                                {
                                    l_temp.X = rw.LL[j - 1].X;
                                    l_temp.Y = rw.LL[j - 1].Y;
                                    l_temp.Z = rw.LL[j - 1].Z + (2 * random.Next(0, 2) - 1);
                                    if (InsideEllipsoid(l_temp))
                                    {
                                        rw.LL[j] = l_temp;
                                    }
                                }
                                break;

                                default:
                                    break;
                                }
                                rw.nmonomer[j] = j;
                                j++;
                            }
                        }
                        if (ApplyRad2RWs(rs, rw, DSBdata)) // collect all sets of DSBs and put them into a list
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        //foreach (var item in new ManagementObjectSearcher("Select * from Win32_ComputerSystem").Get())
                        //{
                        //    Console.WriteLine("Number Of Physical Processors: {0} ", item["NumberOfProcessors"]);
                        //}
                        int coreCount = 0;
                        foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get())
                        {
                            coreCount += int.Parse(item["NumberOfCores"].ToString());
                        }
                        //Console.WriteLine("Number Of Cores: {0}", coreCount);
                        //Console.WriteLine("Number Of Logical Processors: {0}", Environment.ProcessorCount);
                        int processorCount        = Environment.ProcessorCount;
                        int logicalprocessorCount = 0;
                        foreach (var item in new ManagementObjectSearcher("Select * from Win32_ComputerSystem").Get())
                        {
                            //Console.WriteLine("Number Of Logical Processors: {0}", item["NumberOfLogicalProcessors"]);
                            logicalprocessorCount += int.Parse(item["NumberOfLogicalProcessors"].ToString());
                        }
                        int      nThreads = coreCount; // zzz ? or logicalprocessorCount?
                        Thread[] oThread  = null;
                        for (thread = 0; thread < nThreads; thread++)
                        {
                            Work        w = new Work(thread, nThreads, rs, DSBdata);
                            ThreadStart threadDelegate = new ThreadStart(Work.DoWork);
                            oThread[thread] = new Thread(threadDelegate);
                            oThread[thread].Start();
                        }
                    }
                    return(true);
                    // zzz666 run subtask all the way here, so that every CPU would produce DSBdata for each own RW, which has 46/nCPU  chromosomes; meaure time with and w/o parallelization
                }
                catch { return(false); }
            }
        public Object(int chromonumber) // obj = intact chromo
        {
            try
            {
                Length = Convert.ToInt32(IntactHumanGenome.NC[chromonumber] / IntactHumanGenome.monomerSize);
                md     = new MetaData();
                int itemp = Convert.ToInt32(IntactHumanGenome.CM[0] / IntactHumanGenome.monomerSize);
                for (int i = 0; i < chromonumber; i++)
                {
                    itemp += Convert.ToInt32(IntactHumanGenome.CM[chromonumber] / IntactHumanGenome.monomerSize);
                }
                md.c_l.Add(new Centromere()
                {
                    Position = itemp, Relative_position = PositionWithRespectToReferencePoint.not_known
                });
                md.f_e.Add(new Free_end()
                {
                    Position          = Convert.ToInt32(IntactHumanGenome.DownstreamEndPosition(chromonumber) / IntactHumanGenome.monomerSize),
                    FE_type           = MetaData.FreeEndType.telomeric,
                    Reacting          = false,
                    Relative_position = PositionWithRespectToReferencePoint.not_known // TBD later
                                                                                      // relative_location has to be defined with respect to some point of reference, like a DSB; this var. will used later in the algo
                });
                md.f_e.Add(new Free_end()
                {
                    Position          = Convert.ToInt32(IntactHumanGenome.DownstreamEndPosition(chromonumber) / IntactHumanGenome.monomerSize) + Length,
                    FE_type           = MetaData.FreeEndType.telomeric,
                    Reacting          = false,
                    Relative_position = PositionWithRespectToReferencePoint.not_known
                                        // relative_location has to be defined with respect to some point of reference, like a DSB, or a CM; this var. will used later in the algo
                });
                md.O_type = MetaData.ObjectType.intact_chromo;
                md.chromo_bands.AddLast(new Band()
                {
                    Size = Length,
                    Position_within_object  = 0,
                    Chromo_num              = chromonumber,
                    Downstream_end_position = md.f_e[0].Position,
                    Upstream_end_position   = md.f_e[1].Position
                });
                NumberOfBands = md.chromo_bands.Count;
                foreach (Band b in md.chromo_bands)
                {
                    switch (chromonumber)
                    {
                    case (1 - 1):
                    case (2 - 1):
                    {
                        b.Color = System.Drawing.Color.Red;
                    }
                    break;

                    case (3 - 1):
                    case (4 - 1):
                    {
                        b.Color = System.Drawing.Color.Green;
                    }
                    break;

                    case (7 - 1):
                    case (8 - 1):
                    {
                        b.Color = System.Drawing.Color.Yellow;
                    }
                    break;

                    default:
                    {
                        b.Color = System.Drawing.Color.DarkBlue;
                    }
                    break;
                    }
                }
            }
            catch
            {
                md = null; // if normal object definition is not possible, the MetaData are null
            }
        }