SHARE
TWEET

ENTIDADE

a guest Jan 26th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 'use strict'
  3.  
  4. const lodash = use('lodash');
  5.  
  6. class DnaItensEntity {
  7.     constructor() {
  8.         this.limit = 4;
  9.     }
  10.  
  11.     checkSequence(object) {
  12.         return Object.keys(object).filter(elem => object[elem] == this.limit);
  13.     }
  14.  
  15.     verifyIsSimian(dnas) {
  16.         const simianScore = { A: 0, T: 0, C: 0, G: 0 }
  17.         const resultIsSimian = [];
  18.  
  19.         for (let dna in dnas) {
  20.             let is_simian = false;
  21.             const value = dnas[dna];
  22.             const arrayValues = value.split('');
  23.             arrayValues.some(elem => {
  24.                 const itemUpperCase = elem.toUpperCase();;
  25.                 if (simianScore.hasOwnProperty(itemUpperCase)) {
  26.                     const actualCount = simianScore[itemUpperCase];
  27.                     simianScore[itemUpperCase] = (actualCount < this.limit) ? (actualCount + 1) : actualCount;
  28.                     is_simian = true;
  29.                 }
  30.             });
  31.             resultIsSimian.push({ value, is_simian })
  32.         }
  33.  
  34.         const resultCheckSequence = this.checkSequence(simianScore);
  35.  
  36.         return { isSimian: (resultCheckSequence.length != 0), resultIsSimian }
  37.     }
  38.  
  39.     handleCreate(dna_id, itens) {
  40.         let newItens = [];
  41.         for (let item in itens) {
  42.             const actual = Object.assign(itens[item], { dna_id });
  43.             newItens.push(actual)
  44.         }
  45.         return newItens;
  46.     }
  47.  
  48.     compare($data, $input) {
  49.         let haveDifference = []
  50.         const teste = lodash.groupBy($data, 'dna_id');
  51.         const newteste = Object.keys(teste).map(item => {
  52.             const sjkjlksd = teste[item].map(i => i.value);
  53.  
  54.             const assaakls = lodash.differenceWith($input, sjkjlksd, lodash.isEqual);
  55.             if (!assaakls.length) {
  56.                 haveDifference.push(assaakls);
  57.             }
  58.         })
  59.         return haveDifference;
  60.     }
  61. }
  62.  
  63. module.exports = { DnaItensEntity }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top