Beispiel #1
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);
        }
Beispiel #2
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);
        }