SHARE
TWEET

Untitled

a guest Nov 17th, 2012 28 Never
  1. Tuple!(size_t[char],size_t) baseCounter( const ref string[] sequences ){
  2.         alias Tuple!(size_t[char], size_t) Result;
  3.         Result result;
  4.         size_t         length       = 0;
  5.         size_t[char][] baseNumbers  = new size_t[char][](sequences.length);
  6.         foreach(index, ref seq; parallel(sequences)){
  7.             foreach(ref letter; seq ){
  8.                 if( letter in baseNumbers[index]) baseNumbers[index][letter]++;
  9.                 else baseNumbers[index][letter] = 1;
  10.             }
  11.             length += seq.length;
  12.         }
  13.         foreach(baseNumber; baseNumbers){
  14.             foreach( key, value; baseNumber ){
  15.                 if( key in result[0] ) result[0][key] += value;
  16.                 else result[0][key] = value;
  17.             }
  18.         }
  19.         result[1] = length;
  20.         return result;
  21.     }
RAW Paste Data
Top