I'm having some trouble parsing plain text output from samtools stats
.
Example output:
45205768 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
5203838 + 0 duplicates
44647359 + 0 mapped (98.76% : N/A)
0 + 0 paired in sequencing
0 + 0 read1
0 + 0 read2
0 + 0 properly paired (N/A : N/A)
0 + 0 with itself and mate mapped
0 + 0 singletons (N/A : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)
I'd like to parse the file line-by-line and get the following output in a PHP array like this:
Array(
"in total" => [45205768,0],
...
)
So, long story short, I'd like to get the numerical values from the front of the line as an array of integers and the following string (without the brackets) as key.