public static void Run()
        {
            Console.WriteLine("Parsing PBD File");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            PrimaryStructure model = PDBStructureParser.GetPrimaryStructure(inputFilePath + inputFileName);

            stopWatch.Stop();

            Console.WriteLine("Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");
            Console.WriteLine("Atom Count: " + model.Atoms().Count);

            Console.WriteLine("Running Stride Analysis");

            stopWatch = new Stopwatch();
            stopWatch.Start();

            StrideAnalysis     stride    = new StrideAnalysis(exePath);
            SecondaryStructure structure = stride.GetSecondaryStructure(inputFilePath + inputFileName);

            // Console.WriteLine("Secondary structure:\n\n" + structure);

            stopWatch.Stop();
            Console.WriteLine("Processing complete [" + stopWatch.ElapsedMilliseconds + " ms]");

            Console.WriteLine("End Testing Stride");

            foreach (Chain chain in model.Chains())
            {
                Console.WriteLine("Chain ID: " + chain.ID);

                if (chain.ResidueType != StandardResidue.AminoAcid)
                {
                    Console.WriteLine("Not a protein chain");
                    continue;
                }

                foreach (Residue residue in chain.MainChainResidues)
                {
                    if (residue.CarbonylOxygen == null)
                    {
                        Console.WriteLine("Residue ID: " + residue.ID + " has no oxygen");
                    }

                    SecondaryStructureInfomation structureInfo = structure.GetStructureInformation(residue.Index);

                    if (structureInfo == null)
                    {
                        Console.WriteLine("Couldn't find structure info for residue index: " + residue.Index);
                    }
                    else
                    {
                        Console.WriteLine("Residue [" + residue.ID + "][" + residue.Name + "] has structure [" + structureInfo.ToString() + "] and Alpha Carbon: " + residue.AlphaCarbon);
                    }
                }
            }
        }
示例#2
0
        public static void Run()
        {
            // get the primary structure
            Console.WriteLine("Parsing GRO File");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            PrimaryStructure primaryStructure = GROStructureParser.GetStructure(inputFilePath + inputFileName);

            stopWatch.Stop();

            Console.WriteLine("Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");

            // get the structure trajectory
            int atomCount = XTCTrajectoryParser.GetAtomCount(inputFilePath + trajectoryFileName);

            if (atomCount == primaryStructure.AtomCount())
            {
                Console.WriteLine("Atom Count matches.");
            }
            else
            {
                Console.WriteLine("Atom count doesnt match between primary structure and trajectory");
            }

            Stopwatch stopWatch2 = new Stopwatch();

            stopWatch2.Start();
            PrimaryStructureTrajectory trajectory = XTCTrajectoryParser.GetTrajectory(inputFilePath + trajectoryFileName, 0, 100, 1);

            stopWatch2.Stop();

            Console.WriteLine("Trajectory Parsing Complete [" + stopWatch2.ElapsedMilliseconds + " ms]");

            // get the secondary structure for the base primary structure

            Stopwatch stopWatch3 = new Stopwatch();

            stopWatch3.Start();
            SecondaryStructure secondaryStructure = SecondaryStructure.CreateFromPrimaryStructure(primaryStructure, strideExePath, tmpFilePath);

            Console.WriteLine("Main Secondary Structure Parsing Complete [" + stopWatch3.ElapsedMilliseconds + " ms]");

            Console.WriteLine(secondaryStructure);

            // get the secondary structure for a frame of the trajectory
            Stopwatch stopWatch4 = new Stopwatch();

            stopWatch4.Start();

            SecondaryStructureTrajectory secondaryStructureTrajectory = new SecondaryStructureTrajectory(primaryStructure, trajectory, strideExePath, tmpFilePath);
            SecondaryStructure           secondaryStructure2          = secondaryStructureTrajectory.GetStructure(50);

            Console.WriteLine("Secondary Structure Parsing for frame 50 Complete [" + stopWatch3.ElapsedMilliseconds + " ms]");

            Console.WriteLine(secondaryStructure2);
        }
        public static void Run()
        {
            Console.WriteLine("Parsing PDB File");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            PrimaryStructure primaryStructure = PDBStructureParser.GetPrimaryStructure(filepath + structureFile);

            stopWatch.Stop();

            Console.WriteLine("Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");

            stopWatch.Reset();
            stopWatch.Start();
            SecondaryStructure.CreateFromPrimaryStructure(primaryStructure, strideExePath, tmpFilePath);
            Console.WriteLine("Main Secondary Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");


            foreach (Chain chain in primaryStructure.Chains())
            {
                foreach (Atom atom in chain.MainChainAtoms)
                {
                    // if no frame number use the base structure coordinates.
                    if (atom == null)
                    {
                        Console.WriteLine("Main chain atom is null");
                    }
                    else
                    {
                        Console.WriteLine("Atom found: " + atom.ToString());
                    }
                }


                //Console.WriteLine("\n---------------------\n");
                //Console.WriteLine("Chain ID: " + chain.ID);
                //Console.WriteLine("Chain Residue Count: " + chain.Residues.Count);
                //if (chain.ResidueType == MolecularDynamics.Definitions.StandardResidue.AminoAcid) {
                //    foreach (Residue residue in chain.Residues) {
                //        Console.WriteLine("Residue index: " + residue.Index + ", ResidueID: " + residue.ID + ", Residue Name: " + residue.Name);
                //        SecondaryStructureInfomation information = secondaryStructure.GetStructureInformation(residue.Index);
                //        if (information == null) {
                //            Console.WriteLine("information null: " + residue.Index);
                //        }
                //    }
                //}
                //else {
                //    Console.WriteLine("Not an amino acid residue");
                //}
            }
        }
        public static SecondaryStructure CreateFromPrimaryStructure(PrimaryStructure primaryStructure, string strideExePath, string tmpFilePath)
        {
            string tmpFileName             = tmpFilePath + @"tempStructure.pdb";
            PDBStructureCreator pdbCreator = new PDBStructureCreator(primaryStructure, null);

            //pdbCreator.CreatePDBFile(tmpFileName, true, true, true);
            pdbCreator.CreatePDBFile(tmpFileName);

            SecondaryStructure secondaryStructure = null;

            try {
                StrideAnalysis stride = new StrideAnalysis(strideExePath);
                secondaryStructure = stride.GetSecondaryStructure(tmpFileName);
            }
            finally {
                FileUtil.DeleteFile(tmpFileName);
            }

            return(secondaryStructure);
        }
        private SecondaryStructure CalculateSecondaryStructure(int frameNumber)
        {
            string tmpFileName             = tmpFilePath + @"tempStructure_" + frameNumber + ".pdb";
            PDBStructureCreator pdbCreator = new PDBStructureCreator(primaryStructure, primaryTrajectory.GetFrame(frameNumber));

            pdbCreator.CreatePDBFile(tmpFileName, true, true, true);

            SecondaryStructure frame = null;

            try {
                StrideAnalysis stride = new StrideAnalysis(strideExePath);
                frame = stride.GetSecondaryStructure(tmpFileName);
            }
            catch (StrideException ex) {
                throw new StrideException(ex.Message);
            }
            finally {
                FileUtil.DeleteFile(tmpFileName);
            }

            return(frame);
        }
示例#6
0
        public static void Run()
        {
            Console.WriteLine("Parsing GRO File");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            PrimaryStructure primaryStructure = GROStructureParser.GetStructure(filepath + structureFile);

            stopWatch.Stop();

            Console.WriteLine("Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");

            stopWatch.Reset();
            stopWatch.Start();
            SecondaryStructure secondaryStructure = SecondaryStructure.CreateFromPrimaryStructure(primaryStructure, strideExePath, tmpFilePath);

            Console.WriteLine("Main Secondary Structure Parsing Complete [" + stopWatch.ElapsedMilliseconds + " ms]");


            foreach (Chain chain in primaryStructure.Chains())
            {
                Console.WriteLine("\n---------------------\n");
                Console.WriteLine("Chain ID: " + chain.ID);
                Console.WriteLine("Chain Residue Count: " + chain.Residues.Count);
                foreach (Residue residue in chain.Residues)
                {
                    Console.WriteLine("Residue index: " + residue.Index + ", ResidueID: " + residue.ID + ", Residue Name: " + residue.Name);
                    SecondaryStructureInfomation information = secondaryStructure.GetStructureInformation(residue.Index);
                    if (information == null)
                    {
                        Console.WriteLine("information null: " + residue.Index);
                    }
                }
            }
        }
        private SecondaryStructure parseStrideOutput(string strideOutput)
        {
            SecondaryStructure ss = new SecondaryStructure();

            using (StringReader reader = new StringReader(strideOutput)) {
                string line;
                int    residueIndex = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    // Console.WriteLine("Processing line: [" + line + "]");

                    if (!line.StartsWith("ASG "))
                    {
                        continue;
                    }

                    if (int.TryParse(line.Substring(10, 5), out residueIndex))
                    {
                        string structureCode = line.Substring(24, 1);

                        SecondaryStructureType structure;
                        switch (structureCode)
                        {
                        case "G":
                            structure = SecondaryStructureType.ThreeHelix;
                            break;

                        case "H":
                            structure = SecondaryStructureType.AlphaHelix;
                            break;

                        case "I":
                            structure = SecondaryStructureType.FiveHelix;
                            break;

                        case "T":
                            structure = SecondaryStructureType.Turn;
                            break;

                        case "E":
                            structure = SecondaryStructureType.BetaSheet;
                            break;

                        case "B":
                            structure = SecondaryStructureType.BetaBridge;
                            break;

                        case "S":
                            structure = SecondaryStructureType.Bend;
                            break;

                        default:
                            structure = SecondaryStructureType.Coil;
                            break;
                        }

                        string phi = line.Substring(42, 7);
                        string psi = line.Substring(52, 7);

                        SecondaryStructureInfomation information = new SecondaryStructureInfomation();
                        information.type = structure;
                        information.phi  = float.Parse(phi);
                        information.psi  = float.Parse(psi);

                        ss.AddStructureInformation(residueIndex, information);

                        Console.WriteLine("Added structure information for residue index: " + residueIndex);
                    }
                }
            }

            return(ss);
        }