Question: bedtools multiple BAM files
0
gravatar for amitpande74
18 days ago by
amitpande740 wrote:

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.

bamtobed shellscript bedtools • 146 views
ADD COMMENTlink modified 17 days ago • written 18 days ago by amitpande740

any error message on your screen ?

ADD REPLYlink written 18 days ago by Pierre Lindenbaum131k

error: unrecognized command: bamToBed

ADD REPLYlink written 18 days ago by amitpande740

change bamToBed to bamtobed (small letters).

ADD REPLYlink modified 17 days ago • written 17 days ago by husensofteng290

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 REPLYlink written 17 days ago by Pierre Lindenbaum131k
(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 REPLYlink written 17 days ago by amitpande740

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 REPLYlink modified 17 days ago • written 17 days ago by Pierre Lindenbaum131k

Is there a header? What does

samtools view -H A1_S1.bam | head

show?

ADD REPLYlink written 17 days ago by GenoMax93k

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

ADD REPLYlink written 17 days ago by Pierre Lindenbaum131k

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

ADD REPLYlink written 16 days ago by amitpande740
2
gravatar for Pierre Lindenbaum
17 days ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:

error: unrecognized command: bamToBed

bedtools bamtobed ....

ADD COMMENTlink written 17 days ago by Pierre Lindenbaum131k

I did correct it, yet it does not work.

ADD REPLYlink written 17 days ago by amitpande740

has the error message changed?

ADD REPLYlink written 17 days ago by Friederike6.5k

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 REPLYlink written 17 days ago by amitpande740

show us a few reads from a bam please.

ADD REPLYlink written 17 days ago by Pierre Lindenbaum131k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1266 users visited in the last hour