public void Crossover_TwoChromosomesOnePercentProbability_CrossoverNotHappend() { var probability = 0.1m; var representation1 = new IGene <decimal> [2]; var representation2 = new IGene <decimal> [2]; var gene1Representation = new[] { 1.2m, 1.3m, 1.4m, 1.5m }; var gene2Representation = new[] { 1.6m, 1.7m, 1.8m, 1.9m }; var gene3Representation = new[] { 2.6m, 2.7m, 2.8m, 2.9m }; representation1[0] = new Gene <decimal>(gene1Representation, probability); representation1[1] = new Gene <decimal>(gene2Representation, probability); representation2[0] = new Gene <decimal>(gene1Representation, probability); representation2[1] = new Gene <decimal>(gene3Representation, probability); var x = new Chromosome <decimal>(representation1); var y = new Chromosome <decimal>(representation2); var crossover = new Crossover(0.01m); var crossed = crossover.RunCrossover(x, y, probability); Assert.AreEqual(crossed.Representation[1].Representation[0], gene2Representation[0]); Assert.AreEqual(crossed.Representation[1].Representation[1], gene2Representation[1]); Assert.AreEqual(crossed.Representation[1].Representation[2], gene2Representation[2]); Assert.AreEqual(crossed.Representation[1].Representation[3], gene2Representation[3]); }
public GeneComparerTests() { _geneA = new Gene(ChromosomeUtilities.Chr1, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneB = new Gene(ChromosomeUtilities.Chr1, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneC = new Gene(ChromosomeUtilities.Chr1, 101, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneComparer = new GeneComparer(); }
/// <summary> /// Get a list of the genes that have not been taken before. This is useful /// if you do not wish the same gene to appear more than once in a /// chromosome. /// </summary> /// <param name="source">The pool of genes to select from.</param> /// <param name="taken">An array of the taken genes.</param> /// <returns>Those genes in source that are not taken.</returns> private static IGene GetNotTaken(Chromosome source, IList <IGene> taken) { int geneLength = source.Genes.Count; for (int i = 0; i < geneLength; i++) { IGene trial = source.Genes[i]; bool found = false; foreach (IGene current in taken) { if (current.Equals(trial)) { found = true; break; } } if (!found) { taken.Add(trial); return(trial); } } return(null); }
public void DisplacementOperatorShouldReturnCorrectChildren() { IGene[] parent = new IGene[] { new UintGene(1), new UintGene(2), new UintGene(3), new UintGene(4), new UintGene(5), new UintGene(6), new UintGene(7), new UintGene(8), new UintGene(9) }; IGene[] expectedChild = new IGene[] { new UintGene(4), new UintGene(5), new UintGene(6), new UintGene(1), new UintGene(2), new UintGene(3), new UintGene(7), new UintGene(8), new UintGene(9) }; int startPoint = 3, destPoint = 0, length = 3; var swap = new DisplacementOperator(); swap.Run(parent, startPoint, destPoint, length); bool areChildrenEqual = true; for (int i = 0; i < expectedChild.Length; ++i) { areChildrenEqual &= expectedChild[i].Equals(parent[i]); } Assert.AreEqual(true, areChildrenEqual); }
private ScatterViewItem _myDadSVI; //The scatterviewitem that has me as a DataContext //private double _verticalScrollOffset; //private ScatterViewItem _myUncleSVI; //The scatterviewitem that is aligned. Hook our scroll viewers //private SurfaceScrollViewer _mySurfaceScrollViewer; public TranslationViewModel(SurfaceWindow1ViewModel mainVM, IGene model) { _mainVM = mainVM; _model = model; _background = new SolidColorBrush(Colors.Black); //_myUncleSVI = null; //Nothing is aligned to me yet }
private void Mutate(IGenome genome, double soften = 1) { if (new Random().NextDouble() < GenerationParameters.MutateAddNodeProbability / Math.Max(soften, 1)) { genome.MutateAddNode(); } else if (new Random().NextDouble() < GenerationParameters.MutateAddGeneProbability / Math.Max(soften, 1)) { genome.MutateAddGene(Population.Genomes.SelectMany(g => g.Genes)); } else { if (new Random().NextDouble() < GenerationParameters.MutateAllGeneWeightsProbability) { genome.MutateGeneWeights(GeneMutationType.AdjustWeight, GeneParameters.MutateGeneWeightFactor, 1); } if (new Random().NextDouble() < GenerationParameters.MutateGeneExpressionProbability) { genome.MutateGeneExpression(); } if (new Random().NextDouble() < GenerationParameters.MutateGeneReExpressionProbability) { genome.MutateGeneReExpress(); } IGene geneCandidate = genome.Genes[new Random().Next(genome.Genes.Count)]; if (new Random().NextDouble() < GenerationParameters.MutateGeneWeightProbability) { geneCandidate.MutateWeight(GeneMutationType.AdjustWeight, GeneParameters.MutateGeneWeightFactor); } } }
public IList<IPublication> GetResults(IGene gene) { //if (!String.IsNullOrEmpty(geneName)) //{ // PubMedParser parser = new PubMedParser(geneName); // return parser.getPublicationsFromHTML(); //} //if the gene has a name, use name as keyword, else use Locus Tag (Locus Tag with no results //will be handled within getPublicationsFromHTML() from PubMedParser.cs if (!String.IsNullOrEmpty(gene.Name)) { PubMedParser parser = new PubMedParser(gene.Name); return parser.getPublicationsFromHTML(); } else if (!String.IsNullOrEmpty(gene.LocusTag)) { PubMedParser parser = new PubMedParser(gene.LocusTag); return parser.getPublicationsFromHTML(); } else { return new List<IPublication>(); } }
public void Run(IGene[] parent1, IGene[] parent2, out IGene[] child1, out IGene[] child2, bool[] mask) { int geneCount = parent1.Count(); IGene[] c1 = new IGene[geneCount]; IGene[] c2 = new IGene[geneCount]; for (int index = 0; index < mask.Length; ++index) { if (mask[index]) { c1[index] = parent1[index]; c2[index] = parent2[index]; } } int firstParentIndex = 0, secondParentIndex = 0; for (int index = 0; index < mask.Length; ++index) { if (!mask[index]) { MoveGenesInZeroPositions(parent2, c1, index, ref secondParentIndex); MoveGenesInZeroPositions(parent1, c2, index, ref firstParentIndex); } } child1 = c1; child2 = c2; }
public Transcript(IChromosome chromosome, int start, int end, ICompactId id, ITranslation translation, BioType bioType, IGene gene, int totalExonLength, byte startExonPhase, bool isCanonical, ITranscriptRegion[] transcriptRegions, ushort numExons, IInterval[] microRnas, int siftIndex, int polyPhenIndex, Source source, bool cdsStartNotFound, bool cdsEndNotFound, int[] selenocysteines, IRnaEdit[] rnaEdits) { Chromosome = chromosome; Start = start; End = end; Id = id; Translation = translation; BioType = bioType; Gene = gene; TotalExonLength = totalExonLength; StartExonPhase = startExonPhase; IsCanonical = isCanonical; TranscriptRegions = transcriptRegions; NumExons = numExons; MicroRnas = microRnas; SiftIndex = siftIndex; PolyPhenIndex = polyPhenIndex; Source = source; CdsStartNotFound = cdsStartNotFound; CdsEndNotFound = cdsEndNotFound; Selenocysteines = selenocysteines; RnaEdits = rnaEdits; }
protected override IEnumerable <(IGene Root, string Origin)> GetVariations(IGene source) { //var sourceTree = Catalog.Factory.Map(source); //var descendantNodes = sourceTree.GetDescendantsOfType().ToArray(); //var count = descendantNodes.Length; return(null); //int i; //// Remove genes one at a time. //for (i = 0; i < count; i++) // if (Catalog.Variation.TryRemoveValid(descendantNodes[i], out var pruned)) // yield return (pruned, "Remove descendant by index"); //for (i = 0; i < count; i++) //{ // yield return ( // Catalog.Variation.PromoteChildren(descendantNodes[i]), // "Promote descendant children"); // // Let mutation take care of this... // // foreach (var fn in Operators.Available.Functions) // // { // // yield return VariationCatalog.ApplyFunction(source, i, fn); // // } //} //if (source is IParent) //{ // var paramExpIncrease = Catalog.Variation.IncreaseParameterExponents(source); // if (paramExpIncrease != source) // { // yield return (paramExpIncrease, // "Increase all parameter exponent"); // } //} //for (i = 0; i < count; i++) // yield return ( // Catalog.AddConstant(descendantNodes[i], 2), // "Add constant to descendant"); // 2 ensures the constant isn't negated when adding to a product. //sourceTree.Recycle(); //if (!(reduced is Sum<double> sum)) yield break; //sourceTree = Catalog.Factory.Map(reduced); //var clonedChildren = sourceTree.Children.Where(c => c.Value is IConstant<double>).ToArray(); //if (sourceTree.Count > clonedChildren.Length) //{ // foreach (var c in clonedChildren) // c.Detatch(); //} //var next = Catalog.FixHierarchy(sourceTree).Recycle(); //sourceTree.Recycle(); //yield return (Catalog.GetReduced(next), "Constants Stripped"); //if (sum.TryExtractGreatestFactor(Catalog, out var extracted, out _)) // yield return (extracted, "GCF Extracted Reduction"); }
public void SwapOperatorShouldReturnCorrectChildren() { IGene[] parent = new IGene[] { new UintGene(1), new UintGene(2), new UintGene(3), new UintGene(4), new UintGene(5), new UintGene(6), new UintGene(7), new UintGene(8), new UintGene(9) }; IGene[] expectedChild = new IGene[] { new UintGene(1), new UintGene(2), new UintGene(3), new UintGene(8), new UintGene(5), new UintGene(6), new UintGene(7), new UintGene(4), new UintGene(9) }; int poiont1 = 3, poiont2 = 7; var swap = new SwapOperator(); swap.Run(parent, poiont1, poiont2); bool areChildrenEqual = true; for (int i = 0; i < expectedChild.Length; ++i) { areChildrenEqual &= expectedChild[i].Equals(parent[i]); } Assert.AreEqual(true, areChildrenEqual); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// A new solution instance gets a reference to the same problem /// and a new route list instance with the same references. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> public override object Clone() { IGene[] newGenes = new IGene[Genes.Length]; Array.Copy(Genes, newGenes, Genes.Length); Solution copy = new Solution((VrptwProblem)Problem, newGenes); return(copy); }
public IGene Mate(IGene other) { NQueenGene ret = other.Clone() as NQueenGene; for (int i = 0; i < ret.queen_location_.Length / 2; i++) { ret.queen_location_[i] = queen_location_[i]; } return ret; }
// override object.Equals public bool Equals(IGene obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } return(((Location)obj).Id == this.Id); }
public Character Mutate(Character c, double probability) { IGene[] genes = new IGene[c.Genes.Length]; for (var i = 0; i < c.Genes.Length; i++) { genes[i] = rnd.NextDouble() < probability ? c.Genes[i].Mutate() : c.Genes[i]; } return(new Character(c.CharacterType, genes)); }
public GeneComparerTests() { var chromosome = new Chromosome("chr1", "1", 0); _geneA = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneB = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneC = new Gene(chromosome, 101, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneComparer = new GeneComparer(); }
public ICollection <Character> Crossover(Character c1, Character c2) { int s = c1.Genes.Length; int p = rnd.Next(s + 1); var genes1 = new IGene[s]; var genes2 = new IGene[s]; c1.Genes[..p].CopyTo(genes1);
/// <summary> /// Copy from another gene. /// </summary> /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { NEATLinkGene other = (NEATLinkGene)gene; this.Enabled = other.Enabled; fromNeuronID = other.fromNeuronID; toNeuronID = other.toNeuronID; this.InnovationId = other.InnovationId; recurrent = other.recurrent; weight = other.weight; }
/// <summary> /// Copy another gene to this one. /// </summary> /// /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { var other = (NEATNeuronGene)gene; activationResponse = other.activationResponse; Id = other.Id; neuronType = other.neuronType; recurrent = other.recurrent; splitX = other.splitX; splitY = other.splitY; }
public void CopyTest() { IGene gene = new Gene(new Node(NodeType.Hidden), new Node(NodeType.Hidden), 1); IGene copiedGene = gene.Copy(); Assert.AreEqual(gene.Innovation, copiedGene.Innovation); Assert.AreEqual(gene.IsExpressed, copiedGene.IsExpressed); Assert.AreEqual(gene.NodeIn.Id, copiedGene.NodeIn.Id); Assert.AreEqual(gene.NodeOut.Id, copiedGene.NodeOut.Id); Assert.AreEqual(gene.Weight, copiedGene.Weight); }
public override Chromosome RandomNeighbourSolution(Chromosome chromosome, MutationOperator neighbourhood) { int size = chromosome.Size(); IGene[] newGenes = new IGene[size]; Array.Copy(chromosome.Genes, newGenes, size); neighbourhood.Run(newGenes); Chromosome result = new Solution(chromosome.Problem as VrptwProblem, newGenes); return(result); }
public bool IsSameAs(IGene other) { var otherFixture = other as Fixture; if (otherFixture == null) { return false; } var otherHomeTeam = otherFixture.HomeTeam; var otherAwayTeam = otherFixture.AwayTeam; return HomeTeam.Equals(otherHomeTeam) && AwayTeam.Equals(otherAwayTeam); }
public ICollection <Character> Crossover(Character c1, Character c2) { int s = c1.Genes.Length; int p1 = rnd.Next(s + 1); int p2 = rnd.Next(s + 1); (p1, p2) = (Math.Min(p1, p2), Math.Max(p1, p2)); var genes1 = new IGene[s]; var genes2 = new IGene[s]; c1.Genes[..p1].CopyTo(genes1);
private void WriteGene(IGene gene, IRequiredFields requiredFields, string geneId, int internalGeneId) { if (_observedGenes.Contains(internalGeneId)) { return; } _observedGenes.Add(internalGeneId); var gffGene = GetGene(gene, geneId); _writer.WriteGene(gffGene, requiredFields, internalGeneId); }
public void MutateGeneExpression() { IGene gene = Genes[new Random().Next(Genes.Count)]; Genes[new Random().Next(Genes.Count)].MutateExpression(); // Avoid Node Isolation if (!gene.IsExpressed && !Genes.Any(g => g.NodeIn == gene.NodeIn)) { gene.MutateExpressionEnable(); } }
public override void Run(IGene[] parent1, IGene[] parent2, out IGene[] child1, out IGene[] child2) { int customerCount = parent1.Count(); IGene[] c1 = new IGene[customerCount]; IGene[] c2 = new IGene[customerCount]; int slicePoint = RandomGeneratorThreadSafe.NextInt(customerCount); DoCycleCrossover(parent1, parent2, c1, c2, slicePoint, true); child1 = c1; child2 = c2; }
public IGene MutateAddGene(IEnumerable <IGene> genePool) { // Select two nodes at random to connect List <INode> nodeOutCandidates = Nodes.ToList(); if (!GenomeParameters.AllowOutputOutGenes) { nodeOutCandidates = nodeOutCandidates.Where(n => n.Type != NodeType.Output).ToList(); } INode nodeOut = nodeOutCandidates[new Random().Next(nodeOutCandidates.Count)]; // Get existing connections for this node List <IGene> existingConnectionsIn = Genes.Where(cg => cg.NodeIn == nodeOut).ToList(); List <IGene> existingConnectionsOut = Genes.Where(cg => cg.NodeOut == nodeOut).ToList(); // Discover nodes where no connection currently exists List <INode> nodeInCandidates = Nodes .Except(existingConnectionsIn.Select(g => g.NodeOut)) .Except(existingConnectionsOut.Select(g => g.NodeIn)).ToList(); // Don't allow input to input or output to output connections if (nodeOut.Type == NodeType.Input || nodeOut.Type == NodeType.Output) { nodeInCandidates = nodeInCandidates.Where(n => n.Type != nodeOut.Type).ToList(); } if (nodeOut.Type == NodeType.Hidden || nodeOut.Type == NodeType.Output) { nodeInCandidates = nodeInCandidates.Where(n => n.Type != NodeType.Input).ToList(); } if (nodeInCandidates.Count > 0) { INode selectedNodeIn = nodeInCandidates[new Random().Next(nodeInCandidates.Count)]; IGene existingGene = genePool.FirstOrDefault(gp => gp.NodeIn.Id == selectedNodeIn.Id && gp.NodeOut.Id == nodeOut.Id); // Create the connection IGene gene = new Gene( nodeOut, selectedNodeIn, existingGene != null ? existingGene.Innovation : GetNextInnovation() ); Genes.Add(gene); return(gene); } return(null); }
/// <summary> /// Fills empty place in chromosome with genes from second parent. /// </summary> /// <param name="childPosition">Index in child chromosome.</param> /// <param name="sourceParentPosition">Index in parent chromosome.</param> /// <param name="sourceParent">Source of genes.</param> /// <param name="child">Output child.</param> private void FillEmptyGenes(int childPosition, ref int sourceParentPosition, IGene[] sourceParent, IGene[] child) { for (int j = 0; j < child.Length; ++j) { sourceParentPosition = (++sourceParentPosition) % child.Length; IGene inner = sourceParent[sourceParentPosition]; if (!child.Contains(inner)) { child[childPosition] = inner; break; } } }
public void AssignGene(IGene gene) { if (genes == null) { genes = new Dictionary <char, IGene>(); } if (genes.ContainsKey(gene.ID)) { throw new System.Exception("Genes must have unique IDs/cannot be assigned twice"); } genes.Add(gene.ID, gene); gene.Controller = GetComponent <CarController>(); }
private void Inverse(IGene[] genes, int startPosition, int length) { int index1, index2; for (int i = 0; i < length / 2; ++i) { index1 = startPosition + i; index2 = startPosition + length - i - 1; IGene tmp = genes[index1]; genes[index1] = genes[index2]; genes[index2] = tmp; } }
public void AddGene(IGene gene) { var name = gene.Allele.Name; if (Genes.ContainsKey(name)) { AddDuplicateGene(gene); } else { Genes.Add(name, gene); } }
public TranscriptCacheReaderTests() { var chr1 = new Chromosome("chr1", "1", 0); var chr2 = new Chromosome("chr2", "2", 1); var chr3 = new Chromosome("chr3", "3", 2); _refIndexToChromosome = new Dictionary <ushort, IChromosome> { [chr1.Index] = chr1, [chr2.Index] = chr2, [chr3.Index] = chr3 }; const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38; var baseHeader = new Header("test", 2, 3, Source.BothRefSeqAndEnsembl, 4, genomeAssembly); var customHeader = new TranscriptCacheCustomHeader(1, 2); _expectedHeader = new CacheHeader(baseHeader, customHeader); var transcriptRegions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 1, 100, 199, 300, 399), new TranscriptRegion(TranscriptRegionType.Intron, 1, 200, 299, 399, 400), new TranscriptRegion(TranscriptRegionType.Exon, 2, 300, 399, 400, 499) }; var mirnas = new IInterval[2]; mirnas[0] = new Interval(100, 200); mirnas[1] = new Interval(300, 400); var peptideSeqs = new[] { "MASE*" }; var genes = new IGene[1]; genes[0] = new Gene(chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"), CompactId.Convert("ENSG00000141510")); var regulatoryRegions = new IRegulatoryRegion[2]; regulatoryRegions[0] = new RegulatoryRegion(chr3, 1200, 1300, CompactId.Convert("123"), RegulatoryRegionType.enhancer); regulatoryRegions[1] = new RegulatoryRegion(chr3, 1250, 1450, CompactId.Convert("456"), RegulatoryRegionType.enhancer); var regulatoryRegionIntervalArrays = regulatoryRegions.ToIntervalArrays(3); var transcripts = GetTranscripts(chr3, genes, transcriptRegions, mirnas); var transcriptIntervalArrays = transcripts.ToIntervalArrays(3); _expectedCacheData = new TranscriptCacheData(_expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs, transcriptIntervalArrays, regulatoryRegionIntervalArrays); }
private static Stream GetCacheStream() { const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38; var baseHeader = new Header("test", 2, 3, Source.BothRefSeqAndEnsembl, 4, genomeAssembly); var customHeader = new TranscriptCacheCustomHeader(1, 2); var expectedHeader = new CacheHeader(baseHeader, customHeader); var transcriptRegions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 1, 100, 199, 300, 399), new TranscriptRegion(TranscriptRegionType.Intron, 1, 200, 299, 399, 400), new TranscriptRegion(TranscriptRegionType.Exon, 2, 300, 399, 400, 499) }; var mirnas = new IInterval[2]; mirnas[0] = new Interval(100, 200); mirnas[1] = new Interval(300, 400); var peptideSeqs = new[] { "MASE*" }; var genes = new IGene[1]; genes[0] = new Gene(ChromosomeUtilities.Chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"), CompactId.Convert("ENSG00000141510")); var regulatoryRegions = new IRegulatoryRegion[2]; regulatoryRegions[0] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1200, 1300, CompactId.Convert("123"), RegulatoryRegionType.enhancer); regulatoryRegions[1] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1250, 1450, CompactId.Convert("456"), RegulatoryRegionType.enhancer); var regulatoryRegionIntervalArrays = regulatoryRegions.ToIntervalArrays(3); var transcripts = GetTranscripts(ChromosomeUtilities.Chr3, genes, transcriptRegions, mirnas); var transcriptIntervalArrays = transcripts.ToIntervalArrays(3); var expectedCacheData = new TranscriptCacheData(expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs, transcriptIntervalArrays, regulatoryRegionIntervalArrays); var ms = new MemoryStream(); using (var writer = new TranscriptCacheWriter(ms, expectedHeader, true)) { writer.Write(expectedCacheData); } ms.Position = 0; return(ms); }
/// <summary> /// Crossover this gene with another of the same type. /// </summary> /// <typeparam name="TGene"></typeparam> /// <param name="gene"></param> /// <param name="other"></param> /// <param name="settings"></param> /// <returns></returns> public static TGene Crossover <TGene>(this TGene gene, TGene other, GeneticAlgorithmSettings settings) where TGene : IGene { IGene result = gene.Crossover((IGene)other, settings); if (result != null && result is TGene) { return((TGene)result); } else { return(default(TGene)); } }
public List<IGene> CrossOver(IGene _gene1, IGene _gene2) { List<IGene> nextGeneration = new List<IGene>(2); int maskbit = R.Next(0, _gene1.Size); IGene meme1 = _gene1.Copy(); IGene meme2 = _gene2.Copy(); for (int j = maskbit; j < _gene1.Size; j++) { meme1[j] = _gene2[j]; meme2[j] = _gene1[j]; } nextGeneration.Add(meme1); nextGeneration.Add(meme2); return nextGeneration; }
public List<IGene> CrossOver(IGene _gene1, IGene _gene2) { List<IGene> nextGeneration = new List<IGene>(2); int[] mask = new int[_gene1.Size]; for (int j = 0; j < _gene1.Size; j++) { mask[j] = R.Next(0, 2); } IGene meme1 = _gene1.Copy(); IGene meme2 = _gene2.Copy(); for (int j = 0; j < _gene1.Size; j++) { if (mask[j] == 1) { meme1[j] = _gene2[j]; meme2[j] = _gene1[j]; } } nextGeneration.Add(meme1); nextGeneration.Add(meme2); return nextGeneration; }
public override void Copy(IGene gene) { NEATNeuronGene gene2 = (NEATNeuronGene) gene; if (0 == 0) { this.activationResponse = gene2.activationResponse; base.Id = gene2.Id; if (0 == 0) { this.neuronType = gene2.neuronType; this.recurrent = gene2.recurrent; if (0 == 0) { goto Label_000A; } } return; } Label_000A: this.splitX = gene2.splitX; this.splitY = gene2.splitY; }
/// <summary> /// Copy from another gene. /// </summary> /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { var other = (NEATLinkGene) gene; Enabled = other.Enabled; fromNeuronID = other.fromNeuronID; toNeuronID = other.toNeuronID; InnovationId = other.InnovationId; recurrent = other.recurrent; weight = other.weight; }
public int CompareTo(IGene _other) { return this.Fitness.CompareTo(_other.Fitness) * -1; }
/// <summary> /// Copy another gene to this one. /// </summary> public override sealed void Copy(IGene gene) { Value = ((IntegerGene) gene).Value; }
public override sealed void Copy(IGene gene) { this._xbcea506a33cf9111 = ((DoubleGene) gene).Value; }
/// <summary> /// Copy another gene to this one. /// </summary> /// /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { var other = (NEATNeuronGene) gene; activationResponse = other.activationResponse; Id = other.Id; neuronType = other.neuronType; recurrent = other.recurrent; splitX = other.splitX; splitY = other.splitY; }
/// <summary> /// Given a selected iGEM object, this method creates the Primer Designer main page with the relevant information, /// including the primer sequences, name, base pairs, and relevant directions. Handles the logic for creating a new /// gene. /// /// Params: an IGene object selected by the user /// </summary> /// <param name="gene">the IGene object selected from G-Nome Surfer Pro</param> private void ChangeGene(IGene gene) { if (gene != null) { _gene = gene; // updates lenght and displays accordingly _rightLength = 5; _leftLength = 5; rightLength.Content = 5; leftLength.Content = 5; // updates sequence and primer sequences String sequence = (gene.Sequence).ToUpper(); _leftSequence = (sequence).Substring(0, 40); leftSequence.Text = _leftSequence; _rightSequence = (sequence).Substring(sequence.Length - 40, 40); rightSequence.Text = _rightSequence; _leftPrimer = leftGetPrimer(_leftLength, _leftSequence); _rightPrimer = rightGetPrimer(_rightLength, _rightSequence); //updates the name of the gene and total base pairs if (gene.Name != null) geneNameLabel.Content = gene.Name; else geneNameLabel.Content = ""; geneBPLabel.Content = (Math.Abs(gene.RightBasePair - gene.LeftBasePair)) + " bp"; // updates the display to show all tests with a blank box (incomplete) rightBlastResult.Content = "x"; leftBlastResult.Content = "x"; leftHairpinResult.Content = "x"; rightHairpinResult.Content = "x"; leftSelfDimerResult.Content = "x"; rightSelfDimerResult.Content = "x"; leftHeteroDimerResult.Content = "x"; rightHeteroDimerResult.Content = "x"; //update visibility of test tips // calculates and displays Gibb's Free and temperature rightGibbsFree.Content = calcDeltaG(_rightPrimer); leftGibbsFree.Content = calcDeltaG(_leftPrimer); _leftTemp = leftCalculateTemp(_leftSequence, _leftLength); _rightTemp = rightCalculateTemp(_leftSequence, _rightLength); leftTemp.Content = _leftTemp; temp.Content = _rightTemp; rightTempResult.Content = updateTempResults(_leftTemp, _rightTemp); leftTempResult.Content = updateTempResults(_leftTemp, _rightTemp); // displays the highlighters at appropriate spot rightHighlight.Center = new Point(925, 625); rightHighlight.Width = 100; leftHighlight.Center = new Point(100, 350); leftHighlight.Width = 100; // updates length so minimum of 10 bp to start _rightLength = 10; _leftLength = 10; rightLength.Content = 10; leftLength.Content = 10; // Restriction Enzyme Cut Sites List<int> rightCutSites = generateCutSites(_rightSequence, rightRestrictionCutSequences); List<int> leftcutSites = generateCutSites(_leftSequence, leftRestrictionCutSequences); restrictionWarningGrid(rightCutSites, rightSequenceRestrictionLayer); restrictionWarningGrid(leftcutSites, leftSequenceRestrictionLayer); // draws gene and primer triangles on display depending on the orientation of the given gene genePolygon.Points = new PointCollection(); leftPrimerPolygon.Points = new PointCollection(); rightPrimerPolygon.Points = new PointCollection(); if (gene.IsForward) { foreach (Point p in forwardGenePolygonPoints) genePolygon.Points.Add(p); foreach (Point p in leftForwardPrimerPolygonPoints) leftPrimerPolygon.Points.Add(p); foreach (Point p in rightForwardPrimerPolygonPoints) rightPrimerPolygon.Points.Add(p); } else { foreach (Point p in reverseGenePolygonPoints) genePolygon.Points.Add(p); foreach (Point p in leftReversePrimerPolygonPoints) leftPrimerPolygon.Points.Add(p); foreach (Point p in rightReversePrimerPolygonPoints) rightPrimerPolygon.Points.Add(p); } } }
/// <summary> /// from Encog.ml.genetic.genes.Gene /// </summary> /// public abstract void Copy(IGene gene);
private void GeneSearchCallback(IGene result) { if (result == null) { GeneSearchStatus = GeneSearchStatusEnum.GeneNotFound; return; } GeneSearchStatus = GeneSearchStatusEnum.Idle; _onGeneSelected(result); }
private void RenderSequenceView(IGene gene) { SequenceViewModel sequenceViewModel = new SequenceViewModel(this, gene); int size = _allObjectsCollection.Add(sequenceViewModel); }
/// <summary> /// Add a gene. /// </summary> /// /// <param name="gene">The gene to add.</param> public void Add(IGene gene) { _genes.Add(gene); }
private void RenderTranslationView(IGene gene) { TranslationViewModel translationViewModel = new TranslationViewModel(this, gene); _allObjectsCollection.Add(translationViewModel); }
/// <summary> /// Copy another gene to this one. /// </summary> /// <param name="gene">The other gene to copy.</param> public override void Copy(IGene gene) { Value = ((DoubleGene)gene).Value; }
public override void Copy(IGene gene) { NEATLinkGene gene2 = (NEATLinkGene) gene; base.Enabled = gene2.Enabled; this.fromNeuronID = gene2.fromNeuronID; this.toNeuronID = gene2.toNeuronID; if (0 == 0) { base.InnovationId = gene2.InnovationId; this.recurrent = gene2.recurrent; this.weight = gene2.weight; } }
public VisualGene(IGene model, double pixelsPerBasePair) { _model = model; _name = model.Name; _leftPosition = model.LeftBasePair * pixelsPerBasePair; _length = (model.RightBasePair - model.LeftBasePair) * pixelsPerBasePair; _direction = model.IsForward ? GeneDirection.Forward : GeneDirection.Reverse; _locusTag = model.LocusTag; // Define the points in the pentagon container _pentagonPoints = new PointCollection(5); double rectangleLength = _length > _height / 2 ? _length - _height / 2 : 0; if (_direction == GeneDirection.Forward) { _pentagonPoints.Add(new Point(0, 0)); _pentagonPoints.Add(new Point(rectangleLength, 0)); _pentagonPoints.Add(new Point(_length, _height / 2)); _pentagonPoints.Add(new Point(rectangleLength, _height)); _pentagonPoints.Add(new Point(0, _height)); } else { _pentagonPoints.Add(new Point(0, _height / 2)); _pentagonPoints.Add(new Point(_height / 2, _height)); _pentagonPoints.Add(new Point(_height / 2 + rectangleLength, _height)); _pentagonPoints.Add(new Point(_height / 2 + rectangleLength, 0)); _pentagonPoints.Add(new Point(_height / 2, 0)); } }
private void PanToGene(IGene gene) { _chromosomeBarViewModel.CentralBasePair = gene.LeftBasePair; }
/// <summary> /// The provided IGene must be an IGEPGene. /// </summary> /// <param name="gene"></param> /// <returns></returns> new public IGEPGene Add(IGene gene) { return this.Add((IGEPGene) gene); }
private void RenderNotesView(IGene gene) { NotesViewModel notesViewModel = new NotesViewModel(gene); _allObjectsCollection.Add(notesViewModel); }
/// <summary> /// Copy another gene to this gene. /// </summary> /// /// <param name="gene">The source gene.</param> public override sealed void Copy(IGene gene) { _value = ((CharGene) gene).Value; }
public NotesViewModel(IGene model) { _model = model; }
/// <summary> /// Gets the percentage that IGene one and IGene two are similar. /// 100% would be identical and 0% would indicate that the IGenes share nothing. /// </summary> /// <param name="one">The first IGene to compare.</param> /// <param name="two">The second IGene to compare.</param> /// <returns>The percentage that IGene one and IGene two are similar. /// 100% would be identical and 0% would indicate that the IGenes share nothing.</returns> public override double GetPercentageIGeneSimilarity(IGene one, IGene two) { return this.GetPercentageIGeneSimilarityDelegate(one: one, two: two); }
public void ShowDesigner(IGene gene) { this.Gene = gene; this.DesignerVisibility = Visibility.Visible; }
/// <inheritdoc/> public int CompareTo(IGene o) { return ((int) (InnovationId - o.InnovationId)); }
private void RenderPublicationsView(IGene gene) { PublicationsViewModel publicationsViewModel = new PublicationsViewModel(this, gene); _allObjectsCollection.Add(publicationsViewModel); }