Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by alignment score [feature request] #141

Open
sjackman opened this issue Dec 21, 2016 · 3 comments
Open

Filter by alignment score [feature request] #141

sjackman opened this issue Dec 21, 2016 · 3 comments

Comments

@sjackman
Copy link

I'd like to filter out alignments with an alignment score (AS:i) less than some threshold.

@cgandini
Copy link

cgandini commented Feb 3, 2017

me 2

@cgandini
Copy link

cgandini commented Feb 3, 2017

did you found a way to do it?

@sjackman
Copy link
Author

sjackman commented Feb 5, 2017

Yes, using awk. The following is a Makefile snippet.

# Remove alignments with an alignment score below a threshold.
%.as100.bam: %.bam
	samtools view -h -F4 $< | gawk -F'\t' ' \
			/^@/ { print; next } \
			{ as = 0 } \
			match($$0, "AS:.:([^\t]*)", x) { as = x[1] } \
			as >= 100' \
		| samtools view -@$t -b -o $@

https://github.com/sjackman/picea-sitchensis-mitochondrion/blob/master/Makefile#L288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants