/// <exception cref="ArgumentNullException">Specified argument is null</exception> /// <exception cref="ArgumentException">A feature group with the specified name already exists</exception> /// <exception cref="ResourceNotFoundException{Feature}">A referenced feature does not exist</exception> public FeatureGroup CreateGroup(FeatureGroupArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (Db.FeatureGroups.Any(g => g.Name == args.Name)) { throw new ArgumentException($"A feature group with name '{args.Name}' already exists"); } var group = new FeatureGroup { Name = args.Name }; group.EnabledFeatures = GetFeatures(args.EnabledFeatures) .Select(f => new FeatureToFeatureGroupMapping(f, group)) .ToList(); group.Members = GetOrCreateUsers(args.Members).ToList(); // "pre-assigned" members of the new group might - until now - be assigned to another group // => we have to correctly detach from the old group foreach (var user in group.Members.ToList()) { MoveUserToGroupCore(user, group); } Db.FeatureGroups.Add(group); Db.SaveChanges(); return(group); }
private IReadOnlyCollection <Feature> GetEffectivelyEnabledFeaturesForGroup(FeatureGroup group) { // required navigation properties: FeatureGroup.EnabledFeatures.Feature // The feature group specifies which features are enabled. // From specification: "A feature X is [effectively] enabled for a certain user if X and all features // higher than X in the feature hierarchy are enabled for the user's feature group [or the public group]" // (features enabled in the public group are "added" to those of the user's group, HIPCMS-608) // Thus, the set of effectively enabled features is a subset of the enabled features. // Example: // Feature Hierarchy: Features enabled in user Bob's group: [1, 2, 4] // (1) Features enabled in public group: [3, 5] // (2) // (3) Features effectively enabled for user Bob: [1, 3, 5] // (4) Features effectively enabled for unauthenticated users: [3] // (5) // (6) // (7) var enabledFeatures = group.EnabledFeatures .Concat(PublicGroup.EnabledFeatures) .Distinct() .Select(m => m.Feature) .ToSet(); return(enabledFeatures .Where(f => AncestorsAndSelf(f).All(parent => enabledFeatures.Contains(parent))) .ToList()); }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.FeatureGroup = (FeatureGroup)target; return; case 2: this.InfoFooter = (ProfileInfoFooter)target; return; case 3: this.ConnectBtn = (Button)target; return; case 4: this.UpgradeBtn = (UpgradeButton)target; return; default: this._contentLoaded = true; return; } }
public FeatureValue Compress( IList <FeatureValue> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { var scalarProduct = 0.0d; var vectorXNorm = 0.0d; var vectorYNorm = 0.0d; for (var i = 0; i < values.Count; i++) { scalarProduct += values[i].NumericValue; vectorXNorm += Math.Pow(values[i].NumericValue, 2); vectorYNorm += 1; } if (vectorXNorm == 0) { return(new FeatureValue(0)); } vectorXNorm = Math.Sqrt(vectorXNorm); vectorYNorm = Math.Sqrt(vectorYNorm); return(new FeatureValue((float)(scalarProduct / (vectorXNorm * vectorYNorm)))); }
static void Main(string[] args) { var sessionFactory = CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { Feature feat = new Feature { Name = "featuretest", Percentage = 50, IsEnabled = true, LastModifiedDate = DateTime.Now }; FeatureGroup grp = new FeatureGroup { Feature = feat, Name = "group1" }; FeatureUser usr = new FeatureUser { Feature = feat, Name = "user1" }; session.SaveOrUpdate(feat); session.SaveOrUpdate(grp); session.SaveOrUpdate(usr); Feature globFeat = new Feature { Name = "globalfeat", Percentage = 100, IsEnabled = true, LastModifiedDate = DateTime.Now }; session.SaveOrUpdate(globFeat); transaction.Commit(); } } Console.Read(); }
public FeatureValue Compress( IList <FeatureValue> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { context.Project.PluginData .GetData <LoggingPlugin, UsageStatistics>(string.Empty) .CosThetaUnitaryCounter++; var scalarProduct = 0.0d; var vectorXNorm = 0.0d; var vectorYNorm = 0.0d; for (var i = 0; i < values.Count; i++) { scalarProduct += values[i].NumericValue; vectorXNorm += Math.Pow(values[i].NumericValue, 2); vectorYNorm += 1; } if (vectorXNorm == 0) { return(new FeatureValue(0)); } vectorXNorm = Math.Sqrt(vectorXNorm); vectorYNorm = Math.Sqrt(vectorYNorm); return(new FeatureValue((float)(scalarProduct / (vectorXNorm * vectorYNorm)))); }
private void MoveUserToGroupCore(User user, FeatureGroup group) { // remove user from current group, then add to new group user.FeatureGroup.Members.Remove(user); group.Members.Add(user); user.FeatureGroup = group; }
public FeatureValue Compress( IList <FeatureValue> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { var vectorX = values; var vectorY = new List <FeatureValue>(values.Count); for (var i = 0; i < featureGroup.CompressionElements.Count; i++) { var featureValues = featureGroup.CompressionElements[i].GetValues(record, context); for (var j = 0; j < featureValues.Count; j++) { vectorY.Add(featureValues[j]); } } if (vectorX.Count < vectorY.Count) { vectorX = vectorX.ToList(); var missingCount = vectorY.Count - vectorX.Count; for (var i = 0; i < missingCount; i++) { vectorX.Add(new FeatureValue(0)); } } else if (vectorY.Count < vectorX.Count) { var missingCount = vectorX.Count - vectorY.Count; for (var i = 0; i < missingCount; i++) { vectorY.Add(new FeatureValue(0)); } } var scalarProduct = 0.0d; var vectorXNorm = 0.0d; var vectorYNorm = 0.0d; for (var i = 0; i < vectorX.Count; i++) { scalarProduct += vectorX[i].NumericValue * vectorY[i].NumericValue; vectorXNorm += Math.Pow(vectorX[i].NumericValue, 2); vectorYNorm += Math.Pow(vectorY[i].NumericValue, 2); } if (vectorXNorm == 0 || vectorYNorm == 0) { return(new FeatureValue(0)); } vectorXNorm = Math.Sqrt(vectorXNorm); vectorYNorm = Math.Sqrt(vectorYNorm); return(new FeatureValue((float)(scalarProduct / (vectorXNorm * vectorYNorm)))); }
public static BlueprintFeature CreateFeature(String name, String displayName, String description, String guid, Sprite icon, FeatureGroup group, params BlueprintComponent[] components) { var feat = Create <BlueprintFeature>(); SetFeatureInfo(feat, name, displayName, description, guid, icon, group, components); return(feat); }
public FeatureGroupResult(FeatureGroup group) { Id = group.Id; Name = group.Name; IsProtected = group.IsProtected; EnabledFeatures = group.EnabledFeatures.Select(f => f.FeatureId).ToList(); Members = group.Members.Select(m => m.Id).ToList(); }
private bool IsFeatureEffectivelyEnabledForGroup(Feature feature, FeatureGroup group) { // required navigation properties: FeatureGroup.EnabledFeatures var enabledFeatures = group.EnabledFeatures .Concat(PublicGroup.EnabledFeatures) .Distinct(); return(AncestorsAndSelf(feature).All(parent => enabledFeatures.Any(m => m.FeatureId == parent.Id))); }
public static void SetFeatureInfo(BlueprintFeature feat, String name, String displayName, String description, String guid, Sprite icon, FeatureGroup group, params BlueprintComponent[] components) { feat.name = name; feat.SetComponents(components); feat.Groups = new [] { group }; feat.SetNameDescriptionIcon(displayName, description, icon); Main.library.AddAsset(feat, guid); }
public static FeatureGroupDto ToDto(this FeatureGroup feature) { var dto = new FeatureGroupDto { Name = feature.Name, DisplayName = feature.DisplayName }; ((IData)feature).ToDto((IDataDto)dto); return(dto); }
// At the moment it just generates a simple chunk, probably fine performance-wise public SimpleChunk GetSimpleChunkAt(Vector2Int chunkPos) // TODO: Pull from memory and storage { float[,] chunkHeightMap = heightGenerator.GenerateHeightMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y)); float[,] chunkClimateMap = climateGenerator.GenerateClimateNoiseMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y)); float[,] chunkBiomeMap = biomeGenerator.GenerateBiomeNoiseMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y)); float[,] chunkFeatureMap = featureGenerator.GenerateObjectNutrientsMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y)); Biome biome = biomeGenerator.getBiome(chunkBiomeMap[0, 0], chunkHeightMap[0, 0], chunkClimateMap[0, 0]); BiomeLayer biomeLayer = biomeGenerator.getBiomeLayer(biome, chunkHeightMap[0, 0], chunkClimateMap[0, 0]); FeatureGroup featureGroup = featureGenerator.getFeatureGroup(chunkFeatureMap[0, 0], biomeLayer, Vector2.zero); return(new SimpleChunk(biome, biomeLayer)); }
public IList <FeatureValue> Aggregate( IList <EncounterValues> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { var result = new FeatureValue[values[0].Values.Count]; for (var i = 0; i < result.Length; i++) { result[i] = new FeatureValue( string.Join("__", values.Select(x => x.Values[i].StringValue))); } return(result); }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.BrowserStartOption = (ComboBox)target; return; case 2: this.No = (ComboBoxItem)target; return; case 3: this.Yes = (ComboBoxItem)target; return; case 4: this.yesIncognito = (ComboBoxItem)target; return; case 5: this.CountryComboBox = (ComboBox)target; this.CountryComboBox.AddHandler(UserSelectionChangedBehavior.UserSelectionChangedEvent, new UserSelectionChangedEventHandler(this.OnCountrySelectionChanged)); return; case 6: this.FeatureGroup = (FeatureGroup)target; return; case 7: this.InfoFooter = (ProfileInfoFooter)target; return; case 8: this.ConnectBtn = (Button)target; return; case 9: this.UpgradeBtn = (UpgradeButton)target; return; default: this._contentLoaded = true; return; } }
public FeatureTogglesManagerBase(ToggleDbContext db) { Db = db; // Load standard groups which are always available and can't be deleted. // If this fails, the database is not correctly initialized. DefaultGroup = GetAllGroups(true, true) .Include(g => g.EnabledFeatures) .ThenInclude(m => m.Feature) // loading this is required for checking effectively enabled features .ThenInclude(f => f.Children) .Single(g => g.Name == FeatureGroup.DefaultGroupName); PublicGroup = GetAllGroups(true, true) .Include(g => g.EnabledFeatures) .ThenInclude(m => m.Feature) // loading this is required for checking effectively enabled features .ThenInclude(f => f.Children) .Single(g => g.Name == FeatureGroup.PublicGroupName); }
public IList <FeatureValue> Aggregate( IList <EncounterValues> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { context.Project.PluginData .GetData <LoggingPlugin, UsageStatistics>(string.Empty) .StringConcatCounter++; var result = new FeatureValue[values[0].Values.Count]; for (var i = 0; i < result.Length; i++) { result[i] = new FeatureValue( string.Join("__", values.Select(x => x.Values[i].StringValue))); } return(result); }
public FeatureGroupReadable(FeatureGroup group) { if (group == null) { throw new ArgumentNullException(nameof(group)); } Source = group.Source?.DisplayName; Type = group.ValueType.ToString(); Elements = group.Elements != null ? string.Join(", ", group.Elements.Select(x => x.DisplayName)) : null; AggregationFunction = group.AggregationFunction?.DisplayName; CompressionFunction = group.CompressionFunction?.DisplayName; CompressionElements = group.CompressionElements != null ? string.Join(", ", group.CompressionElements.Select(x => x.DisplayName)) : null; }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.SecurStatus = (Label)target; return; case 2: this.SignalStatus = (Label)target; return; case 3: this.WifiLabel = (Label)target; return; case 4: this.HotspotComboBox = (ComboBox)target; this.HotspotComboBox.SelectionChanged += new SelectionChangedEventHandler(this.HotspotComboBox_OnSelectionChanged); return; case 5: this.FeatureGroup = (FeatureGroup)target; return; case 6: this.InfoFooter = (ProfileInfoFooter)target; return; case 7: this.ConnectBtn = (Button)target; return; case 8: this.UpgradeBtn = (UpgradeButton)target; return; default: this._contentLoaded = true; return; } }
public static FeatureGroup ToDomain(this FeatureGroupDto feature, FeatureGroup originalFeature = null) { if (originalFeature != null && originalFeature.Id == feature.Id) { originalFeature.Name = feature.Name; originalFeature.DisplayName = feature.DisplayName; ((IDataDto)feature).ToDomain((IData)originalFeature); return(originalFeature); } var data = new FeatureGroup { Name = feature.Name, DisplayName = feature.DisplayName }; ((IDataDto)feature).ToDomain((IData)data); return(data); }
public static void Initialize(ToggleDbContext db) { if (db.FeatureGroups.Any()) { return; // DB is already seeded } var defaultGroup = new FeatureGroup { Name = FeatureGroup.DefaultGroupName, IsProtected = true }; var publicGroup = new FeatureGroup { Name = FeatureGroup.PublicGroupName, IsProtected = true }; db.FeatureGroups.AddRange(defaultGroup, publicGroup); db.SaveChanges(); }
// Generates the chunk colors to be applied to the world texture void GenerateWorldChunkColors() { int worldWidth = world.width * pixelsPerChunk; int worldHeight = world.height * pixelsPerChunk; for (chunkY = 0; chunkY < worldHeight; chunkY++) { for (chunkX = 0; chunkX < worldWidth; chunkX++) { float[,] chunkHeightMap = world.heightGenerator.GenerateHeightMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY)); float[,] chunkClimateMap = world.climateGenerator.GenerateClimateNoiseMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY)); float[,] chunkBiomeMap = world.biomeGenerator.GenerateBiomeNoiseMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY)); float[,] chunkFeatureMap = world.featureGenerator.GenerateObjectNutrientsMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY)); for (int chunkTileY = 0; chunkTileY < pixelsPerChunk; chunkTileY++) { for (int chunkTileX = 0; chunkTileX < pixelsPerChunk; chunkTileX++) { int x = (chunkX * pixelsPerChunk) + chunkTileX; int y = (chunkY * pixelsPerChunk) + chunkTileY; Biome biome = world.biomeGenerator.getBiome(chunkBiomeMap[chunkTileX, chunkTileY], chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]); BiomeLayer biomeLayer = world.biomeGenerator.getBiomeLayer(biome, chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]); FeatureGroup featureGroup = world.featureGenerator.getFeatureGroup(chunkFeatureMap[chunkTileX, chunkTileY], biomeLayer, Vector2.zero); if (featureGroup != null) { chunkColors[(y * worldWidth) + x] = featureGroup.mapColor; } else { chunkColors[(y * worldWidth) + x] = biomeLayer.groundTile.mapColor; } } } } } }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.SelectedLabel = (Label)target; return; case 2: this.ServerOption = (Label)target; return; case 3: this.ServerImage = (Image)target; return; case 4: this.FeatureGroup = (FeatureGroup)target; return; case 5: this.InfoFooter = (ProfileInfoFooter)target; return; case 6: this.ConnectBtn = (Button)target; return; case 7: this.UpgradeBtn = (UpgradeButton)target; return; default: this._contentLoaded = true; return; } }
public async Task <IActionResult> Update([FromBody] FeatureGroupViewModel value, Guid?index) { if (ModelState.IsValid) { var grp = new FeatureGroup { ID = Guid.NewGuid(), Name = value.Name, Description = value.Description, CreatedBy = userId, UpdatedBy = userId, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, }; //commit var ret = await this._unitOfWork.FeatureGroups.Update(grp, value.ID); //return client side return(Ok(ret)); } return(BadRequest(ModelState)); }
// Fills the table with a list of available features protected void PopulateFeaturesTable() { // declare vars List <FeatureGroup> features = new List <FeatureGroup> (); FeatureGroup featGroup; string[] mediaTypes; // Sources featGroup = new FeatureGroup() { Name = "Sources" }; try { featGroup.Features.Add(new Feature() { Name = "Camera", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) }); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView("No Camera", "No Camera Detected!", null, "OK", null); alert.Show(); } featGroup.Features.Add(new Feature() { Name = "Photo Library", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) }); featGroup.Features.Add(new Feature() { Name = "Saved Photos Album", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) }); features.Add(featGroup); // Camera and Flash featGroup = new FeatureGroup() { Name = "Camera and Flash" }; try { featGroup.Features.Add(new Feature() { Name = "Front Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add(new Feature() { Name = "Front Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice(UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add(new Feature() { Name = "Rear Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear) }); featGroup.Features.Add(new Feature() { Name = "Rear Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice(UIImagePickerControllerCameraDevice.Rear) }); features.Add(featGroup); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView("No Camera", "No Camera Detected!", null, "OK", null); alert.Show(); } // Camera Media Types featGroup = new FeatureGroup() { Name = "Camera Media Types" }; try { mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView("No Camera", "No Camera Detected!", null, "OK", null); alert.Show(); } // Photo Library Media Types featGroup = new FeatureGroup() { Name = "Photo Library Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); // Saved Photos Album Media Types featGroup = new FeatureGroup() { Name = "Saved Photos Album Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.SavedPhotosAlbum); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); // bind to the table tableSource = new ImagePickerScreen.FeaturesTableDataSource(features); tblFeatures.Source = tableSource; }
static void FixSpellbookSelection(BlueprintArchetype archetype, String spellSelectionId, String sorcererSelectionId, FeatureGroup group) { var spellSelection = (BlueprintFeatureSelection)library.BlueprintsByAssetId[spellSelectionId]; var sorcererClass = archetype.GetParentClass(); var sorcererFeature = spellSelection.AllFeatures.Cast <BlueprintFeatureReplaceSpellbook>() .First(f => f.AssetGuid == sorcererSelectionId); // Restrict sorcerer feat so it can't be selected with this archetype var sorcererPrereqs = sorcererFeature.ComponentsArray.ToList(); sorcererPrereqs.Add(Helpers.Create <PrerequisiteNoArchetype>(p => { p.CharacterClass = sorcererClass; p.Archetype = archetype; })); sorcererFeature.SetComponents(sorcererPrereqs); // Create a new feature for this archetype's spellbook var spellbookFeature = library.CopyAndAdd(sorcererFeature, group.ToString().Replace("Spellbook", archetype.name), sorcererFeature.AssetGuid, "7d400c2c080947ecb0a1052b453bc107"); spellbookFeature.Spellbook = archetype.ReplaceSpellbook; spellbookFeature.SetName(archetype.LocalizedName); // Update the prerequisites. spellbookFeature.SetComponents( Helpers.Create <PrerequisiteArchetypeLevel>(p => { p.CharacterClass = sorcererClass; p.Archetype = archetype; }), Helpers.Create <PrerequisiteClassSpellLevel>(p => { p.CharacterClass = sorcererClass; p.RequiredSpellLevel = 1; })); // Add to the list of all features for this selector. var allFeatures = spellSelection.AllFeatures.ToList(); allFeatures.Add(spellbookFeature); spellSelection.AllFeatures = allFeatures.ToArray(); }
/// <summary> /// Validate GenBank Features clonning. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="featureName">Name of the GenBank feature</param> private void ValidateGenBankFeaturesClonning(string nodeName, FeatureGroup featureName) { // Get Values from XML node. string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); string expectedExonFeatureCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExonCount); string expectedExonGeneSymbol = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExonGeneSymbol); string expectedExonNumber = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExonNumber); string expectedMiscDiffCount = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MiscQualifiersCount); string expectedGeneSymbol = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GeneSymbol); string expectedIntronGeneSymbol = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.IntronGeneSymbol); string expectedIntronNumber = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.IntronNumber); string expectedVariationReplace = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.VariationReplace); // Parse a GenBank file. ISequenceParser parserObj = new GenBankParser(); { ISequence seq = parserObj.ParseOne(filePath); Assert.IsNotNull(seq); var metadata = seq.Metadata[Constants.GenBank] as GenBankMetadata; Assert.IsNotNull(metadata); // Validate cloned GenBank feature. switch (featureName) { case FeatureGroup.Exon: List<Exon> exonFeatureList = metadata.Features.Exons; // Validate Exon feature before clonning. Assert.AreEqual(exonFeatureList.Count.ToString((IFormatProvider) null), expectedExonFeatureCount); Assert.AreEqual(exonFeatureList[0].GeneSymbol, expectedExonGeneSymbol); Assert.AreEqual(exonFeatureList[0].Number, expectedExonNumber); // Clone Exon feature. Exon clonedExons = exonFeatureList[0].Clone(); // Validate Exon feature after clonning. Assert.AreEqual(clonedExons.GeneSymbol, expectedExonGeneSymbol); Assert.AreEqual(clonedExons.Number, expectedExonNumber); break; case FeatureGroup.miscDifference: // Validate Misc Difference feature before clonning. List<MiscDifference> miscDifferenceFeatureList = metadata.Features.MiscDifferences; Assert.AreEqual(miscDifferenceFeatureList.Count.ToString((IFormatProvider) null), expectedMiscDiffCount); Assert.AreEqual(miscDifferenceFeatureList[0].GeneSymbol, expectedGeneSymbol); // Clone Misc Difference feature MiscDifference clonedMiscDifferences = miscDifferenceFeatureList[0].Clone(); // Validate Misc Difference feature after clonning. Assert.AreEqual(clonedMiscDifferences.GeneSymbol, expectedGeneSymbol); break; case FeatureGroup.Intron: // Validate Intron feature before clonning. List<Intron> intronFeatureList = metadata.Features.Introns; Assert.AreEqual(intronFeatureList[0].GeneSymbol, expectedIntronGeneSymbol); Assert.AreEqual(intronFeatureList[0].Number, expectedIntronNumber); // Clone Intron feature. Intron clonedIntrons = intronFeatureList[0].Clone(); // Validate Intron feature after clonning. Assert.AreEqual(clonedIntrons.GeneSymbol, expectedIntronGeneSymbol); Assert.AreEqual(clonedIntrons.Number, expectedIntronNumber); break; case FeatureGroup.variation: // Validate Variation feature before clonning. List<Variation> variationFeatureList = metadata.Features.Variations; Assert.AreEqual(variationFeatureList[0].Replace, expectedVariationReplace); // Clone Variation feature. Variation clonedVariations = variationFeatureList[0].Clone(); // Validate Intron feature after clonning. Assert.AreEqual(clonedVariations.Replace, expectedVariationReplace); break; default: break; } } }
// Fills the table with a list of available features protected void PopulateFeaturesTable() { // declare vars List<FeatureGroup> features = new List<FeatureGroup> (); FeatureGroup featGroup; string[] mediaTypes; // Sources featGroup = new FeatureGroup () { Name = "Sources" }; try { featGroup.Features.Add (new Feature () { Name = "Camera", IsAvailable = UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.Camera) }); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView ("No Camera", "No Camera Detected!", null, "OK", null); alert.Show (); } featGroup.Features.Add (new Feature () { Name = "Photo Library", IsAvailable = UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.PhotoLibrary) }); featGroup.Features.Add (new Feature () { Name = "Saved Photos Album", IsAvailable = UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.SavedPhotosAlbum) }); features.Add (featGroup); // Camera and Flash featGroup = new FeatureGroup () { Name = "Camera and Flash" }; try { featGroup.Features.Add (new Feature () { Name = "Front Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable (UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add (new Feature () { Name = "Front Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice (UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add (new Feature () { Name = "Rear Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable (UIImagePickerControllerCameraDevice.Rear) }); featGroup.Features.Add (new Feature () { Name = "Rear Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice (UIImagePickerControllerCameraDevice.Rear) }); features.Add (featGroup); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView ("No Camera", "No Camera Detected!", null, "OK", null); alert.Show (); } // Camera Media Types featGroup = new FeatureGroup () { Name = "Camera Media Types" }; try { mediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera); foreach (var mediaType in mediaTypes) { featGroup.Features.Add (new Feature () { Name = mediaType, IsAvailable = true }); } features.Add (featGroup); } catch (System.NullReferenceException) { UIAlertView alert = new UIAlertView ("No Camera", "No Camera Detected!", null, "OK", null); alert.Show (); } // Photo Library Media Types featGroup = new FeatureGroup () { Name = "Photo Library Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary); foreach (var mediaType in mediaTypes) { featGroup.Features.Add (new Feature () { Name = mediaType, IsAvailable = true }); } features.Add (featGroup); // Saved Photos Album Media Types featGroup = new FeatureGroup () { Name = "Saved Photos Album Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.SavedPhotosAlbum); foreach (var mediaType in mediaTypes) { featGroup.Features.Add (new Feature () { Name = mediaType, IsAvailable = true }); } features.Add (featGroup); // bind to the table tableSource = new ImagePickerScreen.FeaturesTableDataSource (features); tblFeatures.Source = tableSource; }
//================================================================================ //================================================================================ /// <summary> /// Fills the table with a list of available features /// </summary> protected void PopulateFeaturesTable() { //---- declare vars List <FeatureGroup> features = new List <FeatureGroup>(); FeatureGroup featGroup; string[] mediaTypes; //---- Sources featGroup = new FeatureGroup() { Name = "Sources" }; featGroup.Features.Add(new Feature() { Name = "Camera", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) }); featGroup.Features.Add(new Feature() { Name = "Photo Library", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) }); featGroup.Features.Add(new Feature() { Name = "Saved Photos Album", IsAvailable = UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) }); features.Add(featGroup); //---- Camera and Flash featGroup = new FeatureGroup() { Name = "Camera and Flash" }; featGroup.Features.Add(new Feature() { Name = "Front Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add(new Feature() { Name = "Front Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice(UIImagePickerControllerCameraDevice.Front) }); featGroup.Features.Add(new Feature() { Name = "Rear Camera", IsAvailable = UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear) }); featGroup.Features.Add(new Feature() { Name = "Rear Flash", IsAvailable = UIImagePickerController.IsFlashAvailableForCameraDevice(UIImagePickerControllerCameraDevice.Rear) }); features.Add(featGroup); //---- Camera Media Types featGroup = new FeatureGroup() { Name = "Camera Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); //---- Photo Library Media Types featGroup = new FeatureGroup() { Name = "Photo Library Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); //---- Saved Photos Album Media Types featGroup = new FeatureGroup() { Name = "Saved Photos Album Media Types" }; mediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.SavedPhotosAlbum); foreach (var mediaType in mediaTypes) { featGroup.Features.Add(new Feature() { Name = mediaType, IsAvailable = true }); } features.Add(featGroup); //---- bind to the table this._tableSource = new ImagePickerScreen.FeaturesTableDataSource(features); this.tblFeatures.Source = this._tableSource; }
/// <summary> /// Validate General GenBank Features /// </summary> /// <param name="nodeName">xml node name for different feature.</param> /// <param name="featureName">Name of the GenBank feature</param> private void ValidateGeneralGenBankFeatureQualifiers(string nodeName, FeatureGroup featureName) { // Get Values from XML node. string filePath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); // Parse a GenBank file. ISequenceParser parserObj = new GenBankParser(); { IEnumerable<ISequence> seqList = parserObj.Parse(filePath); // Validate ProteinBinding feature all qualifiers. var metadata = (GenBankMetadata) seqList.ElementAt(0).Metadata[Constants.GenBank]; switch (featureName) { case FeatureGroup.MiscStructure: ValidateGenBankMiscStructureFeature(nodeName, metadata); break; case FeatureGroup.TrnsitPeptide: ValidateGenBankTrnsitPeptideFeature(nodeName, metadata); break; case FeatureGroup.StemLoop: ValidateGenBankStemLoopFeature(nodeName, metadata); break; case FeatureGroup.ModifiedBase: ValidateGenBankModifiedBaseFeature(nodeName, metadata); break; case FeatureGroup.PrecursorRNA: ValidateGenBankPrecursorRNAFeature(nodeName, metadata); break; case FeatureGroup.PolySite: ValidateGenBankPolySiteFeature(nodeName, metadata); break; case FeatureGroup.MiscBinding: ValidateGenBankMiscBindingFeature(nodeName, metadata); break; case FeatureGroup.Enhancer: ValidateGenBankEnhancerFeature(nodeName, metadata); break; case FeatureGroup.GCSignal: ValidateGenBankGCSignalFeature(nodeName, metadata); break; case FeatureGroup.LTR: ValidateGenBankLTRFeature(nodeName, metadata); break; case FeatureGroup.Operon: ValidateGenBankOperon(nodeName, metadata); break; case FeatureGroup.UnsureSequenceRegion: ValidateGenBankUnsureSequenceRegion(nodeName, metadata); break; case FeatureGroup.NonCodingRNA: ValidateGenBankNonCodingRNA(nodeName, metadata); break; case FeatureGroup.CDS: ValidateGenBankCDSFeatures(nodeName, metadata); break; case FeatureGroup.RibosomeBindingSite: ValidateGenBankRibosomeBindingSite(nodeName, metadata); break; default: break; } // Log VSTest GUI. ApplicationLog.WriteLine( "GenBank Features P1: Successfully validated the GenBank Features"); } }
/// <summary> /// Validate GenBank Citation referenced present in GenBank Metadata. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="featureName">Feature Name</param> private void ValidateCitationReferenced(string nodeName, FeatureGroup featureName) { // Get Values from XML node. string filePath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); string expectedCitationReferenced = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.citationReferencedCount); string expectedmRNACitationReferenced = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.citationReferencedCount); string expectedExonACitationReferenced = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.ExonCitationReferencedCount); string expectedIntronCitationReferenced = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.IntronCitationReferencedCount); string expectedpromoterCitationReferenced = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.PromotersCitationReferencedCount); // Parse a GenBank file. ISequenceParser parserObj = new GenBankParser(); { ISequence seq = parserObj.ParseOne(filePath); var metadata = seq.Metadata[Constants.GenBank] as GenBankMetadata; List<CitationReference> citationReferenceList; // Get a list citationReferenced present in GenBank file. switch (featureName) { case FeatureGroup.CDS: FeatureItem cds = metadata.Features.CodingSequences[0]; citationReferenceList = metadata.GetCitationsReferredInFeature(cds); // Validate citation referenced present in CDS features. Assert.AreEqual(citationReferenceList.Count.ToString((IFormatProvider) null), expectedCitationReferenced); break; case FeatureGroup.mRNA: FeatureItem mRNA = metadata.Features.MessengerRNAs[0]; citationReferenceList = metadata.GetCitationsReferredInFeature(mRNA); // Validate citation referenced present in mRNA features. Assert.AreEqual(citationReferenceList.Count.ToString((IFormatProvider) null), expectedmRNACitationReferenced); break; case FeatureGroup.Exon: FeatureItem exon = metadata.Features.Exons[0]; citationReferenceList = metadata.GetCitationsReferredInFeature(exon); // Validate citation referenced present in Exons features. Assert.AreEqual(citationReferenceList.Count.ToString((IFormatProvider) null), expectedExonACitationReferenced); break; case FeatureGroup.Intron: FeatureItem introns = metadata.Features.Introns[0]; citationReferenceList = metadata.GetCitationsReferredInFeature(introns); // Validate citation referenced present in Introns features. Assert.AreEqual(citationReferenceList.Count.ToString((IFormatProvider) null), expectedIntronCitationReferenced); break; case FeatureGroup.Promoter: FeatureItem promoter = metadata.Features.Promoters[0]; citationReferenceList = metadata.GetCitationsReferredInFeature(promoter); // Validate citation referenced present in Promoters features. Assert.AreEqual(citationReferenceList.Count.ToString((IFormatProvider) null), expectedpromoterCitationReferenced); break; default: break; } } }
public IList <FeatureValue> Aggregate( IList <EncounterValues> values, RawRecord record, FeatureGroup featureGroup, FeatureSelectionContext context) { var wordAnalyses = new WordAnalysis[values.Count]; var hasNullWordAnalysis = false; for (var i = 0; i < values.Count; i++) { if (values[i].Encounter == RawWordEncounter.EmptyWordEncounter) { return(FeatureValue.NewArray(0, values[i].Values.Count)); } wordAnalyses[i] = context.Project.DataAnalysis.GetByName(values[i].Encounter.Word); if (wordAnalyses[i] == null) { hasNullWordAnalysis = true; } } var weights = new double[wordAnalyses.Length]; if (hasNullWordAnalysis) { var weight = 1d / wordAnalyses.Length; for (var i = 0; i < weights.Length; i++) { weights[i] = weight; } } else { var trainEncounters = new double[wordAnalyses.Length]; var trainEncountersSum = 0; for (var i = 0; i < weights.Length; i++) { var currentTrainingEncounters = wordAnalyses[i].TrainEncounters.Values .Sum(x => x.Encounters); trainEncounters[i] = currentTrainingEncounters; trainEncountersSum += currentTrainingEncounters; } if (trainEncountersSum == 0) { return(FeatureValue.NewArray(0, values[0].Values.Count)); } for (var i = 0; i < weights.Length; i++) { weights[i] = trainEncounters[i] / trainEncountersSum; } } var result = new float[values[0].Values.Count]; for (var vectorIndex = 0; vectorIndex < result.Length; vectorIndex++) { for (var encounterIndex = 0; encounterIndex < values.Count; encounterIndex++) { result[vectorIndex] += (float)(weights[encounterIndex] * values[encounterIndex].Values[vectorIndex].NumericValue); } } return(FeatureValue.NewArray(result)); }
static internal void FixPrestigeSpellbookSelection(string prestigeSpellbookSelectionId, string prestigeSpellbookSelectionWizardItemId, FeatureGroup group) { BlueprintFeatureSelection spellbookSelection = library.Get <BlueprintFeatureSelection>(prestigeSpellbookSelectionId); if (spellbookSelection == null) { string errorMsg = $"Error, Prestige Spellbook Selection {prestigeSpellbookSelectionId} not exist!"; logger.Error(errorMsg); throw new Exception(errorMsg); } var wizardFeature = spellbookSelection.AllFeatures.Cast <BlueprintFeatureReplaceSpellbook>() .First(f => f.AssetGuid == prestigeSpellbookSelectionWizardItemId); // Create a new feature for this archetype's spellbook string arcanistFeatureName = $"ArcanistClass{group.ToString()}ChosenItem"; var arcanistFeature = library.CopyAndAdd <BlueprintFeatureReplaceSpellbook>( wizardFeature, arcanistFeatureName, OtherUtils.GetMd5(arcanistFeatureName)); arcanistFeature.Spellbook = arcanist.Spellbook; arcanistFeature.SetName(arcanist.Name); var classSpellPreqComp = wizardFeature.GetComponent <PrerequisiteClassSpellLevel>(); if (classSpellPreqComp == null) { classSpellPreqComp = Helpers.Create <PrerequisiteClassSpellLevel>(a => { a.CharacterClass = arcanist; a.RequiredSpellLevel = 1; }); } else { classSpellPreqComp = UnityEngine.Object.Instantiate(classSpellPreqComp); classSpellPreqComp.CharacterClass = arcanist; } // Update the prerequisites. arcanistFeature.SetComponents(new BlueprintComponent[] { classSpellPreqComp }); // Add to the list of all features for this selector. var allFeatures = spellbookSelection.AllFeatures.ToList(); allFeatures.Add(arcanistFeature); spellbookSelection.AllFeatures = allFeatures.ToArray(); }