Hi Pierre. Just curious if you can add padding with zeroes simply with awk. Eg: seq1 --> seq0001, seq253 --> seq0253. Happy New Year :)
• 0 views
•
link
Hi there, Is there away change identifiers in a fasta file. For examplt from
>fastsdde135667667
actgcagtctga
>fgdte12875
actggact
to
>Seq1
actgcagtctga
>Seq2
actggact
use awk:
awk '/^>/ { printf(">Seq%d\n",(++i)); next;} { print }' < input.fa > output.fa
Ex:
echo ">fastsdde135667667
actgcagtctga
>fgdte12875
actggact" | awk '/^>/ { printf(">Seq%d\n",(++i)); next;} { print }'
>Seq1
actgcagtctga
>Seq2
actggact
Hi Pierre. Just curious if you can add padding with zeroes simply with awk. Eg: seq1 --> seq0001, seq253 --> seq0253. Happy New Year :)
@Eric, yes that works like the std C printf: printf(">Seq%03d\n",(++i))
@Pierre, nice! Thanks. Have to learn more C and C++ some time.
also, this:
#!/usr/bin/perl
$count =1;
while (<>){
if (s/^>.*/>Seq$count/){;
$count++;
}
print;
}
>Seq1
actgcagtctga
>Seq2
actggact
Log in to answer this question.