예제 #1
0
 //
 public bool Create2newObjs(Object o1, Object o2, Object o, DSBs.DSBstruct dsb)
 {
     if (o1.FillObj(o1, o, dsb, PositionWithRespectToReferencePoint.downstream))
     {
         if (o2.FillObj(o2, o, dsb, PositionWithRespectToReferencePoint.upstream))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
            //
            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); }
            }
예제 #3
0
 public bool FillObj(Object o_new, Object o, DSBs.DSBstruct dsb, PositionWithRespectToReferencePoint relative_location) // add attributes to an empty object
 {
     try
     {
         o_new.md = new MetaData
         {
             chromo_bands = new LinkedList <Band>()
         };
         if (relative_location == PositionWithRespectToReferencePoint.downstream) // downstream from the DSB
         {
             for (int i = 0; i < o.md.f_e.Count; i++)
             {
                 if (o.md.f_e[i].Position <= dsb.position)
                 {
                     o_new.md.f_e.Add(new Free_end()
                     {
                         Position          = o.md.f_e[i].Position,
                         FE_type           = o.md.f_e[i].FE_type,
                         Reacting          = o.md.f_e[i].Reacting,
                         L                 = o.md.f_e[i].L,                                // input X, Y, Z, location of a free end, only if it can interact with other free ends
                         Relative_position = PositionWithRespectToReferencePoint.not_known // since this is a new fragment, there is no point of reference yet for this reactive end; this var. is always for later use
                     });
                     foreach (Band b in o.md.chromo_bands)
                     {
                         if (!(b.Position_within_object <= dsb.position - o.md.f_e[i].Position && b.Position_within_object + b.Size >= dsb.position - o.md.f_e[i].Position))
                         {
                             var b1 = (Band)b.MemberwiseClone();
                             o_new.md.chromo_bands.AddLast(b1);
                         }
                         else
                         {
                             var b1 = (Band)b.MemberwiseClone();
                             o_new.md.chromo_bands.AddLast(b1);
                             o_new.md.chromo_bands.Last.Value.Size = dsb.position - o.md.f_e[i].Position - b.Position_within_object;
                             o_new.md.chromo_bands.Last.Value.Upstream_end_position = dsb.position;
                             break;
                         }
                     }
                     o_new.NumberOfBands = o_new.md.chromo_bands.Count;
                     o_new.Length        = dsb.position - o.md.f_e[i].Position;
                 }
             }
             for (int i = 0; i < o.md.c_l.Count; i++)
             {
                 if (o.md.c_l[i].Position < dsb.position)
                 {
                     o_new.md.c_l.Add(new Centromere()
                     {
                         Position = o.md.c_l[i].Position, Relative_position = PositionWithRespectToReferencePoint.not_known
                     });
                 }
             }
             o_new.md.f_e.Add(new Free_end()
             {
                 Position          = dsb.position,
                 FE_type           = MetaData.FreeEndType.reactive,
                 Reacting          = false,
                 L                 = dsb.L,
                 Relative_position = PositionWithRespectToReferencePoint.not_known // TBD later
                                                                                   // since this is a new fragment, there is no point of reference (like a new DSB) yet for this reactive end; this var. is always for later use
             });
             if (o_new.md.f_e[0].FE_type == MetaData.FreeEndType.reactive)
             {
                 o_new.md.O_type = MetaData.ObjectType.open_fragement;
             }
             else
             {
                 o_new.md.O_type = MetaData.ObjectType.frag_with_one_telomere;
             }
         }
         else
         {
             for (int i = 0; i < o.md.f_e.Count; i++)
             {
                 if (o.md.f_e[i].Position >= dsb.position)
                 {
                     o_new.md.f_e.Add(new Free_end()
                     {
                         Position          = o.md.f_e[i].Position,
                         FE_type           = o.md.f_e[i].FE_type,
                         Reacting          = o.md.f_e[i].Reacting,
                         L                 = o.md.f_e[i].L,
                         Relative_position = PositionWithRespectToReferencePoint.not_known
                                             // since this is a new fragment, there is no point of reference yet for this reactive end; this var. is always for later use
                     });
                     foreach (Band b in o.md.chromo_bands)
                     {
                         if (!(b.Position_within_object <= o.Length - (o.md.f_e[i].Position - dsb.position) && b.Position_within_object + b.Size >= o.Length - (o.md.f_e[i].Position - dsb.position)))
                         {
                             var b1 = (Band)b.MemberwiseClone();
                             o_new.md.chromo_bands.AddLast(b1);
                             o_new.md.chromo_bands.Last.Value.Position_within_object = b.Position_within_object - (o.Length - (o.md.f_e[i].Position - dsb.position));
                         }
                         else
                         {
                             var b1 = (Band)b.MemberwiseClone();
                             o_new.md.chromo_bands.AddFirst(b1); // first, add a band to the new obj., then adjust its size and position
                             o_new.md.chromo_bands.First.Value.Size = b.Size - ((o.Length - b.Position_within_object) - (o.md.f_e[i].Position - dsb.position));
                             o_new.md.chromo_bands.First.Value.Position_within_object  = 0;
                             o_new.md.chromo_bands.First.Value.Downstream_end_position = dsb.position;
                             break;
                         }
                     }
                     o_new.NumberOfBands = o_new.md.chromo_bands.Count;
                     o_new.Length        = -dsb.position + o.md.f_e[i].Position;
                 }
             }
             for (int i = 0; i < o.md.c_l.Count; i++)
             {
                 if (o.md.c_l[i].Position >= dsb.position)
                 {
                     o_new.md.c_l.Add(new Centromere()
                     {
                         Position = o.md.c_l[i].Position, Relative_position = PositionWithRespectToReferencePoint.not_known
                     });
                 }
             }
             o_new.md.f_e.Add(new Free_end()
             {
                 Position          = dsb.position,
                 FE_type           = MetaData.FreeEndType.reactive,
                 Reacting          = false,
                 L                 = dsb.L,
                 Relative_position = PositionWithRespectToReferencePoint.not_known // TBD later
                                                                                   // since this is a new fragment, there is no point of reference (like a new DSB) yet for this reactive end; this var. is always for later use
             });
             if (o_new.md.f_e[0].FE_type == MetaData.FreeEndType.reactive)
             {
                 o_new.md.O_type = MetaData.ObjectType.open_fragement;
             }
             else
             {
                 o_new.md.O_type = MetaData.ObjectType.frag_with_one_telomere;
             }
         }
         foreach (Band b in o_new.md.chromo_bands)
         {
             b.Size = b.Upstream_end_position - b.Downstream_end_position;
         }
         int bsize = 0;
         foreach (Band b in o_new.md.chromo_bands)
         {
             b.Position_within_object += bsize;
             bsize = b.Size;
         }
         if (o_new.md.f_e.Count == 2)
         {
             return(true);
         }
         else
         {
             return(false); // >= and <= should be for all conditions related  to a DSB, and >= and < for a centromere
         }
     }
     catch
     {
         return(false);
     }
 }