Esempio n. 1
0
 $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';
 $percentFiltered = 'NA';
 $path = $dir->getPathname() . DIRECTORY_SEPARATOR . 'log';
 $file = FileIterator::getFileByPattern('/reads-filter\\.pl\\.o\\d+/', $path);
 $filepath = $path . DIRECTORY_SEPARATOR . $file;
 if ($file == null) {
     printf("Warning: file reads-filter.pl.o[:digits:] not found in [%s/log] directory\n", basename($dir->getPathname()));
 } else {
     if (!file_exists($filepath)) {
         printf("Warning: file [%s] not found\n", $filepath);
     } else {
         $content = file_get_contents($filepath);
         $result = preg_match('/Filtered (\\d+) of (\\d+) reads/', $content, $matches);
         if ($result == 0) {
             printf("Warning: file [%s] has no statistics\n", $filepath);
         } else {
             $nReadsTotal = $matches[2];
         }
     }