Example #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;
            }
        }
Example #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;
        }