Пример #1
0
             return $x / $sum * 100;
         }, $values, array_fill(0, count($values), array_sum($values)));
         fwrite($outputs[$key], $id . "\t" . implode("\t", $norma) . "\n");
     }
     fclose($outputs[$key]);
 }
 /*
  * Process bowtie mapping stats and write its to common file as table.
  */
 $result = $workDir . DIRECTORY_SEPARATOR . $prefix . '.stats.txt';
 $output = fopen($result, 'wb');
 if ($output) {
     fwrite($output, "name\tmapped-to-human\tmapped-to-reference\tn-filtered-reads\tn-reads-total\tfiltered-reads-percent\n");
     $outputStrings = array();
     foreach ($dirIterator as $dir) {
         if (!$dir->isDir() || $dir->isDot() || FileIterator::isHidden($dir->getFilename())) {
             continue;
         }
         $humanBowtieStats = BowtieStatsFinder::getBowtieStatsLogFile($dir->getPathname(), BowtieStatsFinder::HUMAN_FILE);
         if (!$humanBowtieStats || !($humanMappingPercent = $humanBowtieStats->getAlignedReadsPercent())) {
             $humanMappingPercent = 'NA';
         }
         $referenceBowtieStats = BowtieStatsFinder::getBowtieStatsLogFile($dir->getPathname(), BowtieStatsFinder::REFERENCE_FILE);
         if (!$referenceBowtieStats || !($refernceMappingPercent = $referenceBowtieStats->getAlignedReadsPercent())) {
             $relativeToUnmappedMappingPercent = 'NA';
         } else {
             $relativeToUnmappedMappingPercent = round((100 - $humanMappingPercent) * $refernceMappingPercent / 100, 2);
         }
         // search for reads filtering stats
         $nReadsTotal = 'NA';
         $nReadsFiltered = $humanBowtieStats ? $humanBowtieStats->getProcessedReadsCount() : 'NA';