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);
                    }
                }
            }
        }
        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");
                //}
            }
        }
Beispiel #3
0
        // private static string inputFileFileName = @"lipoprotein_DS.pdb";
        //private static string inputFileFileName = @"lipoprotein.pdb";

        //private static string inputFilePath = @"D:\Molecule Examples\PDB Example Files\";
        //private static string inputFileFileName = @"Zika_Virus_5ire.pdb";

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

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            // PrimaryStructure model = PDBStructureParser.GetStructure(inputFilePath + inputFileFileName);
            PrimaryStructure model = GROStructureParser.GetStructure(inputFilePath + inputFileFileName);

            stopWatch.Stop();

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

            // Console.WriteLine(model.ToString());

            foreach (Chain chain in model.Chains())
            {
                Console.WriteLine("Chain " + chain.ID + ": ");//  + residue.ToString());
                if (chain.ResidueType == StandardResidue.AminoAcid)
                {
                    foreach (Residue residue in chain.MainChainResidues)
                    {
                        Console.WriteLine(residue);
                    }
                    //foreach (Atom mainChainAtom in chain.Value.MainChainAtoms) {
                    //    Console.WriteLine(mainChainAtom);
                    //}
                }
                else
                {
                    Console.WriteLine("Chain " + chain.ID + " is not a protein chain");
                    //foreach (KeyValuePair<int, Residue> residue in chain.Value.Residues) {
                    //    Console.WriteLine(residue.Value.ResidueType.ToString());
                    //}
                }
            }
        }
Beispiel #4
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);
                    }
                }
            }
        }
Beispiel #5
0
        public static void ParseGromacs()
        {
            Console.WriteLine("Parsing GRO File");

            Stopwatch stopWatch = new Stopwatch();

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

            stopWatch.Stop();

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


            foreach (Atom atom in model.Atoms())
            {
                Console.WriteLine("Atom " + atom.Index + ": " + atom.ToString());
            }

            Console.WriteLine("\n---------------------\n");

            Dictionary <Element, Dictionary <int, Atom> > atomSet = model.GetAtomsByElement();

            foreach (KeyValuePair <Element, Dictionary <int, Atom> > set in atomSet)
            {
                Element element = set.Key;

                Console.WriteLine("Element: " + element.ToString());
                Dictionary <int, Atom> atoms = set.Value;

                foreach (KeyValuePair <int, Atom> atom in atoms)
                {
                    Console.WriteLine("Atom: " + atom.Value.ToString());
                }
            }

            foreach (Chain chain in model.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("ResidueID: " + residue.ID + ", Residue Name: " + residue.Name);
                }
            }


            stopWatch.Reset();
            stopWatch.Start();

            int NumberOfProcessorCores = 6;

            Dictionary <int, Bond> bonds = model.GenerateBonds(NumberOfProcessorCores);

            Console.WriteLine("Bond generation complete [" + stopWatch.ElapsedMilliseconds + " ms]");

            int count = 0;

            foreach (KeyValuePair <int, Bond> bond in bonds)
            {
                Atom atom1 = model.Atoms()[bond.Value.Atom1Index];
                Atom atom2 = model.Atoms()[bond.Value.Atom2Index];

                if ((atom1.Element == Element.O && atom2.Element == Element.H) ||
                    (atom2.Element == Element.O && atom1.Element == Element.H))
                {
                    Console.WriteLine("O-H bond found. Distance: " + Vector3.Distance(atom1.Position, atom2.Position));
                    count++;
                    if (count > 5)
                    {
                        break;
                    }
                }
            }

            Console.WriteLine("Getting frame count from trajectory file");

            stopWatch.Reset();
            stopWatch.Start();
            count = XTCTrajectoryParser.GetFrameCount(filepath + trajectoryFile);
            stopWatch.Stop();

            Console.WriteLine("Frame count complete [" + stopWatch.ElapsedMilliseconds + " ms]");
            Console.WriteLine("Frames counted: " + count);
        }
Beispiel #6
0
        public void CreatePDBFile(string filePath, bool mainChainOnly = false, bool omitHetatoms = false, bool omitHydrogen = false)
        {
            using (StreamWriter writer = new StreamWriter(filePath)) {
                //string testRecord = TestLine(); // for debugging output records
                //writer.WriteLine(testRecord);

                string crystRecord = CrystRecord();
                writer.WriteLine(crystRecord);

                int atomIndex = 1;

                foreach (Chain chain in structure.Chains())
                {
                    if (omitHetatoms && chain.ResidueType == StandardResidue.None)
                    {
                        continue;
                    }

                    Atom lastAtom = null;

                    IEnumerable <Residue> residues = null;
                    if (mainChainOnly)
                    {
                        residues = chain.MainChainResidues;
                    }
                    else
                    {
                        residues = chain.Residues;
                    }

                    foreach (Residue residue in residues)
                    {
                        foreach (Atom atom in residue.Atoms.Values)
                        {
                            if (omitHydrogen && atom.Element == Element.H)
                            {
                                continue;
                            }

                            bool hetAtom = atom.ResidueType != StandardResidue.None ? false : true;

                            Vector3 position;

                            // if no frame number use the primary structure coordinates.
                            if (frame == null)
                            {
                                position = new Vector3(atom.Position.x, atom.Position.y, atom.Position.z);
                            }
                            else
                            {
                                position = new Vector3(frame.Coords[atom.Index * 3], frame.Coords[(atom.Index * 3) + 1], frame.Coords[(atom.Index * 3) + 2]);
                            }

                            string atomRecord = AtomRecord(
                                hetAtom,
                                atomIndex,
                                atom.Name,
                                atom.ResidueName,
                                chain.ID.ToString()[0],
                                atom.ResidueIndex.ToString(),
                                position.x * 10,
                                position.y * 10,
                                position.z * 10,
                                atom.Element.ToString()
                                );

                            writer.WriteLine(atomRecord);
                            atomIndex++;
                            lastAtom = atom;
                        }
                    }

                    if (lastAtom != null)
                    {
                        string terRecord = TerRecord(
                            atomIndex,
                            lastAtom.ResidueName,
                            chain.ID.ToString()[0],
                            lastAtom.ResidueIndex.ToString()
                            );

                        writer.WriteLine(terRecord);
                        atomIndex++;
                    }

                    lastAtom = null;
                }

                string endRecord = EndRecord();
                writer.WriteLine(endRecord);
            }
        }