Exemple #1
0
        private Structure loadStructure(string fileName)
        {
            Structure structure = new Structure();
            int l = fileName.Length;
            structure.PDBCode = fileName.Substring(l-8,4);
                bool flag = false;
                string line = "";
                StreamReader file = new StreamReader(fileName);
                Group g = new Group();
                AminoAcid aa = new AminoAcid();
            while ((line = file.ReadLine()) != null)
            {

                if (line.StartsWith("ATOM"))
                {
                    try{
                        if (flag)
                    {
                        g.groupID = (line.ElementAt(21) - 65);
                        aa.aaID = Convert.ToInt16(line.Substring(22, 4).Trim()); flag = false;
                    }
                    if (aa.aaID != (Convert.ToInt16(line.Substring(22, 4).Trim())))
                    {
                        g.AA.Add(aa);
                        aa = new AminoAcid();
                        aa.aaID = Convert.ToInt16(line.Substring(22, 4).Trim());
                    }
                    if (g.groupID != (line.ElementAt(21) - 65))
                    {
                        structure.Groups.Add(g);
                        g = new Group();
                        g.groupID = (line.ElementAt(21) - 65);
                    }
                    Atom ob = new Atom();

                        ob.setX(Convert.ToDouble(line.Substring(30, 8).Trim()));
                        ob.setY(Convert.ToDouble(line.Substring(38, 8).Trim()));
                        ob.setZ(Convert.ToDouble(line.Substring(46, 8).Trim()));
                        ob.Name = line.Substring(12, 3).Trim();
                        if (ob.Name.Equals("N")) aa.setN(ob);
                        else if (ob.Name.Equals("CA")) aa.setCA(ob);
                        else if (ob.Name.Equals("CB")) aa.setCB(ob);
                        else if (ob.Name.Equals("O")) aa.setO(ob);
                        else if (ob.Name.Equals("C")) aa.setC(ob);
                    }
                    catch (Exception) { }
                }
            }
                    g.AA.Add(aa); structure.Groups.Add(g);

                file.Close();
                count++;
            return structure;
        }
Exemple #2
0
        private void calcPhiPsi(Structure structure,int flag)
        {
            try
            {
                for (int j = 0; j < structure.Groups.Count(); j++)
                {
                    AminoAcid a;
                    AminoAcid b;
                    AminoAcid c;
                    for (int i = 0; i < structure.Groups.ElementAt(j).AA.Count(); i++)
                    {
                        b = structure.Groups.ElementAt(j).AA.ElementAt(i);
                        double phi = 360.0;
                        double psi = 360.0;
                        if (i > 0)
                        {
                            a = structure.Groups.ElementAt(j).AA.ElementAt(i - 1);
                            try
                            {
                                phi = Calc.getPhi(a, b);
                            }
                            catch (Exception e)
                            {
                                phi = 360.0;
                            }
                        }
                        if (i < structure.Groups.ElementAt(j).AA.Count() - 1)
                        {
                            c = structure.Groups.ElementAt(j).AA.ElementAt(i + 1);
                            try
                            {
                                psi = Calc.getPsi(b, c);
                            }
                            catch (Exception e)
                            {

                                psi = 360.0;
                            }
                        }
                        if (phi == 360.0 || psi == 360.0) continue;
                        if (flag==1) angles[(int)phi+180][(int)psi+180] = 1;
                        else if(flag==2 && angles[(int)phi+180][(int)psi+180] != 1) PlotList.series.Add(new Data(phi, psi));
                        else if (flag == 0)PlotList.series.Add(new Data(phi,psi));
                    }
                }
            }
            catch (Exception e)
            {

            }
        }