0

I am trying to use bedtools getfasta on a txt file but some of the chromosome coordinates from big to low, how can I fix this so that all chromosome coordinates are from low to big? I am using command line on Ubuntu.

I expected the command to run properly when running but the bedtools getfasta -fi file.fasta -bed file.txt

the text file looks like this:

ChromosomeName Position1 Position2 ChromosomeName Position1 Position2 ChromosomeName Position1 Position2

Sometimes P1 > P2 which causes the error in the title.

Deep
  • 1
  • 1
    This doesn't have anything to do with programming (i.e. you're not writing software, you're just trying to use an existing program) and is therefore [off-topic for stackoverflow](https://stackoverflow.com/help/on-topic). I suggest you post your question with an example of your actual data (if possible) to https://bioinformatics.stackexchange.com/ to get advice from an expert @Deep. – jared_mamrot Jun 07 '23 at 03:43

1 Answers1

0

Hope this helps. It sounds like you could either 1) go in manually and fix/delete the positions if you only have a few places to fix. Otherwise 2) if you have a 3 column bed file like this: chrA posA posB, an awk command along the lines of:

awk '{OFS="\t"; if ($3-$2 > 0) {print}' your_file.bed > fixed_file.bed

This will only print out the positions where column 3-column2 (aka posB-posA) is a positive value. If posA is greater than posB, the line won't be printed. You will lose those malformed lines this way though.

-Laura