samtools complex question
1
0
Entering edit mode
8.1 years ago
biotech ▴ 570

I need to know if there is any read mapping to certain region in an alignment file (.sam). In fact, I have a list of 20 regions I'm interested. I'm talking about the third column in the sam file. Also, the reads I want to filter must map with an alignment score greater than a certain value.

I'm starting from 6 sam files.

Maybe a custom script is better than samtools?

samtools • 1.6k views
ADD COMMENT
3
Entering edit mode
8.1 years ago

if there is any read mapping to certain region in an alignment file (.sam)

Samtools And Region List

Also, the reads I want to filter must map with an alignment score greater than a certain value.

Filtering A Sam File For Quality Scores

ADD COMMENT
0
Entering edit mode

Thanks Pierre. I just need all reads mapping to certain chromosome. Would this ease the process? Not looking for coordinates.

ADD REPLY
0
Entering edit mode

Am I right with this shortcut? I have no output, shell running... Possibly due to large *sam files.

for file in ./*sam; do echo $file; samtools view -S -F 4 -q 30 $file; done | grep -x -f ./GBK/GBK_homologues/M6_f0_0taxa_algCOG_e0_/specifics.locus
ADD REPLY
0
Entering edit mode

Note that this would filter out unmapped reads but not mapped mates, giving a file with singletons and pairs.

ADD REPLY
0
Entering edit mode

And this one? Still no output

awk -F"\t" '{if ($5 > 30) {print $0}}' *.sam | grep -x -f ./GBK/GBK_homologues/M6_f0_0taxa_algCOG_e0_/specifics.locus
ADD REPLY
0
Entering edit mode

Please actually read the first link that Pierre posted. Grep should never be needed here.

ADD REPLY
0
Entering edit mode

Is this more or less what you suggested? 'specifics.locus' contains my interesting bed file first columns IDs that I'm trying to filter.

for file in *sam.bam.sorted.bam
do
    bamToBed -i $file | awk -F"\t" '{if ($5 > 30) {print $0}}' > $file.bed
    grep -x -f ./GBK/GBK_homologues/M6_f0_0taxa_algCOG_e0_/specifics.locus $file.bed &
done
ADD REPLY
0
Entering edit mode

BTW, this would be much faster if you made a sorted BAM file.

ADD REPLY

Login before adding your answer.

Traffic: 1333 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6