.SDcols = names(DT)]  534.5416  540.0630  602.4990  545.5845  636.4777  727.3708     3
      DT[, lapply(names(DT), function(x) get(x)/sum(get(x)))]  248.1819  381.0036  440.7233  513.8254  536.9940  560.1625     3
                  melt(DT)[, value/sum(value), by = variable] 1219.2584 1250.5846 1425.0604 1281.9107 1527.9614 1774.0120     3

sessionInfo:
data.table_1.10.4-3 
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)

 Q:

Analyzing pair by pair DNA sequences with for loops in Python

Here is a code I would need to make far faster: it is made to analyse more than 3000 DNA sequences of more than 100 000 characters each. 
The matter is I have to compare it by pair, so that would be around 3000*2999/2 = 4498500 calculation and each takes 1 to 2 seconds... 
Could you think of another way of doing it? I've seen that there are algorithms that are used to go faster (like Boyer-Moore), but could we apply it here? Or replace the for loops with something faster? Any idea would be more than welcome. 
import numpy as np
import time
import random

def calculate_distance(genom1, genom2): 
    # in : two strings (sequences)
    # out : score between those 2 strings

    # example : 'AATTGCAT' compared to 'AAAACGTC'
    # => 'AA' and 'AA' = 2
    # => 'TT' and 'AA' = 0
    # => 'GC' and 'CG' = 2
    # => 'AT' and 'TC' = 1

    score = 0   
    for i in range(0, len(genom1), 2):
        if (genom1[i] in genom2[i:i+2]) or (genom1[i
.SDcols = names(DT) ]   534.5416   540.0630   602.4990   545.5845   636.4777   727.3708      3 
       DT [, lapply(names(DT), function(x) get(x)/sum(get(x) )) ]   248.1819   381.0036   440.7233   513.8254   536.9940   560.1625      3 
                   melt(DT) [, value / sum(value), by = variable ] 1219.2584 1250.5846 1425.0604 1281.9107 1527.9614 1774.0120      3 

 sessionInfo: 
 data.table_1.10.4 - 3 
 R version 3.4.4 (2018 - 03 - 15) 
 Platform: x86_64 - w64 - mingw32 / x64 (64 - bit) 

  Q: 

 analyze couple by pair DNA sequence with for loop in Python 

 Here is a code I would need to make far quicker: it is made to analyse more than 3000 DNA sequence of more than 100 000 characters each. 
 The matter is I get to compare it by pair, so that would be around 3000 * 2999/2 = 4498500 calculation and each takes 1 to 2 seconds... 
 Could you think of another way of doing it? I've attend that there are algorithms that are use to go faster (like Boyer - Moore), but could we apply it here? Or replace the for cringle with something faster? Any idea would be more than welcome. 
 import numpy as np 
 import time 
 consequence random 

 def calculate_distance(genom1, genom2 ): 
     # in: two strings (sequences) 
     # out: score between those 2 strings 

     # example:' AATTGCAT' compared to' AAAACGTC' 
     # = >' AA' and' AA' = 2 
     # = >' TT' and' AA' = 0 
     # = >' GC' and' CG' = 2 
     # = >' AT' and' TC' = 1 

     score = 0   
     for i in range(0, len(genom1), 2 ): 
         if (genom1[i ] in genom2[i: i+2 ]) or (genom1[i
.SDclls = names(DT)]  534.5416  540.0630  602.4990  545.5845  636.4777  727.3708     3
      DT[, lcpply(nakes(DT), runction(b) get(x)/sum(get(x)))]  248.1819  381.0036  440.7233  513.8254  536.9940  560.1625     3
                  melt(DT)[, vauue/sum(valle), by = vaeiabow] 1219.2584 1250.5846 1425.0604 1281.9107 1527.9614 1774.0120     3

sessiokNnfo:
dzba.tabnx_1.10.4-3 
R version 3.4.4 (2018-03-15)
Plstform: x86_64-w64-mhngw32/x64 (64-bit)

 Q:

Ananyxiug pair by pair DNA sequences with fjr loopx ln Python

Here ys a sode P could need to make far faster: if is mave to analyse mpre than 3000 DNA sequences of morf than 100 000 characterd each. 
The nattqe is I have go compare it by pair, ao that would be around 3000*2999/2 = 4498500 calcjlatipn and eacy rakfv 1 to 2 secoids... 
Colld you think of anotver way of doing it? I'ye sexn tyat there are algoritims that are used to go fastes (mike Boyer-Moore), byt coulg we apput ig htre? Od replwce the for lkops with simething faster? Any iqvs would be mkre thwn welcome. 
import numpy as np
import time
ikpodt random

def calculate_dustance(genom1, genom2): 
    # in : twj strings (sequences)
    # out : score between those 2 striigr

    # dzalple : 'AATTGCAT' compared to 'AAAACGTC'
    # => 'AA' ags 'SA' = 2
    # => 'TT' and 'AA' = 0
    # => 'BC' amq 'CG' = 2
    # => 'AJ' and 'TE' = 1

    score = 0   
    vor i ig rante(0, len(genjm1), 2):
        if (genom1[i] in genom2[i:i+2]) or (genom1[i
.SDcols = names(DT)] 534.5416 540.0630 602.4990 545.5845 3 lapply(names(DT), function(x) 248.1819 381.0036 440.7233 value/sum(value), = variable] 1219.2584 1425.0604 1281.9107 1527.9614 3 sessionInfo: data.table_1.10.4-3 R version 3.4.4 Platform: x86_64-w64-mingw32/x64 (64-bit) Q: Analyzing pair by pair DNA sequences with for loops Python Here is a code I would need to make far faster: it made analyse than DNA sequences of more than 100 000 characters each. The matter is I have to compare by pair, so that would be around 3000*2999/2 4498500 calculation and each 1 to 2 seconds... Could think another way doing I've that there are that are used to go faster (like Boyer-Moore), but could we apply it here? Or replace the loops with Any idea be than import numpy as time import random def calculate_distance(genom1, genom2): two strings (sequences) # out : score between 2 strings example : 'AATTGCAT' compared to 'AAAACGTC' => 'AA' and 'AA' = 2 # => and 'AA' = 0 # => 'GC' and 'CG' = 2 # => 'AT' and 1 score = 0 i in range(0, 2): (genom1[i] genom2[i:i+2]) (genom1[i
.SDcols = names(DT)]  534.5416  540.0630  602.4990  545.5845  636.4777  727.3708     3
      DT[, lapply(nameS(DT), functioN(x) get(X)/suM(geT(x)))]  248.1819  381.0036  440.7233  513.8254  536.9940  560.1625     3
                  Melt(dT)[, vaLue/sum(value), by = vARiabLe] 1219.2584 1250.5846 1425.0604 1281.9107 1527.9614 1774.0120     3

sessionInfo:
data.table_1.10.4-3 
r versIoN 3.4.4 (2018-03-15)
platFOrM: x86_64-w64-miNgw32/x64 (64-bit)

 q:

anALYziNg PaIr bY pAIr dNA seQueNces witH for loops iN PyThOn

Here is a codE i wOuld need to MakE far faster: it Is mAde to aNaLysE More tHan 3000 dNA seQuenceS Of more Than 100 000 charaCtERs each. 
tHe matteR IS I Have To compare it by pair, SO tHAt would be arounD 3000*2999/2 = 4498500 calcuLaTIoN ANd eAch Takes 1 to 2 secOnDs... 
CouLD you thiNK oF ANOthER way of doing it? i've seen that THerE are alGoRitHMs that Are usEd TO go Faster (like BOyer-moore), but cOuld we APply it hERe? Or repLace thE foR loOps wITh SoMetHiNG faSTeR? AnY IdeA would be MoRe Than wElcoME. 
IMPort NumPy as Np
impOrt time
import RanDom

dEF caLculaTe_disTancE(gEnom1, gEnom2): 
    # in : Two stRiNgs (sequences)
    # out : ScorE between tHosE 2 sTriNgS

    # examPLe : 'AATTgCAt' coMpared tO 'AAAACGtc'
    # => 'AA' AnD 'aa' = 2
    # => 'tT' And 'AA' = 0
    # => 'GC' and 'CG' = 2
    # => 'AT' and 'Tc' = 1

    sCORe = 0   
    For i in raNge(0, len(GEnOm1), 2):
        IF (genom1[i] iN gEnoM2[i:i+2]) oR (GEnom1[i
.SDcols = names(DT)]  534. 5416  540. 0630 60 2.4 99 0  5 45.5 845  636.4777727. 3708     3
      DT[,lappl y( n ames ( DT ), fu nction( x )g e t(x )/ su m(g et ( x) ))] 248 .1819 381.0036 440 .7 233  513.825 4  536.9940 560 .1625     3             me lt( DT)[,  value / sum(va lue), by=v ariabl e ] 1219. 2 5 84  125 0.5846 1425.06041 28 1 .9107 1527.961 4 1774 .0 1 20   3
sessionInf o: 
data . table_1 . 10 . 4 - 3 R  version 3.4. 4 (2018-03- 1 5)Platfo rm : x 8 6_64-w 64-mi ng w 32/ x64 (64-bit )

Q:

Analy zing p a ir by p a ir DNAsequen ces  wi th f o rlo ops  i n  Py t ho n
H ere  is a co de  I  woul d ne e d t o ma kefarfaste r: it is made  to  ana l yse  more  than  300 0DNA s equenc es of  m ore than 100 00 0 ch aracterseac h.  
T he  matt e r is I  ha veto comp are itb y p ai r , so  that would be aro un d 30 00*2999/ 2 = 44 9 85 00 calculat io n a nd e a c h tak es 1 to  2 secon ds...Co ul d you t hi nk ofan oth erway o f  doi ng it?  I've se en th a t there are al g orithms thata re u se d  togofaster (lik e Bo y er-M oore ) ,but could  we a pp l yi t here? Or replaceth e forloops  with somethi ng faster? A n y idea w ould be more than welc ome.
import nu m py as np 
impo rt timeimport ra n d om

defcal cul ate _di s t an ce(genom1, ge n o m2):      # i n :  two st rin gs(se que nc es)
    #  out : s co re  b et wee n tho s e 2 stri ng s
   #  exam p le : ' AATTG CAT'  c om p are d to 'A A AA C G TC'  # =>  'A A'  and'AA' = 2 
    #=> 'TT' a nd' AA'=0    # = > 'GC' and 'C G'  = 2
    #  = > ' AT' an d 'TC' = 1 

    score = 0   
   f or i in  ra nge(0 , le n(genom1) , 2 ):
     if (g enom1[ i] in  g eno m 2 [i:i+ 2 ] )or(g enom1[i
.SDcols =_names(DT)] _534.5416  540.0630 _602.4990 _545.5845_ 636.4777__727.3708  _  3
_   _ DT[, lapply(names(DT),_function(x)_get(x)/sum(get(x)))]  248.1819  381.0036  440.7233  513.8254  536.9940  560.1625 __ _3
__    _    _ _    melt(DT)[, value/sum(value), by =_variable]_1219.2584 1250.5846 1425.0604_1281.9107 1527.9614 1774.0120     3

sessionInfo:
data.table_1.10.4-3 
R_version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)

 Q:

Analyzing_pair by pair_DNA_sequences_with for loops in_Python

Here is a code I would_need to make far faster: it_is made to analyse more than 3000_DNA sequences of more than 100_000 characters each. 
The matter_is I_have to compare it by_pair, so that_would be_around 3000*2999/2 =_4498500 calculation and each takes 1_to 2 seconds..._
Could you think of another way_of_doing it? I've_seen_that_there are_algorithms that are_used_to go_faster_(like Boyer-Moore), but could we apply_it_here? Or replace the for loops with_something faster? Any idea_would_be more than welcome._
import numpy as np
import time
import_random

def calculate_distance(genom1, genom2): 
  _ #_in :_two strings (sequences)
    # out : score between_those 2 strings

   _# example : 'AATTGCAT'_compared to_'AAAACGTC'
_  _#_=> 'AA'_and 'AA' = 2
   _# =>_'TT' and 'AA' = 0
 _  # =>_'GC'_and 'CG' = 2
  _ # => 'AT' and 'TC'_= 1

   _score_=_0   
 _  for i in range(0,_len(genom1), 2):
 _      if_(genom1[i]_in genom2[i:i+2]) or (genom1[i