Ejemplo n.º 1
0
        public static void TrajectoryFileSandBox(long mCStep, List <Structs.BasicStructs.Point> mList)
        {
            string fileName = "TrajectorySandBox" + Directory.FileExtension;

            StringBuilder output = new StringBuilder();

            ExtendedStreamWriter tw;
            string currentFileName = string.Empty;


            if (StateControl.extensionfile == 0)
            {
                currentFileName = fileName;
            }
            else
            {
                currentFileName = "Trajectory" + StateControl.extensionfile + Directory.FileExtension;
            }

            tw = new ExtendedStreamWriter(@"C:\" + @"\" + currentFileName, true, Config.CurrentGuid, Config.Crypt);

            tw.AutoFlush = true;

            //Layout MCS   M1x   M1y  M1z  M2x   M2y  M2z  M3x   M3y  M3z   ...  M27x   M27y  M27z

            output.Append(mCStep + "\t"); // + totalMoviments + "\t" + NumberOfMovementsApplied + "\t");
            tw.Write(output.ToString());
            output.Length = 0;

            for (int xFor = 0; xFor < mList.Count; xFor++)
            {
                output.Append(mList[xFor].x.ToString() + "\t" + mList[xFor].y.ToString() + "\t" + mList[xFor].z.ToString());

                if (xFor < (mList.Count - 1))
                {
                    output.Append("\t");
                }

                tw.Write(output.ToString());
                output.Length = 0;
            }
            tw.WriteLine("");
            output = null;

            try
            {
                tw.Flush();
                tw.Close();
            }
            finally
            {
                tw = null;
            }
        }
            /// <summary>
            /// Salva em arquivo o contato topológico de vizinhos de primeiro contato
            /// </summary>
            /// <param name="isem"></param>
            public void NeighborsSave(long isem, ref int numberNeighborTopological)
            {
                string file = isem.ToString();
                //Members.initialIsem = Members.isem

                string dir      = IO.Directory.SubDirNeighbors;
                string pathFile = dir + @"\" + file + Consts.extensionOfFile;

                ExtendedStreamWriter sw = new ExtendedStreamWriter(Config.Crypt);

                sw.CreateText(pathFile, Config.CurrentGuid);

                int numberContact = 0;

                numberNeighborTopological = 0;
                //sw.WriteLine("Residuo | 1o.Vz.| 2o.Vz.| 3o.Vz.| 4o.Vz.| 5o.Vz.| 6o.Vz.|");

                List <BasicStructs.Point> points = this.r;

                //foreach (Structs.Point temp in points)
                for (int i = 0; i < points.Count; i++)
                {
                    BasicStructs.Point temp = points[i];
                    sw.Write("{0}\t", i);

                    if (temp.neighbors != null)
                    {
                        bool ocuredContact = false;
                        for (int j = 0; j < temp.neighbors.Length; j++)
                        {
                            if (temp.neighbors[j].classification == NeighborsType.neighborTopological)
                            {
                                numberContact++;
                                ocuredContact = true;
                                sw.Write("{0}\t", temp.neighbors[j].classification.ToString() + "(" + temp.neighbors[j].contacResidue.ToString() + ")");
                            }
                        }
                        if (ocuredContact)
                        {
                            numberNeighborTopological++;
                        }
                    }
                    sw.WriteLine();
                }

                sw.WriteLine();
                sw.WriteLine("numberContact:" + numberContact);
                sw.WriteLine("numberNeighborTopological:" + numberNeighborTopological);
                //this.numberNeighborTopological = numberNeighborTopological;
                sw.Flush();
                sw.Close();
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Save a classificação do tipo de Movimento possível
        /// </summary>
        public static void SaveClassificationOfMotion(string file)
        {
            string dir      = IO.Directory.SubDirClassificationOfMotion;
            string pathFile = dir + @"\" + file + Consts.extensionOfFile;

            ExtendedStreamWriter sw = new ExtendedStreamWriter(Config.Crypt);

            sw.CreateText(pathFile, Config.CurrentGuid);

            for (int i = 0; i < GCPS.chain.r.Count; i++)
            {
                Structs.BasicStructs.Point temp = GCPS.chain.r[i];
                sw.Write("{0}\t", i);

                sw.Write("{0}", temp.classificationMotion.ends == true ? "E " : string.Empty);
                sw.Write("{0}", temp.classificationMotion.stretched == true ? "S " : string.Empty);
                sw.Write("{0}", temp.classificationMotion.kink == true ? "T " : string.Empty);

                sw.Write("{0}", temp.classificationMotion.crankShaft__R0 == true ? "CR0 " : string.Empty);
                sw.Write("{0}", temp.classificationMotion.crankShaft__R1 == true ? "CR1 " : string.Empty);
                sw.Write("{0}", temp.classificationMotion.crankShaft__R2 == true ? "CR2 " : string.Empty);
                sw.Write("{0}", temp.classificationMotion.crankShaft__R3 == true ? "CR3 " : string.Empty);

                sw.WriteLine();
            }

            sw.Flush();
            sw.Close();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Metodo o qual efetua geração do arquivo texto com os Monomeros baseados em um dado Isem
        /// </summary>
        /// <param name="mList">Lista de Monomeros</param>
        /// <param name="breakLine">Pula linha entre as interações</param>
        /// <param name="overrideFile">Se o arquivo existir, o mesmo é sobreposto</param>
        public static void RecTrajectoryFileCalcSpinningRay_MIN(long mCStep, long totalMoviments, long numberOfMovementsApplied, List <Structs.BasicStructs.Point> mList, bool breakLine, Guid guid)
        {
            string fileName         = GCPS.initialIsem + "_calcSpinningRay_MIN_" + GCPS.chain.contMoves.SumOfAcceptedAndRejectedMovement + Directory.FileExtension;
            bool   append           = false;
            ExtendedStreamWriter tw = new ExtendedStreamWriter(Directory.SubDirTrajectorySet + @"\" + fileName, append, Config.CurrentGuid, Config.Crypt);

            StringBuilder output = new StringBuilder();

            for (int xFor = 0; xFor < mList.Count; xFor++)
            {
                output.Append(mList[xFor].x.ToString() + "\t" + mList[xFor].y.ToString() + "\t" + mList[xFor].z.ToString());
                tw.Write(output.ToString());
                if (breakLine)
                {
                    tw.WriteLine();
                }
                output.Length = 0;
            }

            output = null;

            try
            {
                tw.Flush();
                tw.Close();
            }
            finally
            {
                tw = null;
            }
        }
Ejemplo n.º 5
0
        public static void SaveData(BasicEnums.ChainTypes chainType, Structs.Queue <QueueType> queue)
        {
            string file = firstNameFiles + chainType.ToString();

            string dir                                  = IO.Directory.SubDirCoord;
            string pathFileIsem                         = dir + @"\" + file + Consts.extensionOfFile;
            string pathFileSpinningRayValue             = dir + @"\" + file + spinningRayValues + Consts.extensionOfFile;
            string pathCalDistanceBetweenLastPointFirst = dir + @"\" + file + calDistanceBetweenLastPointFirst + Consts.extensionOfFile;


            ExtendedStreamWriter swIsem = new ExtendedStreamWriter(Config.Crypt);

            swIsem.AppendText(pathFileIsem, Config.CurrentGuid);

            ExtendedStreamWriter swSpinningRay = new ExtendedStreamWriter(Config.Crypt);

            swSpinningRay.AppendText(pathFileSpinningRayValue, Config.CurrentGuid);

            ExtendedStreamWriter swCalDistanceBetweenLastPointFirst = new ExtendedStreamWriter(Config.Crypt);

            swCalDistanceBetweenLastPointFirst.AppendText(pathCalDistanceBetweenLastPointFirst, Config.CurrentGuid);

            StringBuilder sbIsem        = new StringBuilder();
            StringBuilder sbSpinningRay = new StringBuilder();
            StringBuilder sbCalDistanceBetweenLastPointFirst = new StringBuilder();

            while (queue.Count > 0)
            {
                QueueType type = queue.Dequeue();

                sbIsem.AppendFormat("{0}{1}", type.isemName, ";");
                sbSpinningRay.AppendFormat(@"{0}{1}", type.spinningRayValue, ";");
                sbCalDistanceBetweenLastPointFirst.AppendFormat(@"{0}{1}", type.calDistanceBetweenLastPointFirst, ";");

                swSpinningRay.Write(sbSpinningRay.ToString());
                swCalDistanceBetweenLastPointFirst.Write(sbCalDistanceBetweenLastPointFirst.ToString());
                swIsem.Write(sbIsem.ToString());

                sbIsem.Clear();
                sbSpinningRay.Clear();
                sbCalDistanceBetweenLastPointFirst.Clear();
            }

            swSpinningRay.Close();
            swCalDistanceBetweenLastPointFirst.Close();
            swIsem.Close();
        }
Ejemplo n.º 6
0
        public static void StreamRecBlob(byte[] data)
        {
            bool   append           = true;
            string fileName         = "blob" + DateTime.Now.ToShortDateString() + ".dat";
            ExtendedStreamWriter tw = new ExtendedStreamWriter(Directory.SubDirBlob + @"\" + fileName, append, Config.CurrentGuid, Config.Crypt);

            tw.Write(data);

            try
            {
                tw.Flush();
                tw.Close();
            }
            finally
            {
                tw = null;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Salva em arquivo os valores da "Matriz energética"
        /// </summary>
        public static void SaveEnergeticMatrix()
        {
            string file = GCPS.chain.isem.ToString();

            string dir      = IO.Directory.SubDirNeighbors;
            string pathFile = dir + @"\Me_" + file + Consts.extensionOfFile;

            ExtendedStreamWriter sw = new ExtendedStreamWriter(Config.Crypt);

            sw.CreateText(pathFile, Config.CurrentGuid);

            for (int i = 0; i < GCPS.chain.r.Count; i++)
            {
                for (int j = 0; j < GCPS.chain.r.Count; j++)
                {
                    sw.Write(String.Format(@"{0}", GCPS.energeticMatrix[i, j]).ToString() + "\t");
                }
                sw.WriteLine();
            }
            sw.Flush();
            sw.Close();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Metodo o qual efetua geração do arquivo texto com os Monomeros baseados em um dado Isem
        /// </summary>
        /// <param name="mList">Lista de Monomeros</param>
        /// <param name="breakLine">Pula linha entre as interações</param>
        /// <param name="overrideFile">Se o arquivo existir, o mesmo é sobreposto</param>
        public static void TrajectoryFile(long mCStep, long totalMoviments, long numberOfMovementsApplied, List <Structs.BasicStructs.Point> mList, Guid guid, Int32 splitFileEvery, bool firstStep = false)
        {
            StateControl.splitFileEvery = splitFileEvery;
            string fileName = "Trajectory" + Directory.FileExtension;

            StringBuilder output = new StringBuilder();

            ExtendedStreamWriter tw;
            string currentFileName = string.Empty;

            if (firstStep)
            {
                StateControl.numberOfLines = 0;
                tw = new ExtendedStreamWriter(Directory.SubDirTrajectorySet + @"\" + fileName, false, Config.CurrentGuid, Config.Crypt);
                output.Append("mCStep" + "\t");// + "totalMoviments" + "\t" + "NumberOfMovementsApplied" + "\t");

                for (int xFor = 0; xFor < mList.Count; xFor++)
                {
                    output.Append("x" + xFor + "\t" + "y" + xFor + "\t" + "z" + xFor);

                    if (xFor < (mList.Count - 1))
                    {
                        output.Append("\t");
                    }

                    tw.Write(output.ToString());
                    output.Length = 0;
                }
                tw.WriteLine("");
            }
            else
            {
                if (StateControl.extensionfile == 0)
                {
                    currentFileName = fileName;
                }
                else
                {
                    currentFileName = "Trajectory" + StateControl.extensionfile + Directory.FileExtension;
                }

                tw = new ExtendedStreamWriter(Directory.SubDirTrajectorySet + @"\" + currentFileName, true, Config.CurrentGuid, Config.Crypt);

                StateControl.numberOfLines++;

                if (StateControl.numberOfLines == StateControl.splitFileEvery)
                {
                    StateControl.numberOfLines = 0;
                    StateControl.extensionfile++;
                }
            }


            tw.AutoFlush = true;

            //Layout MCS   M1x   M1y  M1z  M2x   M2y  M2z  M3x   M3y  M3z   ...  M27x   M27y  M27z

            output.Append(mCStep + "\t"); // + totalMoviments + "\t" + NumberOfMovementsApplied + "\t");
            tw.Write(output.ToString());
            output.Length = 0;

            for (int xFor = 0; xFor < mList.Count; xFor++)
            {
                output.Append(mList[xFor].x.ToString() + "\t" + mList[xFor].y.ToString() + "\t" + mList[xFor].z.ToString());

                if (xFor < (mList.Count - 1))
                {
                    output.Append("\t");
                }

                tw.Write(output.ToString());
                output.Length = 0;
            }
            tw.WriteLine("");
            output = null;

            try
            {
                tw.Flush();
                tw.Close();
            }
            finally
            {
                tw = null;
            }
        }