{"__v":0,"_id":"579a898bcfdd400e0050ea76","category":{"__v":0,"_id":"576e8ae1f37ab41700147471","project":"57618347b65324200072d6a5","version":"57618347b65324200072d6a8","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-25T13:45:05.813Z","from_sync":false,"order":4,"slug":"test","title":"How does it work?"},"parentDoc":null,"project":"57618347b65324200072d6a5","user":"57617c8caa540f3600bfed20","version":{"__v":8,"_id":"57618347b65324200072d6a8","project":"57618347b65324200072d6a5","createdAt":"2016-06-15T16:33:11.587Z","releaseDate":"2016-06-15T16:33:11.587Z","categories":["57618347b65324200072d6a9","5761912d207db7170022fbe9","57619455a7c9f729009a74e0","576e8ae1f37ab41700147471","5797b8e5209a6e0e00b8321b","57989a8817ced017003c4c69","579ca6f3d46f960e0029a8ec","579ca703fefb1d0e00c94f06"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"blobtools v0.9.19","version_clean":"0.9.19","version":"0.9.19"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-28T22:39:07.667Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"The process of coverage parsing used by ```blobtools create``` and ```blobtools map2cov``` differs depending on the file format of the [coverage file](doc:coverage-file).\n\n### 1. BAM files\n\n1.1. ```samtools flagstat``` is called on the BAM file in order to obtain: \n * total number of reads\n * mapped number of reads\n\n1.2. ```samtools view -F 4 -F 1028 -F 256``` is called on the BAM file and the output is parsed\n\n1.3 For each read : \n  * read coverage of sequence increases by 1\n  * base coverage of sequence increases by N\n   * where N is the sum of alignment match positions (M/X/='s) divided by the number of AGCT's in the sequence\n\n\n### 2. SAM files\n\n2.1. Only mapped reads (where RNAME is not \"*\") of the SAM file\n\n2.2 For each read  : \n  * read coverage of sequence increases by 1\n  * base coverage of sequence increases by N\n   * where N is the sum of alignment match positions (M/X/='s) divided by the number of AGCT's in the sequence\n\n### 3. CAS files\n\n3.1  ```clc_mapping_info -s``` is called and the output is parsed for:\n * total number of reads\n * mapped number of reads\n\n3.2  ```clc_mapping_info -n``` is called and for each sequence in the assembly the following values are parsed:\n * corrected base coverage (column 6 of \"Contig info\")\n * read coverage (column 3 of \"Contig info\")\n\n### 4. COV files\n* Total/mapped read count is parsed from the header\n* Base/read coverage is parsed for each sequence","excerpt":"How does it work?","slug":"coverage-parsing","type":"basic","title":"Coverage parsing"}

Coverage parsing

How does it work?

The process of coverage parsing used by ```blobtools create``` and ```blobtools map2cov``` differs depending on the file format of the [coverage file](doc:coverage-file). ### 1. BAM files 1.1. ```samtools flagstat``` is called on the BAM file in order to obtain: * total number of reads * mapped number of reads 1.2. ```samtools view -F 4 -F 1028 -F 256``` is called on the BAM file and the output is parsed 1.3 For each read : * read coverage of sequence increases by 1 * base coverage of sequence increases by N * where N is the sum of alignment match positions (M/X/='s) divided by the number of AGCT's in the sequence ### 2. SAM files 2.1. Only mapped reads (where RNAME is not "*") of the SAM file 2.2 For each read : * read coverage of sequence increases by 1 * base coverage of sequence increases by N * where N is the sum of alignment match positions (M/X/='s) divided by the number of AGCT's in the sequence ### 3. CAS files 3.1 ```clc_mapping_info -s``` is called and the output is parsed for: * total number of reads * mapped number of reads 3.2 ```clc_mapping_info -n``` is called and for each sequence in the assembly the following values are parsed: * corrected base coverage (column 6 of "Contig info") * read coverage (column 3 of "Contig info") ### 4. COV files * Total/mapped read count is parsed from the header * Base/read coverage is parsed for each sequence