PcrClipReads

Soft clip bam files based on PCR target regions
Usage
This program is now part of the main jvarkit tool. See jvarkit for compiling.
Usage: java -jar dist/jvarkit.jar pcrclipreads [options] Files
Usage: pcrclipreads [options] Files
Options:
--bamcompression
Compression Level. 0: no compression. 9: max compression;
Default: 5
* -B, --bed, --pcr
Regions containing non-overlapping PCR fragments. A source of intervals.
The following suffixes are recognized: vcf, vcf.gz bed, bed.gz, gtf,
gff, gff.gz, gtf.gz.Otherwise it could be an empty string (no interval)
or a list of plain interval separated by '[ \t\n;,]'
Default: (unspecified)
-flag, --flag
Only run on reads having sam flag 'x' (flag). -1 = all reads. (as
https://github.com/lindenb/jvarkit/issues/43)
Default: -1
-h, --help
print help and exit
--helpFormat
What kind of help. One of [usage,markdown,xml].
-largest, --largest
check if a read overlaps two bed intervals use the bed region sharing
the longest sequence with a read. see
https://github.com/lindenb/jvarkit/issues/44
Default: false
-o, --out
Output file. Optional . Default: stdout
-pr, --programId
add a program group PG to the clipped SAM records
Default: false
-R, --reference
Indexed fasta Reference file. This file must be indexed with samtools
faidx and with picard/gatk CreateSequenceDictionary or samtools dict
--regions
Limit analysis to this interval. A source of intervals. The following
suffixes are recognized: vcf, vcf.gz bed, bed.gz, gtf, gff, gff.gz,
gtf.gz.Otherwise it could be an empty string (no interval) or a list of
plain interval separated by '[ \t\n;,]'
--samoutputformat
Sam output format.
Default: SAM
Possible Values: [BAM, SAM, CRAM]
--validation-stringency
SAM Reader Validation Stringency
Default: LENIENT
Possible Values: [STRICT, LENIENT, SILENT]
--version
print version and exit
Keywords
- sam
- bam
- pcr
- bed
See also in Biostars
- https://www.biostars.org/p/147136
- https://www.biostars.org/p/178308
- https://www.biostars.org/p/498088
Creation Date
20150618
Source code
Unit Tests
Contribute
- Issue Tracker: http://github.com/lindenb/jvarkit/issues
- Source Code: http://github.com/lindenb/jvarkit
License
The project is licensed under the MIT license.
Citing
Should you cite pcrclipreads ? https://github.com/mr-c/shouldacite/blob/master/should-I-cite-this-software.md
The current reference is:
http://dx.doi.org/10.6084/m9.figshare.1425030
Lindenbaum, Pierre (2015): JVarkit: java-based utilities for Bioinformatics. figshare. http://dx.doi.org/10.6084/m9.figshare.1425030
See also
- (2021)
samtools ampliconclip- clip reads using a BED file http://www.htslib.org/doc/samtools-ampliconclip.html
Motivation
Soft clip BAM files based on PCR target regions https://www.biostars.org/p/147136/
- mapping quality is set to zero if a read on mapped strand - overlap the 5' side of the PCR fragment
- mapping quality is set to zero if a read on mapped strand + overlap the 3' side of the PCR fragment
- mapping quality is set to zero if no PCR fragment is found
after processing the BAM file should be sorted, processed with samtools calmd and picard fixmate
Example
echo "seq2\t1100\t1200" > test.bed
java -jar dist/jvarkit.jar pcrclipreads -B test.bed samtools-0.1.19/examples/ex1.bam |\
samtools view -q 1 -F 4 -Sbu - |\
samtools sort -o clipped.bam - && samtools index clipped.bam
samtools tview -p seq2:1100 clipped.bam samtools-0.1.19/examples/ex1.fa
output

1091 1101 1111 1121 1131 1141 1151 1161 1171 1181 1191
AAACAAAGGAGGTCATCATACAATGATAAAAAGATCAATTCAGCAAGAAGATATAACCATCCTACTAAATACATATGCACCTAACACAAGACTACCCAGATTCATAAAACAAATNNNNN
................................... ..................................
,,, ..................................
,,,,, .................................
,,,,,,,,,,, .............................N...
,,,,,,,, ...............................
,,g,,,,,,,,,,,,, ............................
,,,,,,,,,,,,,,,,,,,, ............................
,,,,,,,,,,,,,,,,,,, ..........................
,,,,,,,,,,,,,,,,,,,,,, ..........................
,,,,,,,,,,,,,,,,,,,,,,, ......................
,,,,,,,,,,,,,,,,,,,,,,,,,, ..................
,,,,,,,,,,,,,,,,,,,,,,,,,, ..................
,,,,,,,,,,,,,,,,,,,,,,,,,,,, .................
,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ................
,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ...............
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ............
,,,,,,,,,,,,a,,,,,,,,,,,,,,,,,,, .......
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ......
,,a,,,a,,,,,,,,,,,,,,,,,,,,,,,,,,, ....
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ....
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, .
.
Cited in
- BAMClipper: removing primers from alignments to minimize false-negative mutations in amplicon next-generation sequencing https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5431517/
History
- 20170630 : rewritten after https://github.com/lindenb/jvarkit/issues/81