Entering edit mode
7.4 years ago
madhu.9124
▴
60
Hi,
I have a sam file and I want to increase the value present in the fifth column of the sam file ( MAPQ). This is done to test the BBMap application. Kindly help.
Thanks
thanks you, it works but after incrementing the values, I want to save the changes to the same same file.
You can use
awk -i inplace -v OFS='\t' '$5 += 7' alignment.sam
, but it's good practice to keep your original files.This is what I would do:
cat alignment.sam | awk -v OFS='\t' '$5 += 7' > alignment_mapqincreasedbyseven.sam
Just a couple of things... You should print the sam header as it is, without incrementing the 5th column. I.e. with something like
if($0 ~ "^@") {print $0} else {...}
. Also you should check that incrementing the MAPQ doesn't make it out of bound, i.e. no more than 254 (255 meaning not available).Good points! andthisistextfulfillsthesmartcharacterrequirement
thanks a lot, it works.