<commit_before>import {Injectable} from '@angular/core';
import MutationService from "./mutation.service";
import Gene from "../Models/gene";
import {SiteEnum} from "../Enums/site-enum";
import Site from "../Models/site";
import {Resolvable} from "../Abstract/resolvable";

@Injectable()
export default class GeneService implements Resolvable{
    protected _gene: Gene;

    constructor(private geneItem: Gene, private mutationService: MutationService) {
        let sites = this.getGeneSites();
        this._gene = new Gene(geneItem.name, sites);
    }

    getGeneSites():Site[]{
        let sites: Site[] = [];
        for(let i=0; i<this.geneItem.sites.length; i++ )
        {
            let randomValue = Math.random();
            let siteItem:SiteEnum;
            if(randomValue >= 0.8) siteItem = SiteEnum.A;
            else if(randomValue >= 0.6) siteItem = SiteEnum.C;
            else if(randomValue >= 0.4) siteItem = SiteEnum.G;
            else if(randomValue >= 0.2) siteItem = SiteEnum.T;
            else siteItem = SiteEnum.U;

            sites.push(new Site(siteItem));
        }
        return sites;
    }

    get gene(): Gene{
        return this.checkMutation(this._gene, this.mutationService.isEnabled);
    }
    checkMutation(gene:Gene, isMutationEnabled:boolean){
        gene.mutationSites = [];
        if(!isMutationEnabled){
            return this._gene
        };
        let mutatedGene: Gene = this.mutationService.mutateGene(gene);
        return mutatedGene;
    }
    switchGeneMutation(gene:Gene, isMutationEnabled:boolean){
        this.mutationService.isEnabled = isMutationEnabled;
        this.checkMutation(gene, isMutationEnabled);
    }
}<commit_msg>https://github.com/AndreyAttr/Evo/issues/57 using description of gene, using gene from constructor param instead of demo logic with random values generation.<commit_after>import {Injectable} from '@angular/core';
import MutationService from "./mutation.service";
import Gene from "../Models/gene";
import {SiteEnum} from "../Enums/site-enum";
import Site from "../Models/site";
import {Resolvable} from "../Abstract/resolvable";

@Injectable()
export default class GeneService implements Resolvable{
    constructor(private _gene: Gene, private mutationService: MutationService) {}

    // getGeneSites():Site[]{
    //     let sites: Site[] = [];
    //     for(let i=0; i<this.geneItem.sites.length; i++ )
    //     {
    //         let randomValue = Math.random();
    //         let siteItem:SiteEnum;
    //         if(randomValue >= 0.8) siteItem = SiteEnum.A;
    //         else if(randomValue >= 0.6) siteItem = SiteEnum.C;
    //         else if(randomValue >= 0.4) siteItem = SiteEnum.G;
    //         else if(randomValue >= 0.2) siteItem = SiteEnum.T;
    //         else siteItem = SiteEnum.U;
    //
    //         sites.push(new Site(siteItem));
    //     }
    //     return sites;
    // }

    get gene(): Gene{
        return this.checkMutation(this._gene, this.mutationService.isEnabled);
    }
    checkMutation(gene:Gene, isMutationEnabled:boolean){
        gene.mutationSites = [];
        if(!isMutationEnabled){
            return this._gene
        };
        let mutatedGene: Gene = this.mutationService.mutateGene(gene);
        return mutatedGene;
    }
    switchGeneMutation(gene:Gene, isMutationEnabled:boolean){
        this.mutationService.isEnabled = isMutationEnabled;
        this.checkMutation(gene, isMutationEnabled);
    }
}
{'fraction_non_alphanumeric': 0.12734082397003746, 'fraction_numerical': 0.005762028233938346, 'mean_word_length': 2.6016597510373445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2263236', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1008, 'n_words': 227}