Esempio n. 1
0
 public SimulationBase(MoleculeList ms, LabelingPositionList lps, DistanceList ds)
 {
     this.Molecules         = ms;
     this.LabelingPositions = lps;
     this.Distances         = ds;
     InitRnd();
 }
Esempio n. 2
0
        private LabelingPositionList RedoAV()
        {
            LabelingPositionList lps_local = new LabelingPositionList(this.LabelingPositions.Count);

            lps_local.AddRange(this.LabelingPositions);

            AVEngine         av = new AVEngine(mt, this.ProjectDataCopy.AVGlobalParameters);
            LabelingPosition l;
            Vector3          rmp;
            int natom, nmol;

            for (Int32 i = 0; i < lps_local.Count; i++)
            {
                l = lps_local[i];
                if (l.AVData.AVType == AVSimlationType.None)
                {
                    continue;
                }
                nmol  = sr.Molecules.FindIndex(l.Molecule);
                natom = Array.BinarySearch <Int32>(mt.OriginalAtomID, molstart[nmol], molnatoms[nmol], l.AVData.AtomID);
                if (l.AVData.AVType == AVSimlationType.SingleDyeR)
                {
                    av.Calculate1R(l.AVData.L, l.AVData.W, l.AVData.R, natom);
                }
                else if (l.AVData.AVType == AVSimlationType.ThreeDyeR)
                {
                    av.Calculate3R(l.AVData.L, l.AVData.W, l.AVData.R1, l.AVData.R2, l.AVData.R3, natom);
                }
                rmp = Matrix3.Transpose(sr.Rotation[nmol]) * (av.Rmp - sr.Translation[nmol]
                                                              + sr.Molecules[0].CM - sr.Molecules[nmol].CM) + sr.Molecules[nmol].CM;
                l.X          = rmp.X; l.Y = rmp.Y; l.Z = rmp.Z;
                lps_local[i] = l;
            }
            return(lps_local);
        }
Esempio n. 3
0
        private void AVinterface_Load(object sender, EventArgs e)
        {
            rmptextBox.Text = "Ready";
            moleculescomboBox.Items.Clear();
            if (_standalone)
            {
                _molecules = new MoleculeList(20);
            }
            for (Int32 i = 0; i < _molecules.Count; i++)
            {
                moleculescomboBox.Items.Add(_molecules[i].Name);
            }
            if (moleculescomboBox.Items.Count > 0)
            {
                moleculescomboBox.SelectedIndex = 0;
            }
            calculatebutton.Enabled = (_molecules.Count > 0);

            // load default dye parameters
            dyescomboBox.Items.AddRange(LinkerData.LinkerList);
            dyescomboBox.SelectedIndex = 0;

            simcombobox.SelectedIndex = 0;

            _labelpos          = new LabelingPositionList();
            savebutton.Enabled = false;
            addbutton.Enabled  = false;
        }
Esempio n. 4
0
        public FilterEngine(LabelingPositionList ls, DistanceList ds)
        {
            this.LabelingPositions = ls;
            this.Distances         = ds;
#if DEBUG
            rnd = new Random(53672429);
#else
            rnd = new Random();
#endif
            // just in case default AV parameters
            this.avparam.GridSize            = 0.2;
            this.avparam.MinGridSize         = 0.4;
            this.avparam.LinkerInitialSphere = 0.5;
            this.avparam.LinkSearchNodes     = 3;
            this.avparam.ESamples            = 200000;
        }
Esempio n. 5
0
 public SpringEngine(MoleculeList ms, LabelingPositionList ls, DistanceList ds) : base(ms, ls, ds)
 {
     this.Nmolecules = ms.Count;
     translation     = new Vector3[Nmolecules];
     rotation        = new Matrix3[Nmolecules];
     translationm1   = new Vector3[Nmolecules];
     rotationm1      = new Matrix3[Nmolecules];
     translationm2   = new Vector3[Nmolecules];
     rotationm2      = new Matrix3[Nmolecules];
     for (int i = 0; i < Nmolecules; i++)
     {
         rotation[i]   = Matrix3.E;
         rotationm1[i] = Matrix3.E;
     }
     force  = new Vector3[Nmolecules];
     torque = new Vector3[Nmolecules];
 }
Esempio n. 6
0
 public ErrorEstimation(MoleculeList ms, LabelingPositionList ls, DistanceList ds) : base(ms, ls, ds)
 {
 }
Esempio n. 7
0
 public Refinement(MoleculeList ms, LabelingPositionList ls, DistanceList ds) : base(ms, ls, ds)
 {
 }
Esempio n. 8
0
        private void PrepareSimulation()
        {
            // molecules
            Nmolecules = _molecules.Count;
            int maxatomsincluster = 0;

            for (int i = 0; i < Nmolecules; i++)
            {
                minmass           = Math.Min(minmass, _molecules[i].Mass);
                maxatomsincluster = Math.Max(maxatomsincluster, _molecules[i].MaxAtomsInCluster);
            }

            // labeling positions
            int im;

            labelingpos_cm = new LabelingPositionList();
            labelingpos_cm.AddRange(this._labelingpositions);
            lpossim = new Vector3[labelingpos_cm.Count];
            LtoM    = new int[labelingpos_cm.Count];
            // convert to local coordinates
            for (int i = 0; i < labelingpos_cm.Count; i++)
            {
                im                 = _molecules.FindIndex(labelingpos_cm[i].Molecule);
                LtoM[i]            = im;
                labelingpos_cm[i] -= _molecules[im].CM;
                lpossim[i]         = labelingpos_cm[i];
            }

            // distances
            Distance dist_i;

            DtoL1      = new int[_distances.Count];
            DtoM1      = new int[_distances.Count];
            DtoL2      = new int[_distances.Count];
            DtoM2      = new int[_distances.Count];
            kplus      = new double[_distances.Count];
            kminus     = new double[_distances.Count];
            drmaxplus  = new double[_distances.Count];
            drmaxminus = new double[_distances.Count];
            double minerror = double.MaxValue;

            for (int i = 0; i < _distances.Count; i++)
            {
                DtoL1[i] = labelingpos_cm.FindIndex(_distances[i].Position1);
                DtoM1[i] = _molecules.FindIndex(labelingpos_cm.Find(_distances[i].Position1).Molecule);
                DtoL2[i] = labelingpos_cm.FindIndex(_distances[i].Position2);
                DtoM2[i] = _molecules.FindIndex(labelingpos_cm.Find(_distances[i].Position2).Molecule);

                // check if bond
                dist_i        = _distances[i];
                dist_i.IsBond = (labelingpos_cm[DtoL1[i]].Dye == DyeType.Unknown && labelingpos_cm[DtoL1[i]].AVData.AtomID > 0 &&
                                 labelingpos_cm[DtoL1[i]].AVData.AVType == AVSimlationType.None && labelingpos_cm[DtoL2[i]].Dye == DyeType.Unknown &&
                                 labelingpos_cm[DtoL2[i]].AVData.AtomID > 0 && labelingpos_cm[DtoL2[i]].AVData.AVType == AVSimlationType.None);
                _distances[i] = dist_i;

                // if bond, set small vdW radii to "exclude" from clashing
                if (dist_i.IsBond)
                {
                    foreach (var lp in new[] { labelingpos_cm[DtoL1[i]], labelingpos_cm[DtoL2[i]] })
                    {
                        int m     = _molecules.FindIndex(lp.Molecule);
                        int natom = Array.BinarySearch <int>(_molecules[m].OriginalAtomID, lp.AVData.AtomID);
                        _molecules[m].vdWR[natom] = AtomData.vdWRNoClash;
                        int natom_cluster = Array.FindIndex <int>(_molecules[m].ClusteredAtomOriginalIndex, n => n == natom);
                        if (natom_cluster >= 0)
                        {
                            _molecules[m].ClusteredAtomvdwR[natom_cluster] = AtomData.vdWRNoClash;
                            System.Runtime.InteropServices.Marshal.Copy(new[] { (float)AtomData.vdWRNoClash }, 0,
                                                                        FpsNativeWrapper.Aligned16(_molecules[m].XYZvdwRVectorArray) + (4 * natom_cluster + 3) * sizeof(float), 1);
                        }
                    }
                }

                // "spring constants"
                kplus[i]  = 2.0 / _distances[i].ErrPlus / _distances[i].ErrPlus;
                kminus[i] = 2.0 / _distances[i].ErrMinus / _distances[i].ErrMinus;
                //Console.Out.WriteLine("distance#" + i + " k+= " + kplus[i] + " k-= " + kminus[i] + " err+ " + _distances[i].ErrPlus + " err- " + _distances[i].ErrMinus);

                drmaxplus[i]  = SimulationParameters.MaxForce / kplus[i];
                drmaxminus[i] = -SimulationParameters.MaxForce / kminus[i];
                minerror      = Math.Min(minerror, Math.Min(_distances[i].ErrPlus, _distances[i].ErrMinus));
            }

            // simulation parameters
            kclash     = 2.0 / SimulationParameters.ClashTolerance / SimulationParameters.ClashTolerance;
            drmaxclash = -SimulationParameters.MaxForce / kclash;
            dr4dt      = Math.Min(SimulationParameters.ClashTolerance * 0.5, minerror);
        }
Esempio n. 9
0
        /// <summary>
        /// Read reference atoms from an LP file
        /// </summary>
        /// <param name="m">Example molecule</param>
        /// <param name="classicpdb">True for pdb line format, false if tab-delimited</param>
        public void ReadRefAtoms(Molecule m, Boolean classicpdb)
        {
            // re-read the lp file to get reference frames
            referenceAtoms = new List <ReferenceAtom[]>(labelingpos.Count);
            Int32 j;

            String[] strdata;
            strdata = System.IO.File.ReadAllLines(labelingpos.FullPath);

            String[] tmpstr;
            Double   x, y, z;

            Char[]          separator = new Char[] { ' ', '\t' };
            ReferenceAtom[] reftmp;
            for (Int32 i = 0; i < strdata.Length; i++)
            {
                // find LP line
                if (!LabelingPositionList.ValidLPLine(strdata[i]))
                {
                    continue;
                }
                // now LP is found, count following pdb lines if any
                j = 0;
                if (classicpdb)
                {
                    while (i + j + 1 < strdata.Length && strdata[i + j + 1].Length > 54 && strdata[i + j + 1].Substring(0, 4) == "ATOM")
                    {
                        j++;
                    }
                }
                else
                {
                    while (i + j + 1 < strdata.Length && strdata[i + j + 1].Length > 10 && strdata[i + j + 1].Substring(0, 4) == "ATOM")
                    {
                        j++;
                    }
                }
                reftmp = new ReferenceAtom[j];
                // read reference atoms
                j = 0;
                if (classicpdb)
                {
                    while (i + j + 1 < strdata.Length && strdata[i + j + 1].Length > 54 && strdata[i + j + 1].Substring(0, 4) == "ATOM")
                    {
                        tmpstr = strdata[i + j + 1].Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        reftmp[j].OriginalN  = Int32.Parse(tmpstr[1]);
                        reftmp[j].ConvertedN = Array.BinarySearch <Int32>(m.OriginalAtomID, reftmp[j].OriginalN);
                        if (Double.TryParse(strdata[i + j + 1].Substring(30, 8), out x) &&
                            Double.TryParse(strdata[i + j + 1].Substring(38, 8), out y) &&
                            Double.TryParse(strdata[i + j + 1].Substring(46, 8), out z))
                        {
                            reftmp[j].X = x;
                            reftmp[j].Y = y;
                            reftmp[j].Z = z;
                        }
                        j++;
                    }
                }
                else
                {
                    while (i + j + 1 < strdata.Length && strdata[i + j + 1].Length > 10 && strdata[i + j + 1].Substring(0, 4) == "ATOM")
                    {
                        tmpstr = strdata[i + j + 1].Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        reftmp[j].OriginalN  = Int32.Parse(tmpstr[1]);
                        reftmp[j].ConvertedN = Array.BinarySearch <Int32>(m.OriginalAtomID, reftmp[j].OriginalN);
                        if (Double.TryParse(tmpstr[6], out x) &&
                            Double.TryParse(tmpstr[7], out y) &&
                            Double.TryParse(tmpstr[8], out z))
                        {
                            reftmp[j].X = x;
                            reftmp[j].Y = y;
                            reftmp[j].Z = z;
                        }
                        j++;
                    }
                }
                referenceAtoms.Add(reftmp);
                i += j;
            }
        }
Esempio n. 10
0
        private double Elast; // energy after last iteration

        public MetropolisSampler(MoleculeList ms, LabelingPositionList ls, DistanceList ds) : base(ms, ls, ds)
        {
            this.IsContinuous = true;
        }