コード例 #1
0
        internal static PatchTable GetInstanceWithUniformWeightByLength(IList <PatchPattern> patchPatternCollection)
        {
            PatchTable patchTable = new PatchTable();

            patchTable.PatchTableScorer = PatchTableScorer.GetInstance("normal");

            int totalLength = 0;

            foreach (PatchPattern patchPattern in patchPatternCollection)
            {
                totalLength += patchPattern.FullLength;
            }


            foreach (PatchPattern patchPattern in patchPatternCollection)
            {
                double weight = (double)patchPattern.FullLength / (double)totalLength;

                patchTable.SetMaxPatchLength(patchPattern);

                Patch aPatch = Patch.GetInstance(patchPattern, weight);
                patchTable.Add(aPatch);
                patchTable.CreateSortedArrays();
            }

            return(patchTable);
        }
コード例 #2
0
        static public PatchTable GetInstanceFromFile(PatchPatternFactory patchPatternFactory,
                                                     TextReader patchTableTextReader, string scorerName)
        {
            PatchTable patchTable = new PatchTable();

            patchTable.PatchTableScorer = PatchTableScorer.GetInstance(scorerName);

            foreach (Dictionary <string, string> row in SpecialFunctions.TabFileTable(patchTableTextReader, "Patch\tWeight", false))
            {
                PatchPattern patchPattern = patchPatternFactory.GetInstance(row["Patch"]);
                double       weight       = double.Parse(row["Weight"]);
                patchTable.SetMaxPatchLength(patchPattern);
                Patch patch = Patch.GetInstance(patchPattern, weight);
                patchTable.Add(patch);
            }

            patchTable.CreateSortedArrays();

            return(patchTable);
        }
コード例 #3
0
        static public PatchTable GetInstance(Dictionary <string, double> patchToWeight, string protein, string vaccineCriteriaName)
        {
            PatchTable patchTable = new PatchTable();

            patchTable.PatchTableScorer = PatchTableScorer.GetInstance("normal");

            PatchPatternFactory patchPatternFactory = PatchPatternFactory.GetFactory("strings");

            patchTable.PatchPatternToPatch = new Dictionary <PatchPattern, Patch>();
            foreach (KeyValuePair <string, double> patchAndWeight in patchToWeight)
            {
                string       patchAsString = patchAndWeight.Key;
                double       weight        = patchAndWeight.Value;
                PatchPattern patchPattern  = patchPatternFactory.GetInstance(patchAsString);
                Patch        aPatch        = Patch.GetInstance(patchPattern, weight);
                patchTable.Add(aPatch);
            }

            patchTable.CreateSortedArrays();

            return(patchTable);
        }