Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            var filename = @"G:\Projects\HumanGenome\Protein-PDBs\2mgo.pdb";
            //var filename = @"G:\Projects\HumanGenome\AminoseqFiles\CFTR.aminoseq";
            ApproximatePeptide approximatePeptide;
            Peptide            peptide;

            if (filename.ToLowerInvariant().EndsWith(".pdb"))
            {
                peptide = PeptideLoader.Load(filename);
                peptide.Molecule.MarkBackbone(peptide.MoleculeReference);
                peptide.Molecule.PositionAtoms(peptide.MoleculeReference.FirstAtomId, peptide.MoleculeReference.LastAtomId);
                approximatePeptide = ApproximatePeptideBuilder.FromPeptide(peptide);
            }
            else
            {
                approximatePeptide = ApproximatePeptideBuilder.FromSequence(new string('A', 8), 1);
                //approximatePeptide = ApproximatePeptideBuilder.FromSequence(File.ReadAllLines(filename).Aggregate((a,b) => a + b));
                approximatePeptide.UpdatePositions();
                peptide = new ApproximatePeptideCompleter(approximatePeptide).GetFullPeptide();
            }

            var simulationSettings = new ApproximatePeptideSimulationSettings
            {
                TimeStep       = 2.To(SIPrefix.Femto, Unit.Second),
                SimulationTime = 10.To(SIPrefix.Nano, Unit.Second),
                ResetAtomVelocityAfterEachTimestep = false,
                UseCompactingForce   = true,
                UseRamachandranForce = true
            };
            var ramachadranDataDirectory           = @"G:\Projects\HumanGenome\ramachadranDistributions";
            var ramachandranPlotDistributionSource = new RamachandranPlotGradientDistributionFileSource(ramachadranDataDirectory);
            //var ramachandranPlotDistributionSource = new RamachandranPlotDistributionFixedSource(
            //    new RamachandranPlotFixedDistribution(AminoAcidName.Alanine, new UnitPoint2D(-57.To(Unit.Degree), -47.To(Unit.Degree))));
            //var simulationRunner = ApproximatePeptideFoldingSimulatorFactory.Create(
            //    approximatePeptide, simulationSettings, ramachadranDataDirectory);
            var simulationRunner = new ApproximatePeptideFoldingSimulator(approximatePeptide,
                                                                          simulationSettings,
                                                                          new CompactingForceCalculator(),
                                                                          new RamachandranForceCalculator(ramachandranPlotDistributionSource),
                                                                          new BondForceCalculator());

            //var simulationRunner = new MoleculeDynamicsSimulator(peptide.Molecule, new List<CustomAtomForce>(),
            //    new MoleculeDynamicsSimulationSettings
            //    {
            //        TimeStep = 2.To(SIPrefix.Femto, Unit.Second),
            //        SimulationTime = 10.To(SIPrefix.Pico, Unit.Second)
            //    });
            MoleculeViewModel = new MoleculeViewModel();
            //MoleculeViewModel.DrawAtoms(AtomExtractor.FromApproximatePeptide(approximatePeptide));
            MoleculeViewModel.DrawAtoms(AtomExtractor.FromMolecule(peptide.Molecule));
            simulationRunner.TimestepCompleted += (sender, args) => Application.Current.Dispatcher.BeginInvoke(new Action(() => MoleculeViewModel.DrawAtoms(args.Atoms)));
            SimulationViewModel = new SimulationViewModel(simulationRunner);
        }
        public static ApproximatePeptideFoldingSimulator Create(ApproximatePeptide peptide,
                                                                ApproximatePeptideSimulationSettings simulationSettings,
                                                                string ramachadranDataDirectory)
        {
            var compactnessForceCalculator = new CompactingForceCalculator();

            var ramachandranPlotDistributionSource = new RamachandranPlotGradientDistributionFileSource(ramachadranDataDirectory);
            var ramachadranForceCalculator         = new RamachandranForceCalculator(ramachandranPlotDistributionSource);
            var bondForceCalculator = new BondForceCalculator();

            return(new ApproximatePeptideFoldingSimulator(peptide,
                                                          simulationSettings,
                                                          compactnessForceCalculator,
                                                          ramachadranForceCalculator,
                                                          bondForceCalculator));
        }