Ejemplo n.º 1
0
        public static double angle(Atom a, Atom b)
        {
            Vector3D va = new Vector3D(a.getX(), a.getY(), a.getZ());
                Vector3D vb = new Vector3D(b.getX(), b.getY(), b.getZ());

                return Vector3D.AngleBetween(va, vb);
        }
Ejemplo n.º 2
0
        public static double getDistanceFast(Atom a, Atom b)
        {
            double x = a.getX() - b.getX();
                double y = a.getY() - b.getY();
                double z = a.getZ() - b.getZ();

                return x * x + y * y + z * z;
        }
Ejemplo n.º 3
0
        public static Atom add(Atom a, Atom b)
        {
            Atom c = new Atom();
                c.setX(a.getX() + b.getX());
                c.setY(a.getY() + b.getY());
                c.setZ(a.getZ() + b.getZ());

                return c;
        }
Ejemplo n.º 4
0
        public static double getDistance(Atom a, Atom b)
        {
            double x = a.getX() - b.getX();
                double y = a.getY() - b.getY();
                double z = a.getZ() - b.getZ();

                double s = x * x + y * y + z * z;

                return Math.Sqrt(s);
        }
Ejemplo n.º 5
0
 public static double amount(Atom a)
 {
     return Math.Sqrt(scalarProduct(a, a));
 }
Ejemplo n.º 6
0
 public static Atom vectorProduct(Atom a, Atom b)
 {
     Atom c = new Atom();
         c.setX(a.getY() * b.getZ() - a.getZ() * b.getY());
         c.setY(a.getZ() * b.getX() - a.getX() * b.getZ());
         c.setZ(a.getX() * b.getY() - a.getY() * b.getX());
         return c;
 }
Ejemplo n.º 7
0
        public static Atom unitVector(Atom a)
        {
            double amnt = amount(a);

                double[] coords = new double[3];

                coords[0] = a.getX() / amnt;
                coords[1] = a.getY() / amnt;
                coords[2] = a.getZ() / amnt;

                a.setCoords(coords);
                return a;
        }
Ejemplo n.º 8
0
        public static double torsionAngle(Atom a, Atom b, Atom c, Atom d)
        {
            Atom ab = subtract(a, b);
            Atom cb = subtract(c, b);
            Atom bc = subtract(b, c);
            Atom dc = subtract(d, c);

            Atom abc = vectorProduct(ab, cb);
            Atom bcd = vectorProduct(bc, dc);

            double angl = angle(abc, bcd);

            /* calc the sign: */
            Atom vecprod = vectorProduct(abc, bcd);
            double val = scalarProduct(cb, vecprod);
            if (val < 0.0) angl = -angl;

            return angl;
        }
Ejemplo n.º 9
0
        public static Atom subtract(Atom a, Atom b)
        {
            Atom c = new Atom();
                c.setX(a.getX() - b.getX());
                c.setY(a.getY() - b.getY());
                c.setZ(a.getZ() - b.getZ());

                return c;
        }
Ejemplo n.º 10
0
 public void setC(Atom c)
 {
     C = c;
 }
Ejemplo n.º 11
0
 public static Atom invert(Atom a)
 {
     double[] coords = new double[] { 0.0, 0.0, 0.0 };
         Atom zero = new Atom();
         zero.setCoords(coords);
         return subtract(zero, a);
 }
Ejemplo n.º 12
0
 public void setO(Atom o)
 {
     O = o;
 }
Ejemplo n.º 13
0
 public void setN(Atom n)
 {
     N = n;
 }
Ejemplo n.º 14
0
 public void setCB(Atom cB)
 {
     CB = cB;
 }
Ejemplo n.º 15
0
 public void setCA(Atom cA)
 {
     CA = cA;
 }
Ejemplo n.º 16
0
 public static double scalarProduct(Atom a, Atom b)
 {
     return a.getX() * b.getX() + a.getY() * b.getY() + a.getZ() * b.getZ();
 }
Ejemplo n.º 17
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;
        }