Question: trouble in converting txt to bed file for bedtools
0
gravatar for saadleeshehreen
2.0 years ago by
saadleeshehreen70 wrote:

I tried to convert a .txt file to .bed file.

CONTIG  DNA_START   DNA_END     
NZ_AWYZ01001116.1   641 1875        
AWZB01001762.1  1975    2386        
NZ_AWZG01001811.1   646 18356       
AWYT01002050.1  2311    17133       
NZ_AWYV01001866.1   13969   14380       
NZ_AWYN01001907.1   17959   18370       
AWYR01002060.1  16722   17133       
AWYX01002140.1  8145    8556        
NZ_KK213231.1   7885    19297

I tried the following command

awk -F"[:-]" 'BEGIN{ OFS="\t"; }{ print $1, $2, $3; }' xx.txt > xx.bed

But bedtoos give the folowing error

Unexpected file format.  Please use tab-delimited BED, GFF, or VCF. Perhaps you have non-integer starts or ends at line 1?

I checked the file with the following command

  cat -A AcrIF3.bed | head
  CONTIG^IDNA_START^IDNA_END^I^I$

May be unnecessary characters are there.How to remove that? I also need to extract 5000 bp upstream and downstream sequences from the start and end coordinate. So also try the following code but same error as before.

awk '$2>$3 {print $1 "\t" $2 "\t" $3 "\t" $3-5001 "\t" $2+5000 "\tpep\t0\t-"}' xx.txt > xx.bed

Do you have any idea how can I convert it to a proper bed file? Cheers

bedtools • 1.4k views
ADD COMMENTlink written 2.0 years ago by saadleeshehreen70
3
gravatar for finswimmer
2.0 years ago by
finswimmer13k
Germany
finswimmer13k wrote:

Hello,

assuming your DNA_START and DNA_END coordinates are 0-based your txt file is already a valid bed file, if you remove or comment out (by adding a # at the line beginning) the first line.

fin swimmer

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by finswimmer13k

Thanks. Your suggestion works

ADD REPLYlink written 2.0 years ago by saadleeshehreen70

If it solved your peoblem, please mark the answer as accepted.

ADD REPLYlink written 2.0 years ago by ATpoint38k
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: 1213 users visited in the last hour