public Work(int thread, int n, RadiationSchema r, DSBs dd)
 {
     nThread  = thread;
     nThreads = n;
     rs       = r;
     DSBdata  = dd;
 }
Exemplo n.º 2
0
 //
 public bool CheckDSBlist(DSBs dsbs) // everytime DSBs are created or repaired, this function does some bookkeeping
 {
     //int itemp = 0;
     //foreach (Object o in listObjs)
     //    foreach (free_end fe in o.md.f_e)
     //        if (fe.fe_type == MetaData.freeEndType.reactive)
     //            itemp++;
     //if (itemp != 2 * dsbList.DSBpositions.Count)
     //    return false;
     //else // zzz -- update this function
     return(true);
 }
            //
            public static bool ApplyRad2RWs(RadiationSchema rs, RandomWalk rw, DSBs DSBdata)
            {
                int ndsb = 0;

                try
                {
                    double dose;
                    double dose_total = 0.0;
                    for (int nb = 0; nb < rs.nBeams; nb++) // iterate over all beams
                    {
                        foreach (int j in rw.nmonomer)
                        {
                            dose        = Dconst;
                            dose_total += Dconst;
                            try
                            {
                                for (int i = 0; i < amorphous_partile_tracks[nb].track_struct.ntracks; i++)
                                {
                                    int x     = amorphous_partile_tracks[nb].track_struct.X[i];
                                    int y     = amorphous_partile_tracks[nb].track_struct.Y[i];
                                    int dist2 = (x - rw.LL[j].X) * (x - rw.LL[j].X) + (y - rw.LL[j].Y) * (y - rw.LL[j].Y);
                                    if (dist2 < Convert.ToInt32((RadiationSchema.Pr / lattice_dim) * (RadiationSchema.Pr / lattice_dim)))
                                    {
                                        int t = Convert.ToInt32(MainForm.Particle.Tracks.grid * lattice_dim * Math.Sqrt(dist2) / RadiationSchema.Pr); // microns
                                        dose       += amorphous_partile_tracks[nb].track_struct.dose[t];
                                        dose_total += amorphous_partile_tracks[nb].track_struct.dose[t];
                                    }
                                }
                            }
                            catch { return(false); }
                            double Q = 0.812 * 35.0 / 25.0; // multiply by 35./25. for high/low LET; also 1e-5 is factored out
                            if (amorphous_partile_tracks[nb].p_t == MainForm.Radiation.p_type.photon)
                            {
                                Q = 0.812; // multiply by 35./25. for high LET
                            }
                            else
                            {
                                Q = 0.812 * 35.0 / 25.0; // multiply by 35./25. for high LET
                            }
                            Q *= 1.0e-5;                 // Q is determined from PFGE experiments
                            Random random = new Random();
                            try
                            {
                                if (SimpleRNG.GetUniform() < 1.0 - Math.Exp(-Q * dose))
                                {
                                    ndsb++;
                                    DSBs.DSBstruct new_dsb = new DSBs.DSBstruct
                                    {
                                        ndsb       = ndsb,
                                        L          = rw.LL[j],
                                        position   = rw.nmonomer[j],
                                        entry_time = rs.entryTime[nb],
                                        exit_time  = rs.exitTime[nb]
                                    };
                                    new_dsb.random_time = SimpleRNG.GetUniform() * (new_dsb.exit_time - new_dsb.entry_time) + new_dsb.entry_time; // a DSB is created sometime during the fractionation interval
                                    double r = SimpleRNG.GetUniform();
                                    if (r < DSBs.DSBcomplP[0])
                                    {
                                        new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.simpleDSB;
                                    }
                                    else
                                    {
                                        if (r >= DSBs.DSBcomplP[0] && r < DSBs.DSBcomplP[1]) // zzz can a DSB appear more than 1 time at the same monomer
                                        {
                                            new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.DSBplus;
                                        }
                                        else
                                        {
                                            new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.DSBplusplus;
                                        }
                                    }
                                    DSBdata.listDSBs.Add(new_dsb);
                                }
                            }
                            catch { return(false); }
                        }
                    }
                    dose_total /= Convert.ToDouble(rw.nmonomer.Length); // total dose integrated over all monomers // zzz might wanna output somewhere
                    return(true);
                }
                catch { return(false); }
            }
            //
            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); }
            }
Exemplo n.º 5
0
 public bool Detailed_checkDSBlist(DSBs dsbs) // everytime DSBs are created or repaired, this function does some bookkeeping
 {
     //dsbList.ndsb = dsbList.DSBpositions.Count; // zzz
     return(true); // add checks that might return false
 }
Exemplo n.º 6
0
 public readonly double sigma2 = 2.0e3;                     //  get it from fits to the experiment; sigma2 parameter in the distance exp.
 //
 public TimeOperator()
 {
     rs          = new RadiationSchema();
     DNAbreakage = new NASARTI_original(rs);
     DSBdata     = new DSBs();
 }