GFF to BED conversion
2
1
Entering edit mode
2.4 years ago
Maliha ▴ 20

I have installed BEDTOOLS to convert a GFF file into a BED format.

cat /home/maliha/maliha/data | \ awk 'BEGIN {OFS = "\t"};{if ($3=="gene") print  $1,$4-1,$5}' | \ sed "s/^/chr/"> mygenes.bed

I have run this command to do the conversion. However, after executing this command I am getting this error-

 Command ' sed' not found, did you mean:

  command 'msed' from deb mblaze (0.6-1)
  command 'sed' from deb sed (4.7-1)
  command 'ssed' from deb ssed (3.62-7build1)

Try: sudo apt install <deb name>


Command ' awk' not found, did you mean:

  command 'nawk' from deb gawk (1:5.0.1+dfsg-1)
  command 'nawk' from deb mawk (1.3.4.20200120-2)
  command 'awk' from deb gawk (1:5.0.1+dfsg-1)
  command 'awk' from deb mawk (1.3.4.20200120-2)
  command 'awk' from deb original-awk (2012-12-20-6)
  command 'mawk' from deb mawk (1.3.4.20200120-2)
  command 'gawk' from deb gawk (1:5.0.1+dfsg-1)

Try: sudo apt install <deb name>

If someone can help me to solve this problem, I'd be really grateful.

BED GFF ubuntu • 3.5k views
ADD COMMENT
0
Entering edit mode

it quite difficult to understand your command line with this formating and those \. Please reformat. Don't you have a problem with your ${PATH} ? sed and awk are ubiquitous, you should find them one any linux.

ADD REPLY
0
Entering edit mode

I have reformatted the command line. Please see if it's all right now. I have installed awk and sed seperately. But still, I am getting this similar error.

ADD REPLY
0
Entering edit mode

what does echo $PATH gives you ?

ADD REPLY
0
Entering edit mode

I have reformatted the command line. /home/maliha/maliha/data | \ awk 'BEGI...

this \ inside a command is not a valid .

ADD REPLY
1
Entering edit mode
2.4 years ago

Frankly, I have to recommend investing some time to familiarize yourself with the command line first, before continuing to work on your actual problem. It should take you less than 30min and once you know what "words" correspond to program calls and that | is used to construct pipes, a lot of the other things will fall in place.

After all, you are using the programs cat, awk and sed here, but nothing of the Bedtools suite.

But now back to your problem, which can be simplified a lot. Try:

which awk

If it really says awk not found, then you would need to install it, but it will probably return /usr/bin/awk or something alike. In that case, you can just run

awk 'BEGIN {OFS = "\t"};$3=="gene"{print "chr"$1,$4-1,$5}'  annotation.gtf > genes.bed

This assumes that your original GTF file is called annotation.gtf. Like with your original comment, you will however then not know which gene corresponds to that region, since you are only converting the coordinates and not the name. Is that the desired output?

ADD COMMENT
1
Entering edit mode
2.4 years ago

Via BEDOPS:

gff2bed < in.gff > out.bed
gtf2bed < in.gtf > out.bed

Ref. https://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion.html

ADD COMMENT

Login before adding your answer.

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