This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to modify Chromosome names in genome fasta file

Hi everyone,

I'd like to know how to modify chromosome names in my genome fasta file.

Specifically, I'd like to substitute:

chr1_1-hap-1
chr2_1-hap-1
...
chrX_1-hap-1
chrY_1-hap-1

with:

chr1
chr2 ... chrX, chrY 

Can someone suggest me how to do that?

Thanks in advance

fasta

1 answer

cut -d '_' -f 1 < in.fa

Just dissecting this nice one-liner for the sake of learning. Thank you Pierre.

cut ... < in.fa : print the selected parts of lines from in.fa to standard output (also prints the lines with no delimiters)
-d '_': set the '_' char as field delimiter    
-f 1: select the first field

Log in to answer this question.