fn low_mem_nw<M : Fn(Nucleotide, Nucleotide)-> i64, C : Fn(i64)->i64>(a : &Sequence, b : &Sequence, sub_matrix : Rc<M>, cost_func : Rc<C>) -> Vec<i64> {
        let s = &a.nucleotides; 
        let t = &b.nucleotides; 

        //The lines that will hold the scores. 
        let mut v; 
        let mut u = vec!(0 as i64; s.len()+1);
        for i in 0..(s.len()+1) { u[i] = (i as i64) * -1 } 

        //Iterate down the list and compute the scores. 
        for i in 1..(t.len()+1){
            //Ratchet. 
            v = u.clone(); 
            u = vec!(0 as i64; s.len()+1); 

            //Iterate down the list and do needleman wunsch on the two lists. 
            u[0] = ((i) as i64) * -1;
            for j in 1..(s.len()+1) { 
                let a = v[j-1] + sub_matrix(t[i-1], s[j-1]);
                let b = v[j] + cost_func(1); //TODO: Support more gaps. 
                let c = u[j-1] + cost_func(1); //TODO: Support more gaps.
                u[j] = max(a, max(b, c)); 
            }
        }
        //Return the last row of the matrix. 
        u
    }
//Memoryless version of needleman wunsch for Hirschberg's algorithm to align sequences more efficiently. 
Memoryless version of needleman wunsch for Hirschberg's algorithm to align sequences more efficiently.
Memoryless version of needleman wunsch for Hirschberg ' s algorithm to align sequences more efficiently .
fn low_mem_nw<M : Fn(Nucleotide, Nucleotide)-> i64, C : Fn(i64)->i64>(a : &Sequence, b : &Sequence, sub_matrix : Rc<M>, cost_func : Rc<C>) -> Vec<i64> {
        let s = &a.nucleotides; 
        let t = &b.nucleotides; 
        //The lines that will hold the scores. 
        let mut v; 
        let mut u = vec!(0 as i64; s.len()+1);
        for i in 0..(s.len()+1) { u[i] = (i as i64) * -1 } 
        //Iterate down the list and compute the scores. 
        for i in 1..(t.len()+1){
            //Ratchet. 
            v = u.clone(); 
            u = vec!(0 as i64; s.len()+1); 
            //Iterate down the list and do needleman wunsch on the two lists. 
            u[0] = ((i) as i64) * -1;
            for j in 1..(s.len()+1) { 
                let a = v[j-1] + sub_matrix(t[i-1], s[j-1]);
                let b = v[j] + cost_func(1); //TODO: Support more gaps. 
                let c = u[j-1] + cost_func(1); //TODO: Support more gaps.
                u[j] = max(a, max(b, c)); 
            }
        }
        //Return the last row of the matrix. 
        u
    }
fn low_mem_nw < M : Fn ( Nucleotide , Nucleotide ) -> i64 , C : Fn ( i64 ) -> i64 > ( a : & Sequence , b : & Sequence , sub_matrix : Rc < M > , cost_func : Rc < C > ) -> Vec < i64 > { let s = & a . nucleotides ; let t = & b . nucleotides ; //The lines that will hold the scores.  let mut v ; let mut u = vec ! ( 0 as i64 s len ( ) 1 ) ; for i in 0 .. ( s . len ( ) + 1 ) { u [ i ] = ( i as i64 ) * - 1 } //Iterate down the list and compute the scores.  for i in 1 .. ( t . len ( ) + 1 ) { //Ratchet.  v = u . clone ( ) ; u = vec ! ( 0 as i64 s len ( ) 1 ) ; //Iterate down the list and do needleman wunsch on the two lists.  u [ 0 ] = ( ( i ) as i64 ) * - 1 ; for j in 1 .. ( s . len ( ) + 1 ) { let a = v [ j - 1 ] + sub_matrix ( t [ i - 1 ] , s [ j - 1 ] ) ; let b = v [ j ] + cost_func ( 1 ) ; //TODO: Support more gaps.  let c = u [ j - 1 ] + cost_func ( 1 ) ; //TODO: Support more gaps. u [ j ] = max ( a , max ( b , c ) ) ; } } //Return the last row of the matrix.  u }
Memoryless version of needleman wunsch for Hirschberg's algorithm to align sequences more efficiently.
Memoryless version of needleman wunsch for Hirschberg ' s algorithm to align sequences more efficiently .
a
&Sequence
b
&Sequence
sub_matrix
Rc<M>
cost_func
Rc<C>
a
&Sequence
b
&Sequence
sub_matrix
Rc<M>
cost_func
Rc<C>