Exemplo n.º 1
0
        private void SaveSimulationResult(SimulationResult sr, String fname, Boolean addpdbsave)
        {
            String  converged = sr.Converged ? " (converged)" : " (not converged)";
            String  fullfname = fname + ".pml";
            Vector3 u; Double theta;

            using (StreamWriter sw = new StreamWriter(fullfname, false))
            {
                sw.WriteLine("# Energy = " + sr.E.ToString("F8") + converged);
                for (Int32 i = 0; i < molecules.Count; i++)
                {
                    sw.WriteLine("load " + molecules[i].FullFileName);
                }
                for (Int32 i = 1; i < molecules.Count; i++)
                {
                    theta = Matrix3.AngleAndAxis(sr.Rotation[i], out u) * 180.0 / Math.PI;
                    sw.WriteLine("rotate [" + u.ToString() + "], " + theta.ToString("F3")
                                 + ", " + molecules[i].Name + ", origin=[" + molecules[i].CM.ToString() + "]");
                    sw.WriteLine("translate [" + sr.Translation[i].ToString() + "], " + molecules[i].Name);
                }
                if (_bestfit)
                {
                    sw.WriteLine("select all");
                    sw.WriteLine("translate [" + sr.BestFitTranslation.ToString() + "], sele");
                    theta = Matrix3.AngleAndAxis(sr.BestFitRotation, out u) * 180.0 / Math.PI;
                    sw.WriteLine("rotate [" + u.ToString() + "], " + theta.ToString("F3")
                                 + ", sele, origin=[0, 0, 0]");
                }
                if (addpdbsave)
                {
                    sw.WriteLine("select all");
                    sw.WriteLine("save " + fname + ".pdb, sele");
                }
                String lpnames = "";
                if (lpcheckBox.Checked)
                {
                    Int32            im;
                    Vector3          r;
                    LabelingPosition lpref;
                    foreach (LabelingPosition l in labelingpos)
                    {
                        im = molecules.FindIndex(l.Molecule);
                        if ((sr.SimulationMethod & SimulationMethods.Refinement) != 0)
                        {
                            lpref = sr.RefinedLabelingPositions.Find(l.Name);
                        }
                        else
                        {
                            lpref = l;
                        }
                        r = sr.Rotation[im] * (lpref - molecules[im].CM) + molecules[im].CM + sr.Translation[im];
                        sw.WriteLine("pseudoatom " + l.Name + ", pos=[" + r.ToString() + "]");
                        sw.WriteLine("label " + l.Name + ", \"" + l.Name + "\"");
                        sw.WriteLine("show spheres, " + l.Name);
                        if (l.Dye == DyeType.Donor)
                        {
                            sw.WriteLine("color green, " + l.Name);
                        }
                        if (l.Dye == DyeType.Acceptor)
                        {
                            sw.WriteLine("color red, " + l.Name);
                        }
                        lpnames += " + " + l.Name;
                    }
                }
                if (_bestfit && lpnames != String.Empty)
                {
                    sw.WriteLine("deselect");
                    sw.WriteLine("select " + lpnames.Substring(3));
                    sw.WriteLine("translate [" + sr.BestFitTranslation.ToString() + "], sele");
                    theta = Matrix3.AngleAndAxis(sr.BestFitRotation, out u) * 180.0 / Math.PI;
                    sw.WriteLine("rotate [" + u.ToString() + "], " + theta.ToString("F3")
                                 + ", sele, origin=[0, 0, 0]");
                }
                sw.WriteLine("deselect");
                sw.Close();
            }
        }