This is a test version of Biostars. For the public version, visit https://www.biostars.org.
fast way to change the title name

Dear all,

I want to change the header of big fasta file as this:

>JH208680.1 dna:scaffold scaffold:PelSin_1.0:JH208680.1:1:16024077:1 REF

CTACCCATTCCTTTCCTTTGGTGTACTGTAGTCCTTCTATTAGGGGAACTAATGGGGAAC
TTTTCTTTATGCACCCTCTCCACACCACTCTTGCTTTTATAGACCTCTATCATATCCCCC
CTCCGTCTCCTCTTCTCTAAGCTGAAAAGTCCCAGTCTCTTTAGCCTCTCTTCATATGGG
ACCTGTTCCAAACCC

And change it to

>JH208680.1 

CTACCCATTCCTTTCCTTTGGTGTACTGTAGTCCTTCTATTAGGGGAACTAATGGGGAAC
TTTTCTTTATGCACCCTCTCCACACCACTCTTGCTTTTATAGACCTCTATCATATCCCCC
CTCCGTCTCCTCTTCTCTAAGCTGAAAAGTCCCAGTCTCTTTAGCCTCTCTTCATATGGG
ACCTGTTCCAAACCC

I use this command, but take a little time as:

awk '{if($1 ~ /^>/){split($1,a,"\s"); print a[1]}else{print}}' input.fasta > input.rename.fasta

Did this fast or not? did any one have better solution for faster?

thanks

P.S. the ">" was not shown here, but it is as fasta file ZQ

genome

Did this fast or not? did any one have better solution for faster?

Are you losing money on this. Why worry if it is working :)

2 answers

cut -d ' ' -f 1 in.fa > out.fa

This would be fast. Send some of that money @Pierre's way.

Hi dear Genomax2 and Pierre, As I helped in this post, please send me the rest of money :- )

By the way, we (me and @Goutham Atla) suggested awk in that post because the header has different orders.

Take care

  seqtk rename file.fasta

Or you can use http://bioinf.shenwei.me/seqkit/

Log in to answer this question.