Is there a simple way to remove several bps at the end of each read in a BAM file?
Seqanswers Leaderboard Ad
Collapse
Announcement
Collapse
No announcement yet.
X
-
to really do it right one should also edit the alignment column but since that column which might specify different things at each alignment (continuous alignments, gapped, spliced etc) but if you just want to cut the reads and quality strings down (cutting from the right side and keeping left side) you could do this (all in one line):
Code:myfile="some_file.bam";mylen=20;cat <(samtools view -H $myfile) <(samtools view $myfile | while read line; do cutRead=`echo "$line" | cut -f10 | cut -c1-$mylen`; cutQual=`echo "$line" | cut -f10 | cut -c1-$mylen`; echo -e "$line" | awk -v cRead=$cutRead -v cQual=$cutQual 'BEGIN {FS="\t";OFS="\t"} {$10=cRead;$11=cQual;print $0}; done)
of course i 100% do not recommend using the output of this for any downstream analysis using software the accepts SAM files because of the fact that the alignment column (CIGAR annotation) is not edited so as far as any tools are concerted the alignments will still be full length. note that editing that value would require more code to interpret the alignment and edit it based on the trimming.
is there any chance you can trim the reads prior to alignment? that would be much less messy./* Shawn Driscoll, Gene Expression Laboratory, Pfaff
Salk Institute for Biological Studies, La Jolla, CA, USA */
Latest Articles
Collapse
-
by seqadmin
The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...-
Channel: Articles
04-22-2024, 07:01 AM -
-
by seqadmin
Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...-
Channel: Articles
04-04-2024, 04:25 PM -
ad_right_rmr
Collapse
News
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by seqadmin, Yesterday, 11:49 AM
|
0 responses
15 views
0 likes
|
Last Post
by seqadmin
Yesterday, 11:49 AM
|
||
Started by seqadmin, 04-24-2024, 08:47 AM
|
0 responses
16 views
0 likes
|
Last Post
by seqadmin
04-24-2024, 08:47 AM
|
||
Started by seqadmin, 04-11-2024, 12:08 PM
|
0 responses
62 views
0 likes
|
Last Post
by seqadmin
04-11-2024, 12:08 PM
|
||
Started by seqadmin, 04-10-2024, 10:19 PM
|
0 responses
60 views
0 likes
|
Last Post
by seqadmin
04-10-2024, 10:19 PM
|
Comment