Пример #1
0
        private void OnCreatePredictor(CreatePredictor request)
        {
            var req = new GetPDBs(ReadFileLines.Do(request.ViewModel.TrainingPDBsFile));

            req.RequestInDefaultContext();
            var files = req.Files;

            var graphs = CreateProteinGraph.Do(files, request.ViewModel.InterfaceDist, request.ViewModel.GraphNodeDefinition);

            var requestI = new RequestInterface(files, request.ViewModel.InterfaceDist, request.ViewModel.UseVanDerWaalsRadiiIface);

            requestI.RequestInDefaultContext();
            var interfaces = requestI.Interface;

            switch (request.ViewModel.PredictionType)
            {
            case PredictorTypes.RasaAverageHydrophobicityPredictor:
                var predictor = new RasaAverageHydrophobicityPredictor(request.ViewModel);
                predictor.Train(request.ViewModel, files, interfaces, graphs);

                //store Predictor
                using (var writer = new StreamWriter(BaseDirectory + predictor.Name + RasaAverageHydrophobicityPredictorFileEnding))
                {
                    var serializer = new XmlSerializer(typeof(RasaAverageHydrophobicityPredictor));
                    serializer.Serialize(writer, predictor);
                }

                predictors.Add(predictor);
                this.DoRequest(new Created <IHas <IPredictionLogic> >(predictor));
                break;

            case PredictorTypes.RasaAverageHydrophobicityCRFPredictor:
                var predictor2 = new RasaAverageHydrophobicityCRFPredictor(request.ViewModel);
                predictor2.Train(request.ViewModel, files, interfaces, graphs);

                //store Predictor
                using (var writer = new StreamWriter(BaseDirectory + predictor2.Name + RasaAverageHydrophobicityCRFPredictorFileEnding))
                {
                    var serializer = new XmlSerializer(typeof(RasaAverageHydrophobicityCRFPredictor));
                    serializer.Serialize(writer, predictor2);
                }

                predictors.Add(predictor2);
                this.DoRequest(new Created <IHas <IPredictionLogic> >(predictor2));
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void OnProvidePDBInfo(ProvidePDBInfo obj)
        {
            var options = obj.Options;
            var pdbId   = options.PDBId;

            var pdbinfo = default(PDBInfo);
            var req     = new GetPDBs(pdbId.ToIEnumerable());

            req.RequestInDefaultContext();
            var file = req.Files.FirstOrDefault();

            if (req.Files.NotNullOrEmpty())
            {
                pdbinfo = new PDBInfo(file);
            }

            if (options.ComputeRasa)
            {
                var reqR = new RequestRasa(file);
                reqR.RequestInDefaultContext();
                var rasa = reqR.Rasavalues;
            }

            if (options.ComputeInterface)
            {
                var request = new RequestInterface(pdbinfo.PDBFile.ToIEnumerable(), options.InterfaceDefDistance, options.InterfaceUseVanDerWaalsRadii);
                request.RequestInDefaultContext();
                pdbinfo.Interface.Clear();
                foreach (var residue in pdbinfo.PDBFile.Residues)
                {
                    pdbinfo.Interface.Add(residue, request.Interface[pdbinfo.PDBFile.Name][residue]);
                }
            }

            if (options.ComputeGraph)
            {
                pdbinfo.Graphs = CreateProteinGraph.Do(pdbinfo.PDBFile, options.GraphNeighbourDistance, options.GraphNodeCenterDef);

                if (!(pdbinfo.Interface.Count == 0))
                {
                    foreach (var pgraph in pdbinfo.Graphs)
                    {
                        pgraph.Value.Nodes.Where(n => pdbinfo.Interface[n.Data.Residue]).Each((node) => node.Data.IsRefInterface = true);
                    }
                }
            }

            obj.PDBInfo = pdbinfo;
        }
Пример #3
0
        public void Do(RequestInterface request)
        {
            foreach (var pdb in request.PDBs)
            {
                var Iface = new Dictionary <Residue, bool>();
                pdb.Residues.Each(r => Iface.Add(r, false));
                var filename = Location + pdb.Name + "_" + request.Distance + "_" + request.UseVanDerWaalsRadii + "." + FileEnding;
                if (Directory.GetFiles(Location).Contains(filename))
                {
                    using (var reader = new StreamReader(filename))
                    {
                        string line = "";
                        while ((line = reader.ReadLine()) != null)
                        {
                            var residue = pdb.Residues.First(res => (res.Chain + "_" + res.Id).Equals(line));
                            Iface[residue] = true;
                        }
                    }
                }
                else
                {
                    var comprequest = new ComputeInterface(pdb, request.Distance, request.UseVanDerWaalsRadii);
                    comprequest.RequestInDefaultContext();
                    var result = comprequest.Result;

                    using (var writer = new StreamWriter(Location + pdb.Name + "_" + request.Distance + "_" + request.UseVanDerWaalsRadii + "." + FileEnding))
                    {
                        foreach (var entry in result)
                        {
                            foreach (var residue in entry.Value)
                            {
                                writer.WriteLine(residue.Chain + "_" + residue.Id);
                                Iface[residue] = true;
                            }
                        }
                    }
                }
                request.Interface.Add(pdb.Name, Iface);
            }
        }