This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BLAT error sequnces

Hello,
I use a BLAT alignment with two files.
But here is the error "Error: sequence name channel_231_read_27_template is repeated in the database, all nemes must be unique"

how to change the sequence header of a Fasta file?

or have you another idea.
Thanks

alignment blat test

1 answer

If there is only one offending header, edit it directly using an editor of choice otherwise use sed. If the sequences are repeated then take out one of the copies.

Is there a possibility of changing the header of sequences ?

Something like

$ sed 's/channel_231_read_27_template/channel_231_read_27_template_2/' your_file > new_file

To replace only first instance

$ sed '0,/channel_231_read_27_template/s/channel_231_read_27_template/channel_231_read_27_template_3/' your_file > new_file

I have three copies.

actually, they are not copies but just the same they header.

How I can change the headers?

$ sed 's/channel_231_read_27_template/channel_231_read_27_template_2/' your_file > new_file

it changes the three headers by "channel_231_read_27_template_2"

another solution?

thanks

$ awk 'NR==1,/channel_231_read_27_template/{sub(/channel_231_read_27_template/, "channel_231_read_27_template_2")} 1' your_file
$ awk 'NR==2,/channel_231_read_27_template/{sub(/channel_231_read_27_template/, "channel_231_read_27_template_3")} 1' your_file

there is a lot of repetition.

I want to change the headers of all sequences.

do I change the headers in command line?

Thank you

I am not sure why your fasta headers are repeated in the file.

If the sequences are different then the headers should have been different to begin with. If the sequences are identical then you should be using a non-redundant copy with only one representative of each sequence in your files.

If you still want to proceed you will have to think of a programmatic way to get the headers and then iterate through them to change ones you want.

Log in to answer this question.