Example #1
0
        /**
             * Calculate the psi angle.
             *
             * @param a  an AminoAcid object
             * @param b  an AminoAcid object
             * @return a double
             * @throws StructureException if aminoacids not connected or if any of the 4 needed atoms missing
             */
        public static double getPsi(AminoAcid a, AminoAcid b)
        {
            if (!isConnected(a, b))
                {
                    //System.out.println("can not calc Psi - AminoAcids are not connected!");
                }

                Atom a_N = a.getN();
                Atom a_CA = a.getCA();
                Atom a_C = a.getC();
                Atom b_N = b.getN();

            // C and N were checked in isConnected already
            if (a_CA == null) { }// System.out.println("Can not calculate Psi, CA atom is missing");

                return torsionAngle(a_N, a_CA, a_C, b_N);
        }
Example #2
0
        /**
         * Test if two amino acids are connected, i.e.
         * if the distance from C to N < 2.5 Angstrom.
         *
         * If one of the AminoAcids has an atom missing, returns false.
         *
         * @param a  an AminoAcid object
         * @param b  an AminoAcid object
         * @return true if ...
         */
        public static Boolean isConnected(AminoAcid a, AminoAcid b)
        {
            Atom C = null;
            Atom N = null;

            C = a.getC();
            N = b.getN();

            if (C == null || N == null)
            {
                return(false);
            }

            // one could also check if the CA atoms are < 4 A...
            //double distance = getDistance(C,N);
            //return distance < 2.5;
            return(true);
        }
Example #3
0
        /**
         * Calculate the psi angle.
         *
         * @param a  an AminoAcid object
         * @param b  an AminoAcid object
         * @return a double
         * @throws StructureException if aminoacids not connected or if any of the 4 needed atoms missing
         */
        public static double getPsi(AminoAcid a, AminoAcid b)
        {
            if (!isConnected(a, b))
            {
                //System.out.println("can not calc Psi - AminoAcids are not connected!");
            }

            Atom a_N  = a.getN();
            Atom a_CA = a.getCA();
            Atom a_C  = a.getC();
            Atom b_N  = b.getN();

            // C and N were checked in isConnected already
            if (a_CA == null)
            {
            }                    // System.out.println("Can not calculate Psi, CA atom is missing");

            return(torsionAngle(a_N, a_CA, a_C, b_N));
        }
Example #4
0
        /**
             * Test if two amino acids are connected, i.e.
             * if the distance from C to N < 2.5 Angstrom.
             *
             * If one of the AminoAcids has an atom missing, returns false.
             *
             * @param a  an AminoAcid object
             * @param b  an AminoAcid object
             * @return true if ...
             */
        public static Boolean isConnected(AminoAcid a, AminoAcid b)
        {
            Atom C = null;
                Atom N = null;

                C = a.getC();
                N = b.getN();

                if (C == null || N == null)
                    return false;

                // one could also check if the CA atoms are < 4 A...
                //double distance = getDistance(C,N);
                //return distance < 2.5;
                return true;
        }
Example #5
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);
        }
Example #6
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;
        }