bedtools multiple BAM files
1
0
Entering edit mode
4.0 years ago
amitpande74 ▴ 20

I have BAM files in the external hard drive. Want to convert them into BED. Am using

cd /media/usr/LaCie/work/client/pool1/bam
for x in *.bam ; do
    echo "print current:$x";
    bedtools bamToBed -i "$x" > "${x%.bam}.bed";
done
echo "done"

it writes the BED files in the directory, but they are all empty. My BEDtools is installed in

/home/usr/miniconda3/bin/bedtools

Can someone tell me where I am going wrong? And the BAM files have reads, so there is no problem there. regards.

Bedtools shellscript BAMtoBED • 2.0k views
ADD COMMENT
0
Entering edit mode

any error message on your screen ?

ADD REPLY
0
Entering edit mode

error: unrecognized command: bamToBed

ADD REPLY
0
Entering edit mode

change bamToBed to bamtobed (small letters).

ADD REPLY
0
Entering edit mode

Hello amitpande74!

It appears that your post has been cross-posted to another site: https://stackoverflow.com/questions/64860327

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLY
0
Entering edit mode
(base) samtools view A1_S1.bam | head
NS500455:81:HTVKJBGXC:1:12305:10402:19515   16  chr1    231634  1   43M *   0   0   AGAATTGGGTTGGAATTTTGATGGGGATTGCATTGAATCTGTA <EE<A<EAEAEAA/EEAEEEEAAAAEEEEE/EEAAEEEA/EEE AS:i:86 XS:i:86 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:43 YT:Z:UU
NS500455:81:HTVKJBGXC:2:22109:7726:14155    16  chr1    231634  1   43M *   0   0   AGAATTGGGTTGGAATTTTGATGGGGATTGCATTGAATCTGTA EEEEEEEEEAEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE AS:i:86 XS:i:86 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:43 YT:Z:UU
NS500455:81:HTVKJBGXC:3:22505:6042:9122 16  chr1    231634  1   43M *   0   0   AGAATTGGGTTGGAATTTTGATGGGGATTGCATTGAATCTGTA EE<E/<EAEEAEEEEAEA/EA<AEEEE<AEEE<<AAEAEEAEE AS:i:86 XS:i:86 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:43 YT:Z:UU
NS500455:81:HTVKJBGXC:1:12101:2573:8192 0   chr1    312297  1   37M6S   *   0   0   TATATAATAAATGAATAAATCTTTAAAAAAAAAAAAGGCCTGA EEEEEAEA<EEEEEEEEEEEEEAEEEE<E<EAEEEAAEEAAAE AS:i:74 XS:i:74 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:37 YT:Z:UU
NS500455:81:HTVKJBGXC:1:21211:14672:4155    0   chr1    312297  1   37M6S   *   0   0   TATATAATAAATGAATAAATCTTTAAAAAAAAAAAAGGCCTGA EEEEEEEEAAEEEEAEAEEEEEAEAAEEEEEEAEEAE/EAA<E AS:i:74 XS:i:74 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:37 YT:Z:UU
NS500455:81:HTVKJBGXC:2:21107:10835:2883    0   chr1    312297  11  37M6S   *   0   0   TATATAATAAATGAATAAATCTTTAAAAAAAAAAAAGGCCTGA EEEEE6/E6A/AEA/EAAEEAEEE///<AAEEAEEEEEAEEA< AS:i:74 XS:i:73 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:37 YT:Z:UU
NS500455:81:HTVKJBGXC:4:12504:22831:18864   0   chr1    312297  1   37M6S   *   0   0   TATATAATAAATGAATAAATCTTTAAAAAAAAAAAAGGACCTC EEEE/E/////E//<E<6A//E/AEEA6E/E/A////////// AS:i:74 XS:i:74 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:37 YT:Z:UU
NS500455:81:HTVKJBGXC:3:21402:6383:13492    16  chr1    348070  1   44M *   0   0   AATTTGCAAATTCATCTGGAATAACAAAAAAACCAGGATAGCTA    EEAE<EEEEEEEEEEEAEEEEEEEEEEEEEEEEEEEEEEEEAEE    AS:i:88 XS:i:88 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:44 YT:Z:UU
NS500455:81:HTVKJBGXC:1:22102:3644:3920 16  chr1    348071  1   43M *   0   0   ATTTGCAAATTCATCTGGAATAACAAAAAAACCAGGATAGCTA EEEEEEEEEAAEE<EEEEEEEEEEEEEEEEEEEEEEEEEEEEE AS:i:86 XS:i:86 XN:i:0  XM:i:0  XO:i:0  XG:i:0  NM:i:0  MD:Z:43 YT:Z:UU
NS500455:81:HTVKJBGXC:1:22303:6790:10657    16  chr1    348071  1   43M *   0   0   ATTTGCAAATTCATCTGGAATAACAAAAAAACCAGGATAGCTA EEAEEEAEEAAEA<AEE
ADD REPLY
0
Entering edit mode

after I added a fake header to your sam, it worked fine on my machine.

$ for x in ~/jeter.bam; do echo "current $x"; bedtools bamtobed -i "${x}" > "${x%.bam}.bed" ; done && cat ~/jeter.bed
current /path/to/jeter.bam
chr1    231633  231676  NS500455:81:HTVKJBGXC:1:12305:10402:19515   1   -
chr1    231633  231676  NS500455:81:HTVKJBGXC:2:22109:7726:14155    1   -
chr1    231633  231676  NS500455:81:HTVKJBGXC:3:22505:6042:9122 1   -
chr1    312296  312333  NS500455:81:HTVKJBGXC:1:12101:2573:8192 1   +
chr1    312296  312333  NS500455:81:HTVKJBGXC:1:21211:14672:4155    1   +
chr1    312296  312333  NS500455:81:HTVKJBGXC:2:21107:10835:2883    11  +
chr1    312296  312333  NS500455:81:HTVKJBGXC:4:12504:22831:18864   1   +
chr1    348069  348113  NS500455:81:HTVKJBGXC:3:21402:6383:13492    1   -
chr1    348070  348113  NS500455:81:HTVKJBGXC:1:22102:3644:3920 1   -
ADD REPLY
0
Entering edit mode

Is there a header? What does

samtools view -H A1_S1.bam | head

show?

ADD REPLY
0
Entering edit mode

OP would have told us that there is an error message ...

ADD REPLY
0
Entering edit mode

Thanks @Pierre. I changed the cable of my external hard drive and now it works. Thanks to all for the kind support.

ADD REPLY
2
Entering edit mode
4.0 years ago

error: unrecognized command: bamToBed

bedtools bamtobed ....

ADD COMMENT
0
Entering edit mode

I did correct it, yet it does not work.

ADD REPLY
0
Entering edit mode

has the error message changed?

ADD REPLY
0
Entering edit mode

Now there is no error message...giving an impression that it works. But still cannot see it in the top command.It has made an empty file in the folder titled .bed....am waiting to see if the script writes anything there. Shall keep you all updated. Thanks for the patience you people have shown.

ADD REPLY
0
Entering edit mode

show us a few reads from a bam please.

ADD REPLY

Login before adding your answer.

Traffic: 2103 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