Exemplo n.º 1
0
        private void ThreadLibrary(object o)
        {
            int[] inx = (int [])o;



            if (fragBagLibrary[0].GetLength(0) + inx[2] > res.Count)
            {
                resetEvents[inx[3]].Set();
                return;
            }

            for (int n = 0; n < fragBagLibrary[0].GetLength(0); n++)
            {
                chunk[inx[3]][n, 0] = res[inx[2] + n].Atoms[0].Position.X;
                chunk[inx[3]][n, 1] = res[inx[2] + n].Atoms[0].Position.Y;
                chunk[inx[3]][n, 2] = res[inx[2] + n].Atoms[0].Position.Z;
            }
            Optimization.CenterMol(chunk[inx[3]], center[inx[3]]);

            for (int j = inx[0]; j < inx[1]; j++)
            {
                distData[j] = Optimization.Rmsd(fragBagLibrary[j], chunk[inx[3]], false);
            }

            resetEvents[inx[3]].Set();
        }
Exemplo n.º 2
0
        private void PreparePDBPos()
        {
            //Check if all alignm have the same length
            foreach (var item in pdbs.molDic)
            {
                foreach (var itemIndex in item.Value.indexMol)
                {
                    if (itemIndex == -1)
                    {
                        return;
                    }
                }
            }
            pdbPos = new float[structures.Count][, ];
            for (int i = 0; i < structures.Count; i++)
            {
                pdbPos[i] = new float[pdbs.molDic[structures[0]].indexMol.Length, 3];
            }
            float [] center = new float [3];
            for (int i = 0; i < structures.Count; i++)
            {
                int count = 0;

                for (int j = 0; j < pdbs.molDic[structures[i]].mol.Residues.Count; j++)
                {
                    for (int n = 0; n < pdbs.molDic[structures[i]].mol.Residues[j].Atoms.Count; n++)
                    {
                        pdbPos[i][count, 0]   = pdbs.molDic[structures[i]].mol.Residues[j].Atoms[n].Position.X;
                        pdbPos[i][count, 1]   = pdbs.molDic[structures[i]].mol.Residues[j].Atoms[n].Position.Y;
                        pdbPos[i][count++, 2] = pdbs.molDic[structures[i]].mol.Residues[j].Atoms[n].Position.Z;
                    }
                }

                Optimization.CenterMol(pdbPos[i], center);
            }
        }
Exemplo n.º 3
0
        public void ReadLibrary()
        {
            string[] files;
            string   location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) +
                                Path.DirectorySeparatorChar + "fragLib";

            if (Directory.Exists(location))
            {
                files = Directory.GetFiles(location);
            }
            else
            {
                throw new Exception("Directory fragLib not exists. Profile fragBag cannot be used!");
            }

            fragBagLibrary.Clear();

            string libraryName;

            if (dirSettings.mode == INPUTMODE.PROTEIN)
            {
                libraryName = "fragBagProtein.txt";
            }
            else
            {
                libraryName = "fragBagRNAv2.txt";
            }
            libraryName = location + Path.DirectorySeparatorChar + libraryName;
            if (!File.Exists(libraryName))
            {
                throw new Exception("Cannot find: " + libraryName + " Profile fragBag cannot be used!");
            }

            using (StreamReader s = new StreamReader(libraryName))
            {
                string  line = s.ReadLine();
                float[] cent = new float[3];
                while (line != null)
                {
                    if (line.Contains("----"))
                    {
                        line = s.ReadLine();
                        List <float[]> str = new List <float[]>();
                        while (line != null && !line.Contains("***"))
                        {
                            try
                            {
                                line = line.Trim();
                                line = Regex.Replace(line, @"\s+", " ");
                                string[] aux = line.Split(' ');
                                float[]  p   = new float[3];
                                for (int i = 0; i < 3; i++)
                                {
                                    p[i] = (float)Convert.ToDouble(aux[i], System.Globalization.CultureInfo.InvariantCulture);
                                }

                                str.Add(p);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("Error in frag bag library: " + line);
                            }
                            line = s.ReadLine();
                        }
//                        if (str.Count > 5)
//                            Console.WriteLine("UPS");
                        float[,] auxTab = new float[str.Count, 3];
                        for (int i = 0; i < str.Count; i++)
                        {
                            for (int j = 0; j < str[i].Length; j++)
                            {
                                auxTab[i, j] = str[i][j];
                            }
                        }

                        Optimization.CenterMol(auxTab, cent);
                        fragBagLibrary.Add(auxTab);
                    }
                    line = s.ReadLine();
                }
            }


            if (fragBagLibrary.Count == 0)
            {
                throw new Exception("Frag Bag Library is empty!");
            }
            distData  = new float[fragBagLibrary.Count];
            index     = new int[fragBagLibrary.Count];
            zeroCount = new int[fragBagLibrary.Count];
            profile   = new int[fragBagLibrary.Count];
        }