Example #1
0
        public static double[] LoadData(BasicEnums.ChainTypes chainType, BasicEnums.HistTypes histType)
        {
            string file = firstNameFiles + chainType.ToString();

            string dir = IO.Directory.SubDirCoord;
            string pathFileSpinningRayValue = dir + @"\" + file + histType.ToString() + Consts.extensionOfFile;

            ExtendedStreamReader srSpinningRay = new ExtendedStreamReader(pathFileSpinningRayValue, Config.CurrentGuid, Config.Crypt);

            string allText = srSpinningRay.ReadToEnd();

            if (allText != null)
            {
                string[] arrString = Regex.Split(allText, ";");
                //Array.Resize(ref arrString, arrString.Length -1); //tira o bug do ENTER

                srSpinningRay.Close();
                srSpinningRay.Dispose();

                double[] arrDouble = new double[arrString.Length - 1];
                for (int i = 0; i < arrString.Length - 1; i++)
                {
                    arrDouble[i] = Convert.ToDouble(arrString[i]);
                }

                return(arrDouble);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public static List <int> DoPoc_GhostStructToNativeStruct()
        {
            Console.WriteLine("DoPoc_GhostStructToNativeStruct");
            //Representa as posições do CUBO FANTASMA
            List <BasicStructs.Point> ghostCube = new List <BasicStructs.Point>();

            //Path do local de execução do executável
            string path = System.Environment.CurrentDirectory;
            ExtendedStreamReader ghostCubeFile = new ExtendedStreamReader(path + @"\cuboFantasma.dat", new Guid(), false);
            //Carrega CUBO FANTASMA
            string line = string.Empty;

            while ((line = ghostCubeFile.ReadLine()) != null)
            {
                string[] data = line.Split('\t');                           //separa informações através do caracter TAB
                data = data.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //limpa eventuais espaços em branco

                BasicStructs.Point temp = new BasicStructs.Point();
                temp.x = Convert.ToInt16(data[0]);
                temp.y = Convert.ToInt16(data[1]);
                temp.z = Convert.ToInt16(data[2]);
                ghostCube.Add(temp);
            }
            ghostCubeFile.Close();

            int        cordX      = 0;
            int        cordY      = 0;
            int        cordZ      = 0;
            List <int> newSequece = new List <int>();

            Console.WriteLine("De: ");
            //Motor de busca, ele retorna posição do INDICE da lista, em relação a condição de busca
            ExtendedStreamReader structOfSimulation = new ExtendedStreamReader(path + @"\00003.dat", new Guid(), false);

            //Carrega ESTRUTURA SIMULADA
            line = string.Empty;
            while ((line = structOfSimulation.ReadLine()) != null)
            {
                string[] data = line.Split('\t');                           //separa informações através do caracter TAB
                data = data.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //limpa eventuais espaços em branco

                cordX = Convert.ToInt16(data[0]);
                cordY = Convert.ToInt16(data[1]);
                cordZ = Convert.ToInt16(data[2]);

                newSequece.Add(ghostCube.FindIndex(coord => coord.x == cordX && coord.y == cordY && coord.z == cordZ) + 1);

                Console.WriteLine("{0} {1} {2}", cordX, cordY, cordZ);
            }

            //Print a RESULTADO DA CONFIGURACAO
            Console.Write("Para: ");
            foreach (int item in newSequece)
            {
                Console.Write("{0} ", item);
            }
            Console.WriteLine();

            return(newSequece);
        }
Example #3
0
        public ConfigIntegrator(Param param, bool filesMoved)
        {
            this.param          = param;
            this.totalSitio     = param.dataToProcess.totalSitio;
            this.MCSteps        = param.dataToProcess.maxInterations * totalSitio * 5;
            this.valueDivResult = param.dataToResults.valueDivResult;
            this.valueDiscard   = param.dataToResults.valueDiscard;
            this.maxInterations = param.dataToProcess.maxInterations;

            this.dirBaseServer = new ExtendedDirectoryInfo(DirBaseService.GetDirBaseService().dirBaseServer);
            this.dirBaseWeb    = new ExtendedDirectoryInfo(DirBaseService.GetDirBaseService().dirBaseWeb);

            if (!filesMoved)
            {
                this.movimentsOccurred = ExtendedStreamReader.LinesOfFile(dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Debug\Debug.dat");
            }
            else
            {
                this.movimentsOccurred = ExtendedStreamReader.LinesOfFile(dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Debug.dat");
            }

            this.delta = (movimentsOccurred - valueDiscard) / valueDivResult;

            this.mcSteps = param.dataToProcess.maxInterations * 5 * param.dataToProcess.totalSitio;
        }
Example #4
0
        public static List <BasicStructs.Point> DoNativeStructToGhostStruct(List <int> nativeStruct)
        {
            //Representa a estrutura do CUBO FANTASMA
            List <BasicStructs.Point> ghostCube = new List <BasicStructs.Point>();

            //Representa qual linha foi escolhida, no arquivo de configuração
            int[] seqToMakeNewStruct = new int[27];
            //Representa a nova estrutura a ser gerada
            List <BasicStructs.Point> newStruct = new List <BasicStructs.Point>();

            //Path do local de execução do executável
            string path = System.Environment.CurrentDirectory;
            ExtendedStreamReader ghostCubeFile = new ExtendedStreamReader(path + @"\cuboFantasma.dat", new Guid(), false);


            //Leitura das COORDENADAS BASICAS para os 27 monomeros(coordenadas estabelecidas arbitrariamente, mas fixas)
            string line = string.Empty;

            while ((line = ghostCubeFile.ReadLine()) != null)
            {
                string[] data = line.Split('\t');                           //separa informações através do caracter TAB
                data = data.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //limpa eventuais espaços em branco

                BasicStructs.Point temp = new BasicStructs.Point();
                temp.x = Convert.ToInt16(data[0]);
                temp.y = Convert.ToInt16(data[1]);
                temp.z = Convert.ToInt16(data[2]);
                ghostCube.Add(temp);
            }
            ghostCubeFile.Close();

            //Gera mapeamento da nova estrutura
            int ik = 0;

            foreach (int item in nativeStruct)
            {
                seqToMakeNewStruct[ik] = item;
                ik++;
            }

            //Guardar as coordenadas para cada monomero da ie configuracao desejada
            for (int ipos = 0; ipos < 27; ipos++)
            {
                BasicStructs.Point temp = new BasicStructs.Point();

                int imon = seqToMakeNewStruct[ipos] - 1;
                temp.x = ghostCube[imon].x;
                temp.y = ghostCube[imon].y;
                temp.z = ghostCube[imon].z;

                newStruct.Add(temp);
            }

            return(newStruct);
        }
Example #5
0
        //static string Server = "Server";
        //static string Web = "Web";

        private void DecrypAllFiles(string[] diretories, string destination)
        {
            foreach (string path in diretories)
            {
                //string newWebFolder = path.Replace(Server, Web);
                Directory.CreateDirIfNotExist(destination);

                foreach (string tempFile in Directory.GetFilesOfDir(path))
                {
                    string newWebFile = string.Empty;

                    //newWebFile = tempFile.Replace(Server, Web);
                    newWebFile = destination + Path.GetFileName(tempFile);

                    string extensionFile = Path.GetExtension(tempFile);

                    if (extensionFile == ".xls")
                    {
                        File.Copy(tempFile, newWebFile, true);
                    }
                    else
                    {
                        if (param.dataToProcess.crypt)
                        {
                            //DADOS
                            string line;
                            using (ExtendedStreamReader fileReader = new ExtendedStreamReader(tempFile, this.param.dataToProcess.Guid, AppConfigClient.Crypt))
                            {
                                ExtendedStreamWriter fileWriter = new ExtendedStreamWriter(newWebFile, false, this.param.dataToProcess.Guid, false);
                                while ((line = fileReader.ReadLine()) != null)
                                {
                                    if (String.IsNullOrEmpty(line))
                                    {
                                        break;
                                    }

                                    fileWriter.WriteLine(line);
                                }
                                fileReader.Close();
                                //fileReader = null;
                                fileWriter.Flush();
                                fileWriter.Close();
                                fileWriter = null;
                                fileReader.Dispose();
                            }
                            //FIM DADOS
                        }
                        else
                        {
                            File.Copy(tempFile, newWebFile, true);
                        }
                    }
                }
            }
        }
        private void SheetDebug(ref XLWorkbook workbook)
        {
            string sheetName   = "debug";
            var    worksheet01 = workbook.Worksheets.Add(sheetName);

            //DADOS
            string line;
            int    numberofLines = ExtendedStreamReader.LinesOfFile(dirServerDebug + @"\" + debugFile);

            //List<string> lines = new List<string>();
            using (ExtendedStreamReader file = new ExtendedStreamReader(dirServerDebug + @"\" + debugFile, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
            {
                int rec = 0;
                int idx = 0;

                while ((line = file.ReadLine()) != null)
                {
                    if (!(idx < 1048576))
                    {
                        break;
                    }

                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    WriteSecondSheet(line, idx, ref worksheet01);
                    idx++;

                    if (rec == 99999)
                    {
                        SaveDebug(ref workbook);
                        //http://stackoverflow.com/questions/22747360/append-to-excel-file-with-closedxml
                        //int NumberOfLastRow = worksheet01.LastRowUsed().RowNumber();
                        //IXLCell CellForNewData = worksheet01.Cell(NumberOfLastRow + 1, 1);
                        rec = 0;

                        PrintPercentCompleted(idx, numberofLines);
                    }
                    else
                    {
                        rec++;
                    }
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS
        }
        private void SheetConfiguration(ref XLWorkbook workbook)
        {
            string sheetName     = "Configuration";
            string configuration = "Configuration.dat";

            var worksheet01 = workbook.Worksheets.Add(sheetName);


            //DADOS
            string               line;
            List <string>        lines = new List <string>();
            ExtendedStreamReader file  = new ExtendedStreamReader(dirWebExcel + @"\" + configuration, this.param.dataToProcess.Guid, false);

            while ((line = file.ReadLine()) != null)
            {
                if (String.IsNullOrEmpty(line))
                {
                    break;
                }

                lines.Add(line);
            }
            file.Close();
            //FIM DADOS

            //HEADER
            worksheet01.Cell("A1").Value = sheetName;


            //INFOS
            string value   = string.Empty;
            string refCell = string.Empty;

            for (int i = 0; i < lines.Count; i++)
            {
                string[] cols = lines[i].Split('\t');

                for (int j = 0; j < cols.Length; j++)
                {
                    value = Convert.ToString(cols[j]);
                    //refCell = ((char)(65 + j)).ToString();
                    refCell = ExcelColumnFromNumber(j + 1) + (i + 2);
                    worksheet01.Cell(refCell).Value = value;
                }
            }

            lines = null;
            //FIM DATASHEET
        }
Example #8
0
        public static List <int> DoGhostStructToNativeStruct(List <BasicStructs.Point> trajectoryToStruct, string nameFileGhostCube)
        {
            //Representa as posições do CUBO FANTASMA
            List <BasicStructs.Point> ghostCube = new List <BasicStructs.Point>();

            //Path do local de execução do executável
            string path = System.Environment.CurrentDirectory;
            ExtendedStreamReader ghostCubeFile = new ExtendedStreamReader(path + @"\" + nameFileGhostCube, new Guid(), false);
            //Carrega CUBO FANTASMA
            string line = string.Empty;

            while ((line = ghostCubeFile.ReadLine()) != null)
            {
                string[] data = line.Split('\t');                           //separa informações através do caracter TAB
                data = data.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //limpa eventuais espaços em branco

                BasicStructs.Point temp = new BasicStructs.Point();
                temp.x = Convert.ToInt16(data[0]);
                temp.y = Convert.ToInt16(data[1]);
                temp.z = Convert.ToInt16(data[2]);
                ghostCube.Add(temp);
            }
            ghostCubeFile.Close();

            int        cordX      = 0;
            int        cordY      = 0;
            int        cordZ      = 0;
            List <int> newSequece = new List <int>();

            //Carrega ESTRUTURA SIMULADA
            foreach (BasicStructs.Point item in trajectoryToStruct)
            {
                cordX = Convert.ToInt16(item.x);
                cordY = Convert.ToInt16(item.y);
                cordZ = Convert.ToInt16(item.z);

                newSequece.Add(ghostCube.FindIndex(coord => coord.x == cordX && coord.y == cordY && coord.z == cordZ) + 1);
            }

            return(newSequece);
        }
Example #9
0
        public static List <Point> CreateTarget(string strucFull)
        {
            string[] struc = strucFull.Split(' ');                        //Quebra a linha em posições na array atravéz do espaço
            struc = struc.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //Remove os espaços em branco, deixa estrutura somente com posições válidas

            if (coord.Count == 0)
            {
                //Lê o arquivo sample de geração das coordenadas
                string line;

                string path = System.Environment.CurrentDirectory;
                ExtendedStreamReader fileReader = new ExtendedStreamReader(path + @"\coord" + Directory.FileExtension, new Guid(), false);
                while ((line = fileReader.ReadLine()) != null)
                {
                    string[] tempFile = line.Split(' ');
                    tempFile = tempFile.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                    coord.Add(new Point()
                    {
                        x = Convert.ToInt16(tempFile[0]), y = Convert.ToInt16(tempFile[1]), z = Convert.ToInt16(tempFile[2])
                    });
                }
                fileReader.Close();
            }

            //Incrimento inicial das posições do cubo x,y,z
            List <Point> points = new List <Point>(); //Uma lista encadeada do tipo PointCube

            for (int i = 0; i < coord.Count(); i++)
            {
                int   pos   = Convert.ToInt16(struc[i]) - 1;
                Point point = new Point()
                {
                    x = coord[pos].x, y = coord[pos].y, z = coord[pos].z
                };
                points.Add(point);

                //Console.WriteLine("{0},{1},{2}", points[i].x, points[i].y, points[i].z);
            }

            return(points);
        }
Example #10
0
        /// <summary>
        /// Carrega as coordenadas geradas da SEMENTE
        /// </summary>
        public static void LoadSeedCoord(string file, bool firstLineIsIsemNUmber)
        {
            //string dir = Members.workSpace + @"\" + Resource.SubDirSeed;
            //string pathFile = dir + @"\" + file + Consts.extensionOfFile;

            using (ExtendedStreamReader sr = new ExtendedStreamReader(file, Config.CurrentGuid, true))
            {
                string   line = string.Empty;
                string[] temp = new string[3];

                GCPS.Reset();

                bool first = true;
                while ((line = sr.ReadLine()) != null)
                {
                    if (first && firstLineIsIsemNUmber)
                    {
                        GCPS.chain.isem = Convert.ToInt32(line);
                        first           = false;
                    }
                    else
                    {
                        temp = Regex.Split(line, "\t"); //temp = line.Split(new char[] { '\t' });

                        GCPS.chain.r.Add(new BasicStructs.Point()
                        {
                            x             = Convert.ToInt32(temp[0]),
                            y             = Convert.ToInt32(temp[1]),
                            z             = Convert.ToInt32(temp[2]),
                            deadEnd       = 0,
                            deadEndPoints = string.Empty
                        });
                    }
                }

                sr.Close();
                sr.Dispose();
            }
        }
Example #11
0
        public static List <BasicStructs.Point> DoPoc_NativeStructToGhostStruct()
        {
            Console.WriteLine("DoPoc_NativeStructToGhostStruct");
            //Representa a estrutura do CUBO FANTASMA
            List <BasicStructs.Point> ghostCube = new List <BasicStructs.Point>();

            //Representa qual linha foi escolhida, no arquivo de configuração
            int[] seqToMakeNewStruct = new int[27];
            //Representa a nova estrutura a ser gerada
            List <BasicStructs.Point> newStruct = new List <BasicStructs.Point>();

            // Observações:
            //cfg51704.dat :  arquivo da sequencia posicional dos 27 monomeros
            //cuboFantasma.dat    :  coordenadas(x, y, z) dos 27 vértices do cubo 3X3X3

            //Path do local de execução do executável
            string path = System.Environment.CurrentDirectory;
            ExtendedStreamReader ghostCubeFile = new ExtendedStreamReader(path + @"\cuboFantasma.dat", new Guid(), false);


            //Leitura das COORDENADAS BASICAS para os 27 monomeros(coordenadas estabelecidas arbitrariamente, mas fixas)
            string line = string.Empty;

            while ((line = ghostCubeFile.ReadLine()) != null)
            {
                string[] data = line.Split('\t');                           //separa informações através do caracter TAB
                data = data.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //limpa eventuais espaços em branco

                BasicStructs.Point temp = new BasicStructs.Point();
                temp.x = Convert.ToInt16(data[0]);
                temp.y = Convert.ToInt16(data[1]);
                temp.z = Convert.ToInt16(data[2]);
                ghostCube.Add(temp);
            }
            ghostCubeFile.Close();

            //ID da estrutura a ser gerada
            int idOfConfig = 3; //equivale arquivo 00003.dat

            //Le a linha da estrutura escolhida
            string[] selectedLine = new string[27];
            selectedLine = System.IO.File.ReadLines(path + @"\cfg51704.dat").Skip(idOfConfig - 1).Take(1).First().Split(' '); //Lê linha escolhida diretamente do arquivo
            selectedLine = selectedLine.Where(x => !string.IsNullOrEmpty(x)).ToArray();                                       //limpa eventuais espaços em branco


            Console.Write("De: ");
            for (int i = 0; i < selectedLine.Count(); i++)
            {
                Console.Write("{0} ", selectedLine[i]);
            }
            Console.WriteLine();

            //Gera mapeamento da nova estrutura
            int ik = 0;

            foreach (string item in selectedLine)
            {
                seqToMakeNewStruct[ik] = Convert.ToInt16(item);
                ik++;
            }

            //Guardar as coordenadas para cada monomero da ie configuracao desejada
            for (int ipos = 0; ipos < 27; ipos++)
            {
                BasicStructs.Point temp = new BasicStructs.Point();

                int imon = seqToMakeNewStruct[ipos] - 1;
                temp.x = ghostCube[imon].x;
                temp.y = ghostCube[imon].y;
                temp.z = ghostCube[imon].z;

                newStruct.Add(temp);
            }

            Console.WriteLine("Para: ");
            //Print a nova ESTRUTURA
            for (int ipos = 0; ipos < 27; ipos++)
            {
                Console.WriteLine("{0} {1} {2}", newStruct[ipos].x, newStruct[ipos].y, newStruct[ipos].z);
            }

            return(newStruct);
        }
Example #12
0
        public void Distribution()
        {
            try
            {
                string readerFile = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Debug.dat";
                string writerFile = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Distribution.dat";

                Guid guid   = param.dataToProcess.Guid;
                int  isem   = param.dataToProcess.isem;
                int  sitios = param.dataToProcess.totalSitio;

                //Data
                string line;
                List <ColsForDepedentModel> md = new List <ColsForDepedentModel>();

                using (ExtendedStreamReader souceFile = new ExtendedStreamReader(readerFile,
                                                                                 this.param.dataToProcess.Guid, false))
                {
                    ExtendedStreamWriter destinationFile = new ExtendedStreamWriter(writerFile, false,
                                                                                    this.param.dataToProcess.Guid, false);

                    string[] cols = null;
                    int      i    = 0;

                    while ((line = souceFile.ReadLine()) != null)
                    {
                        if (String.IsNullOrEmpty(line))
                        {
                            break;
                        }

                        //pulas cabeçalho &  faz o discarte o número de discartes
                        if (i == 0)
                        {
                            for (int k = 0; k < this.valueDiscard; k++)
                            {
                                line = souceFile.ReadLine();
                            }
                        }
                        else
                        {
                            cols = line.Split('\t').ToArray();
                            Int32  _mcSteps = Convert.ToInt32(cols[0]);
                            double _rg      = Convert.ToDouble(cols[3]);
                            double _e       = Convert.ToDouble(cols[2]);
                            double _U       = Convert.ToDouble(cols[8]);

                            md.Add(new ColsForDepedentModel()
                            {
                                mcSteps = _mcSteps, rg = _rg, e = _e, U = _U
                            });

                            //pula o Delta
                            for (int k = 0; k < this.delta; k++)
                            {
                                line = souceFile.ReadLine();
                            }
                        }

                        i++;
                    }

                    souceFile.Close();
                    //souceFile = null;



                    //Write result file
                    destinationFile.WriteLine("simulation id: {0}", guid.ToString());
                    destinationFile.WriteLine("isem: {0}", isem);
                    destinationFile.WriteLine("sitios: {0}", sitios);
                    destinationFile.WriteLine("model: {0}", TranslateModel(param.dataToProcess.modelType));
                    destinationFile.WriteLine("mcStep: {0}", this.mcSteps);
                    destinationFile.WriteLine("temperature: {0}", param.dataToProcess.temperature);
                    destinationFile.WriteLine("valueDiscard: {0}", this.valueDiscard);
                    destinationFile.WriteLine("delta: {0}", this.delta);

                    destinationFile.WriteLine("idx\t mcSteps\t rg2\t rg2(accumulated)\t <rg2>\t e\t e(accumulated)\t <e>\t U\t U(accumulated)\t <U>");

                    double aRG2, eRG2, previousRG2, actualRG2;
                    aRG2 = eRG2 = previousRG2 = actualRG2 = 0;
                    double aE, eE, previousE, actualE;
                    aE = eE = previousE = actualE = 0;
                    double aU, eU, previousU, actualU;
                    aU = eU = previousU = actualU = 0;

                    Int64 idx = 0;

                    for (int z = 0; z < md.Count(); z++)
                    {
                        idx = (z + 1);

                        //Acumulado
                        aRG2 += md[z].rg;
                        aE   += md[z].e;
                        aU   += md[z].U;

                        //Evolução do RAIO DE GIRAÇÃO
                        actualRG2   = md[z].rg;
                        eRG2        = aRG2 / idx;
                        previousRG2 = eRG2;

                        //Evolução do E
                        actualE   = md[z].e;
                        eE        = aE / idx;
                        previousE = eE;

                        //Evolução do U
                        actualU   = md[z].U;
                        eU        = aU / idx;
                        previousE = eU;


                        destinationFile.WriteLine(z + "\t" + md[z].mcSteps + "\t" + actualRG2 + "\t" + aRG2 + "\t" + eRG2 + "\t" + actualE + "\t" + aE + "\t" + eE + "\t" + actualU + "\t" + aU + "\t" + eU);
                    }

                    destinationFile.Flush();
                    destinationFile.Close();
                    souceFile.Dispose();
                }
            }
            catch (Exception ex)
            {
                GICO.WriteLine(ex);
                throw;
            }
        }
Example #13
0
        public static List <Structs.BasicStructs.Point> CreateTarget(List <TargetsCoordinates> lstTargetsCoordinates)
        {
            //Efetua a leitura do modelo da "Sequência X"
            string strucFull = string.Empty; // "1  2  3  6  5  4  7  8  9 18 17 16 13 10 11 12 15 14 23 20 21 24 27 26 25 22 19";

            //string[] struc = strucFull.Split(' '); //Quebra a linha em posições na array atravéz do espaço
            //struc = struc.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //Remove os espaços em branco, deixa estrutura somente com posições válidas

            string[] struc = new string[lstTargetsCoordinates.Count];
            int      j     = 0;

            foreach (TargetsCoordinates item in lstTargetsCoordinates)
            {
                struc[j++] = item.value.ToString();
            }


            //Lê o arquivo sample de geração das coordenadas
            string line;
            List <Structs.BasicStructs.Point> coord = new List <Structs.BasicStructs.Point>();

            ExtendedStreamReader file = new ExtendedStreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\coord" + Directory.FileExtension, Config.CurrentGuid, false);

            while ((line = file.ReadLine()) != null)
            {
                string[] temp = line.Split(' ');
                temp = temp.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                coord.Add(new Structs.BasicStructs.Point()
                {
                    x = Convert.ToInt16(temp[0]), y = Convert.ToInt16(temp[1]), z = Convert.ToInt16(temp[2])
                });
            }
            file.Close();


            //Incrimento inicial das posições do cubo x,y,z
            List <Point> points = new List <Point>(); //Uma lista encadeada do tipo PointCube

            for (int i = 0; i < coord.Count(); i++)
            {
                int   pos   = Convert.ToInt16(struc[i]) - 1;
                Point point = new Point()
                {
                    x = coord[pos].x, y = coord[pos].y, z = coord[pos].z
                };
                points.Add(point);

                GICO.WriteLine(Config.CurrentGuid, String.Format("{0},{1},{2}", points[i].x, points[i].y, points[i].z));
            }

            //Cria um cadeia de simulação
            GCPS.chain = new Structs.BasicStructs.Chain();
            foreach (Point item in points)
            {
                GCPS.chain.r.Add(new Structs.BasicStructs.Point()
                {
                    x             = item.x,
                    y             = item.y,
                    z             = item.z,
                    deadEnd       = 0,
                    deadEndPoints = string.Empty,
                    neighbors     = new Structs.BasicStructs.Neighbor[6],
                    e             = new List <TypeE>()
                });
            }

            return(GCPS.chain.r);
        }
        private void SheetEvolutionValueMediumOfEnergy(ref XLWorkbook workbook)
        {
            string sheetName            = "Evolution Energy";
            string mediumValuesOfEnergy = "EvolutionEnergy.dat";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            //DADOS
            string        line;
            List <string> lines = new List <string>();

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirWebExcel + @"\" + mediumValuesOfEnergy, this.param.dataToProcess.Guid, false))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    lines.Add(line);
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS

            //HEADER
            worksheet01.Cell("A1").Value = sheetName;

            //INFOS
            string comment = string.Empty;
            double value   = 0;
            int    i       = 0;

            for (i = 0; i < 5; i++)
            {
                string[] temp = lines[i].Split(':');
                comment = Convert.ToString(temp[0]);
                worksheet01.Cell("A" + (i + 2)).Value = comment;

                try
                {
                    value = Convert.ToDouble(temp[1]);
                    worksheet01.Cell("B" + (i + 2)).Value = value;
                }
                catch
                {
                    string valueStr = temp[1];
                    worksheet01.Cell("B" + (i + 2)).Value = valueStr;
                }
            }

            //DATA
            worksheet01.Cell("A7").Value = "idx";
            worksheet01.Cell("B7").Value = "MCStep";
            worksheet01.Cell("C7").Value = "E";

            long   mcstep = 0;
            double e      = 0;
            long   idx    = 0;

            i++; //para pular HEADER do arquivo que já foi escrito acima (LINHA 7 do EXCEL)
            for (i = i; i < lines.Count; i++)
            {
                string[] temp = lines[i].Split('\t');
                idx    = Convert.ToInt32(temp[0]);
                mcstep = Convert.ToInt32(temp[1]);
                e      = Convert.ToDouble(temp[2]);

                worksheet01.Cell("A" + (i + 2)).Value = idx;
                worksheet01.Cell("B" + (i + 2)).Value = mcstep;
                worksheet01.Cell("C" + (i + 2)).Value = e;
            }

            lines = null;
            //FIM DATASHEET
        }
Example #15
0
        public void LoadConfigurationOutPutForOrigin()
        {
            GICO.WriteLine(String.Format("  Output: LoadConfigurationOutPutToOrigin: Delete..."));
            ////Delete IF EXIST
            //using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            //{
            //    ctx.Database.ExecuteSqlCommand("DELETE FROM OUTPUT WHERE guid= {0}", param.dataToProcess.Guid);
            //}

            string readerFile = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Configuration.dat";

            using (ExtendedStreamReader souceFile = new ExtendedStreamReader(readerFile,
                                                                             this.param.dataToProcess.Guid, false))
            {
                string line;
                int    i = 0;


                GICO.WriteLine(String.Format("  Output: LoadConfigurationOutPutToOrigin: Insert..."));
                while ((line = souceFile.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    //pulas cabeçalho e o número de discartes
                    if (i == 0)
                    {
                        line = souceFile.ReadLine();
                    }

                    string[] data   = line.Split('\t').ToArray();
                    Int32    mcStep = 0;
                    int      order  = 0;
                    int      count  = 0;

                    using (TransactionScope scope = new TransactionScope())
                    {
                        GridProteinFoldingEntities ctx = null;

                        try
                        {
                            ctx = new GridProteinFoldingEntities();
                            Entities.Internal.Configuration configuration = null;

                            for (int j = 0; j < data.Length; j++)
                            {
                                if (j == 0)
                                {
                                    mcStep = Convert.ToInt32(data[j]); j++;
                                }

                                configuration = new Entities.Internal.Configuration();

                                configuration.process_guid = this.param.dataToProcess.Guid;
                                configuration.mcStep       = mcStep;
                                configuration.order        = order;
                                configuration.x            = Convert.ToInt32(data[j]); j++;
                                configuration.y            = Convert.ToInt32(data[j]); j++;
                                configuration.z            = Convert.ToInt32(data[j]);

                                order++;

                                ++count;
                                ctx = AddToContext(ctx, configuration, count, 100, true);
                                //ctx.Configuration.Add(configuration);
                            }

                            if (configuration != null)
                            {
                                ctx.SaveChanges();
                                configuration = null;
                            }
                        }
                        finally
                        {
                            if (ctx != null)
                            {
                                ctx.Dispose();
                            }
                        }
                        scope.Complete();
                    }
                    i++;
                }


                souceFile.Close();
                //souceFile = null;
                souceFile.Dispose();
            }
        }
        private void SheetTrajectory(ref XLWorkbook workbook)
        {
            // This is invariant
            NumberFormatInfo format = new NumberFormatInfo();

            // Set the 'splitter' for thousands
            format.NumberGroupSeparator = ".";
            // Set the decimal seperator
            format.NumberDecimalSeparator = ",";

            string sheetName = "Trajectory";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            int numberLines = ExtendedStreamReader.LinesOfFile(dirServerDebug + @"\" + debugFile);

            //DADOS
            string            line;
            List <Trajectory> trajectory = new List <Trajectory>();
            int _MCStep = 0;

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirServerDebug + @"\" + debugFile, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
            {
                double rg = 0;   //Calculo acumulado do Raio de GIração

                int cont = 0;    //Contador
                                 //int lastMove = 0; //valor do último movimento
                int contAdd = 1; //contador adicional



                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (cont > 0)
                    {
                        string[] col = line.Split('\t');

                        int numberMov = ConvertCustom.ToInt32(col[0]);

                        if (numberMov < (delta * contAdd) + 1)
                        {
                            rg     += double.Parse(col[3], format); //coluna no qual contêm valor do raio de giração
                            _MCStep = ConvertCustom.ToInt32(col[0]);
                        }
                        else
                        {
                            double value = ((double)1 / delta) * rg;
                            trajectory.Add(new Trajectory()
                            {
                                MCStep = _MCStep, rg = value
                            });
                            contAdd++;
                            rg  = 0;
                            rg += Convert.ToDouble(col[3]); //coluna no qual contêm valor do raio de giração
                        }
                    }

                    cont++;
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS


            //DATASHEET
            worksheet01.Cell("A1").Value = sheetName;

            worksheet01.Cell("A2").Value = "lines";
            worksheet01.Cell("B2").Value = numberLines;

            worksheet01.Cell("A3").Value = "MCSteps";
            worksheet01.Cell("B3").Value = MCSteps;

            worksheet01.Cell("A4").Value = "delta";
            worksheet01.Cell("B4").Value = delta;

            worksheet01.Cell("A5").Value = "idx";
            worksheet01.Cell("B5").Value = "MCSteps";
            worksheet01.Cell("C5").Value = "SUM((1 / delta) * md)";

            for (int i = 0; i < trajectory.Count; i++)
            {
                double value = trajectory[i].rg;
                _MCStep = trajectory[i].MCStep;
                worksheet01.Cell("A" + (i + 6)).Value = i;
                worksheet01.Cell("B" + (i + 6)).Value = _MCStep;
                worksheet01.Cell("C" + (i + 6)).Value = value;
            }
        }
        private void SheetsHistogram(ref XLWorkbook workbook)
        {
            string sheetName = string.Empty;

            //Recupera a quantidade de arquivos existentes
            string[] dir = Directory.GetFiles(dirServerHistogram);

            if (dir.Count() > 0)
            {
                foreach (string file in dir)
                {
                    int posBar = file.LastIndexOf(@"\", StringComparison.Ordinal);
                    int len    = file.Count();

                    string fileName = file.Substring(posBar, len - posBar).Replace(@"\", "");

                    switch (fileName)
                    {
                    case "fileRealHistogramEndToEndDistance.dat":
                        sheetName = "EndToEnd distance";
                        break;

                    case "fileRealHistogramRadiuosOfGyration.dat":
                        sheetName = "Radiuos of gyration";
                        break;

                    default:
                        sheetName = file;
                        break;
                    }

                    var worksheet01 = workbook.Worksheets.Add(sheetName);

                    //DADOS
                    string        line;
                    List <string> lines = new List <string>();
                    using (ExtendedStreamReader stream = new ExtendedStreamReader(dirServerHistogram + @"\" + fileName, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
                    {
                        while ((line = stream.ReadLine()) != null)
                        {
                            if (String.IsNullOrEmpty(line))
                            {
                                break;
                            }

                            lines.Add(line);
                        }
                        stream.Close();

                        stream.Dispose();
                    }
                    //FIM DADOS

                    //DATASHEET
                    for (int i = 0; i < lines.Count; i++)
                    {
                        string[] values = lines[i].Split('\t');

                        for (int j = 0; j < values.Count(); j++)
                        {
                            worksheet01.Cell(Convert.ToChar(65 + j).ToString() + (i + 1)).Value = values[j];
                        }
                    }

                    lines = null;
                    //FIM DATASHEET
                }
            }
        }
Example #18
0
        public void ConfigurationOutPut()
        {
            string[] files = Directory.GetFilesOfDir(dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result", "Trajectory*.dat");
            Array.Sort <string>(files);
            Array.Reverse(files);
            string readerLastFile = files[0];

            Array.Sort <string>(files);

            //Data
            string        line;
            List <string> configurations = new List <string>();

            //FILEs - lê arquivo por arquivo efetuando o SALTO de MCTSP efetuado
            string readerFirstFile = string.Empty;

            ExtendedStreamReader souceFirstFile;
            int i = 0;

            for (int numberOfFile = 0; numberOfFile < files.Length; numberOfFile++)
            {
                readerFirstFile = files[numberOfFile];
                using (souceFirstFile = new ExtendedStreamReader(readerFirstFile,
                                                                 this.param.dataToProcess.Guid, false))
                {
                    bool readHeader = false;

                    while ((line = souceFirstFile.ReadLine()) != null)
                    {
                        if (String.IsNullOrEmpty(line))
                        {
                            break;
                        }

                        //cabeçalho do primeiro arquivo
                        if (!readHeader)
                        {
                            configurations.Add(line);
                            readHeader = true;
                            line       = souceFirstFile.ReadLine();
                        }

                        if (i == 0)
                        {
                            //for (int k = 0; k < this.valueDiscard; k++)
                            //{
                            //    line = souceFirstFile.ReadLine();
                            //}
                            configurations.Add(line);
                        }
                        else
                        {
                            //if (i == param.output.configurationJumpStep)
                            //{
                            //    i = 0;
                            configurations.Add(line);
                            //}
                        }
                        i++;
                    }
                    souceFirstFile.Close();

                    souceFirstFile.Dispose();
                }
            }

            //LAST FILE
            string writerConfigurationFile       = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Configuration.dat";
            ExtendedStreamWriter destinationFile = new ExtendedStreamWriter(writerConfigurationFile, false,
                                                                            this.param.dataToProcess.Guid, false);

            line = string.Empty;
            string last = File.ReadLastLineOfFile(readerLastFile);

            configurations.Add(last);



            souceFirstFile = null;

            //Write result file
            foreach (string data in configurations)
            {
                destinationFile.WriteLine(data);
            }

            destinationFile.Flush();
            destinationFile.Close();

            //Após consolidar arquivo de CONFIGURATION.DAT, os arquivos de TRAJETORY* devem ser descartados
            foreach (string file in files)
            {
                File.Delete(file);
            }
        }
        private void SheetDistribution(ref XLWorkbook workbook)
        {
            // This is invariant
            NumberFormatInfo format = new NumberFormatInfo();

            // Set the 'splitter' for thousands
            format.NumberGroupSeparator = ".";
            // Set the decimal seperator
            format.NumberDecimalSeparator = ",";

            string sheetName = "Distribution";
            string fileName  = "Distribution.dat";
            string mask      = "";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            //DADOS
            string        line;
            List <string> lines = new List <string>();

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirWebExcel + @"\" + fileName, this.param.dataToProcess.Guid, false))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    lines.Add(line);
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS

            //HEADER
            worksheet01.Cell("A1").Value = sheetName;
            worksheet01.Cell("B1").Value = mask;
            worksheet01.Cell("C1").Value = mask;
            worksheet01.Cell("D1").Value = "idx";
            worksheet01.Cell("E1").Value = "mcStep";
            worksheet01.Cell("F1").Value = "rg2";
            worksheet01.Cell("G1").Value = "rg2(accumulated)";
            worksheet01.Cell("H1").Value = "<rg2>";
            worksheet01.Cell("I1").Value = "e";
            worksheet01.Cell("J1").Value = "e(accumulated)";
            worksheet01.Cell("K1").Value = "<e>";
            worksheet01.Cell("L1").Value = "U";
            worksheet01.Cell("M1").Value = "U(accumulated)";
            worksheet01.Cell("N1").Value = "<U>";

            //INFOS
            string comment = string.Empty;
            double value   = 0;
            int    i       = 0;

            //DATA
            long   idx, mcstep = 0;
            double rg, U, eE, eRG, eU, e, aE, aU, aRG;

            rg = U = eE = eRG = eU = e = aE = aU = aRG = 0;

            //PRIMEIRA PARTE COM HEADER
            for (i = 0; i < 8; i++)
            {
                string[] temp = lines[i].Split(':');
                comment = ConvertCustom.ToString(temp[0]);
                worksheet01.Cell("A" + (i + 2)).Value = comment;

                try
                {
                    value = ConvertCustom.ToDouble(temp[1]);
                    worksheet01.Cell("B" + (i + 2)).Value = value;
                }
                catch (FormatException)
                {
                    string strValue = Convert.ToString(temp[1]);
                    worksheet01.Cell("B" + (i + 2)).Value = strValue;
                }


                string[] tempResult = lines[i + 9].Split('\t');
                idx    = ConvertCustom.ToInt32(tempResult[0]);
                mcstep = ConvertCustom.ToInt32(tempResult[1]);

                rg  = double.Parse(tempResult[2], format);
                aRG = double.Parse(tempResult[3], format);
                eRG = double.Parse(tempResult[4], format);

                e  = double.Parse(tempResult[5], format);
                aE = double.Parse(tempResult[6], format);
                eE = double.Parse(tempResult[7], format);

                U  = double.Parse(tempResult[8], format);
                aU = double.Parse(tempResult[9], format);
                eU = double.Parse(tempResult[10], format);

                worksheet01.Cell("C" + (i + 2)).Value = mask;
                worksheet01.Cell("D" + (i + 2)).Value = idx;
                worksheet01.Cell("E" + (i + 2)).Value = mcstep;
                worksheet01.Cell("F" + (i + 2)).Value = rg;
                worksheet01.Cell("G" + (i + 2)).Value = aRG;
                worksheet01.Cell("H" + (i + 2)).Value = eRG;
                worksheet01.Cell("I" + (i + 2)).Value = e;
                worksheet01.Cell("J" + (i + 2)).Value = aE;
                worksheet01.Cell("K" + (i + 2)).Value = eE;
                worksheet01.Cell("L" + (i + 2)).Value = U;
                worksheet01.Cell("M" + (i + 2)).Value = aU;
                worksheet01.Cell("N" + (i + 2)).Value = eU;
            }

            //SEGUNDA PARTE
            for (int j = i; j < (lines.Count() - 9); j++)
            {
                worksheet01.Cell("A" + (j + 2)).Value = mask;
                worksheet01.Cell("B" + (j + 2)).Value = mask;
                worksheet01.Cell("C" + (j + 2)).Value = mask;

                string[] tempResult = lines[j + 9].Split('\t');
                idx    = ConvertCustom.ToInt32(tempResult[0]);
                mcstep = ConvertCustom.ToInt32(tempResult[1]);

                rg  = double.Parse(tempResult[2], format);
                aRG = double.Parse(tempResult[3], format);
                eRG = double.Parse(tempResult[4], format);

                e  = double.Parse(tempResult[5], format);
                aE = double.Parse(tempResult[6], format);
                eE = double.Parse(tempResult[7], format);

                U  = double.Parse(tempResult[8], format);
                aU = double.Parse(tempResult[9], format);
                eU = double.Parse(tempResult[10], format);


                worksheet01.Cell("D" + (j + 2)).Value = idx;
                worksheet01.Cell("E" + (j + 2)).Value = mcstep;
                worksheet01.Cell("F" + (j + 2)).Value = rg;
                worksheet01.Cell("G" + (j + 2)).Value = aRG;
                worksheet01.Cell("H" + (j + 2)).Value = eRG;
                worksheet01.Cell("I" + (j + 2)).Value = e;
                worksheet01.Cell("J" + (j + 2)).Value = aE;
                worksheet01.Cell("K" + (j + 2)).Value = eE;
                worksheet01.Cell("L" + (j + 2)).Value = U;
                worksheet01.Cell("M" + (j + 2)).Value = aU;
                worksheet01.Cell("N" + (j + 2)).Value = eU;
            }
            lines = null;
            //FIM DATASHEET
        }
Example #20
0
        public void EvolutionValueMediumOfEnergy()
        {
            string readerFile = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Debug.dat";
            string writerFile = @dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\EvolutionEnergy.dat";

            //Data
            string line;
            List <ColsForEnergy> energy = new List <ColsForEnergy>();

            using (ExtendedStreamReader souceFile = new ExtendedStreamReader(readerFile,
                                                                             this.param.dataToProcess.Guid, false))
            {
                ExtendedStreamWriter destinationFile = new ExtendedStreamWriter(writerFile, false,
                                                                                this.param.dataToProcess.Guid, false);

                string[] cols = null;
                int      i    = 0;

                while ((line = souceFile.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    //pulas cabeçalho e o número de discartes
                    if (i < 1)
                    {
                        for (int k = 0; k < this.valueDiscard; k++)
                        {
                            line = souceFile.ReadLine();
                        }
                    }
                    else
                    {
                        cols = line.Split('\t').ToArray();

                        Int32  _mcSteps = Convert.ToInt32(cols[0]);
                        double _newE    = Convert.ToDouble(cols[2]);

                        energy.Add(new ColsForEnergy()
                        {
                            mcSteps = _mcSteps, e = _newE
                        });

                        //pula o Delta
                        for (int k = 0; k < this.delta; k++)
                        {
                            line = souceFile.ReadLine();
                        }
                    }

                    i++;
                }

                souceFile.Close();
                //souceFile = null;

                //Write result file
                destinationFile.WriteLine("mcStep: {0}", this.mcSteps);
                destinationFile.WriteLine("valueDiscard: {0}", this.valueDiscard);
                destinationFile.WriteLine("delta: {0}", this.delta);
                destinationFile.WriteLine("temperature: {0}", param.dataToProcess.temperature);
                destinationFile.WriteLine("model: {0}", TranslateModel(param.dataToProcess.modelType));

                destinationFile.WriteLine("idx" + "\t" + "_mcSteps" + "\t" + "energy");
                for (int z = 0; z < energy.Count(); z++)
                {
                    destinationFile.WriteLine(z + "\t" + energy[z].mcSteps + "\t" + energy[z].e);
                }

                destinationFile.Flush();
                destinationFile.Close();
                souceFile.Dispose();
            }
        }