This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Making bed files from fasta

Trying to run a biopython script in Windows cmd to make a bed file from a draft genome downloaded from NCBI. I get the following error. The headers appear to be fine. I have used the biopython script many times with success previously. Can someone see what the error is please?

C:\Python34>python.exe test.fasta make_bed_from_fasta.py >test.bed
File "test.fasta", line 1
    >KQ503367.1
    ^
SyntaxError: invalid syntax

The fasta looks like this, top lines. PS.I am not sure why the post is edited to remove the ">" but it is present in the header like this ">KQ503367.1" with sequence on following line.

>KQ503367.1
TGGAAAATTTGGTttgtaattctttttctaaaaaaaacttattttggGGTGTATGATGTGGGTTATTTGGGAGGGGTGAG
AAAAAGTGTGAAACAAATGGTTGAAGggtttttggaagttttttttccaaatacaggttttttgtttcattttaatttaa
aatgggcCTGGGGAAacccttacatgtttttaccaaattggTTAGGTGGGTTTACCAAAGCCCTAAATTGATTAGAACTt
genome

3 answers

My apologies, my biopython script was corrupted. The fasta is okay.

I think you've already figured out that you need to pass the python script as the first argument instead of the fasta file...

Thanks Matt. Yes I should have looked a bit closer before posting.

I guess I'll also mention that you could use pyfaidx for this as well:

$ pip install pyfaidx  
$ faidx --transform bed test.fasta > test.bed

Log in to answer this question.