Пример #1
0
        private void LoadUpPredictor(string modelName, int eLength, int ncLength, Converter <Hla, Hla> hlaForNormalization)
        {
            //Load up the predictor

            string featurerizerName;

            switch (modelName.ToLower())
            {
            //!!!would be better not to have multiple of these switch statements around - looks like a job for a Class
            case "lanliedb03062007":
                featurerizerName   = "[email protected]";
                SampleNEC          = NEC.GetInstance("", new string(' ', eLength), "");
                HlaFactory         = HlaFactory.GetFactory("MixedWithB15AndA68");
                SourceDataFileName = "lanlIedb03062007.pos.source.txt";
                NameList           = new string[] { "LANL", "IEDB" };
                break;

            default:
                SpecialFunctions.CheckCondition(false, "Don't know what featurerizer to use for the model");
                featurerizerName   = null;
                SourceDataFileName = null;
                NameList           = null;
                break;
            }
            Converter <object, Set <IHashableFeature> > featurizer = FeatureLib.CreateFeaturizer(featurerizerName);

            //GeneratorType generatorType = GeneratorType.ComboAndZero6SuperType;
            //FeatureSerializer featureSerializer = PositiveNegativeExperimentCollection.GetFeatureSerializer();
            //KmerDefinition = kmerDefinition;
            //HlaResolution hlaResolution = HlaResolution.ABMixed;
            string resourceName = string.Format("maxentModel{0}{1}{2}{3}.xml", modelName.Split('.')[0], SampleNEC.N.Length, SampleNEC.E.Length, SampleNEC.C.Length);

            EpitopeLearningDataList = new List <EpitopeLearningDataDupHlaOK>();
            using (StreamReader streamReader = Predictor.OpenResource(resourceName))
            {
                Logistic = (Logistic)FeatureLib.FeatureSerializer.FromXmlStreamReader(streamReader);
                //Logistic.FeatureGenerator = EpitopeFeatureGenerator.GetInstance(KmerDefinition, generatorType, featureSerializer).GenerateFeatureSet;
                Logistic.FeatureGenerator = FeatureLib.CreateFeaturizer(featurerizerName);
                foreach (string name in NameList)
                {
                    EpitopeLearningData epitopeLearningDataX = EpitopeLearningData.GetDbWhole(HlaFactory, SampleNEC.E.Length, name, SourceDataFileName);
                    Debug.Assert(epitopeLearningDataX.Count > 0, "Expect given data to have some data");
                    //!!!combine with previous step
                    EpitopeLearningDataDupHlaOK epitopeLearningData = new EpitopeLearningDataDupHlaOK(epitopeLearningDataX.Name);
                    foreach (KeyValuePair <Pair <string, Hla>, bool> merAndHlaAndLabel in epitopeLearningDataX)
                    {
                        Hla hlaIn  = merAndHlaAndLabel.Key.Second;
                        Hla hlaOut = hlaForNormalization(hlaIn);

                        Dictionary <Hla, Dictionary <Hla, bool> > hla2ToHlaToLabel = SpecialFunctions.GetValueOrDefault(epitopeLearningData, merAndHlaAndLabel.Key.First);
                        Dictionary <Hla, bool> hlaToLabel = SpecialFunctions.GetValueOrDefault(hla2ToHlaToLabel, hlaOut);
                        hlaToLabel.Add(hlaIn, merAndHlaAndLabel.Value);
                    }

                    EpitopeLearningDataList.Add(epitopeLearningData);
                }
            }

            HlaForNormalization = hlaForNormalization;
        }
Пример #2
0
        /// <summary>
        /// Handles the click event of Inspect button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInspect_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CabFilePath))
            {
                return;
            }

            CabUtil            cabUtil = new CabUtil();
            List <FeatureItem> items = null, siteItems = null;

            try
            {
                string manifestPath = cabUtil.ExtractManifest(CabFilePath, System.IO.Path.GetTempPath());

                items     = ManifestLib.GetWebFeatures(manifestPath, true);
                siteItems = ManifestLib.GetWebFeatures(manifestPath, false);
            }
            catch (NotValidCabinetException)
            {
                MessageBox.Show(Constants.invalidCabinet);
            }
            catch (ManifestNotFoundException)
            {
                MessageBox.Show(Constants.invalidCabinet);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show(Constants.accessDenied);
            }



            Constants.SPStatus statusWeb  = FeatureLib.ResolveFeatures(items);
            Constants.SPStatus statusSite = FeatureLib.ResolveFeatures(siteItems);

            BindListBox(cblWebFeatures, items);
            BindListBox(cblSiteFeatures, siteItems);

            cblWebFeatures.SelectionMode  = SelectionMode.None;
            cblSiteFeatures.SelectionMode = SelectionMode.None;

            if (statusWeb == Constants.SPStatus.Unavailable || statusSite == Constants.SPStatus.Unavailable)
            {
                lblStatus.Text = Constants.failSP;
            }
            else if (statusWeb == Constants.SPStatus.Resolved && statusSite == Constants.SPStatus.Resolved)
            {
                lblStatus.Text = Constants.resolvedStatus;
            }
            else if (statusWeb == Constants.SPStatus.NotResolved || statusSite == Constants.SPStatus.NotResolved)
            {
                lblStatus.Text = Constants.unResolvedStatus;
            }

            CabUtil.DeleteFile(System.IO.Path.GetTempPath());
        }