Header and sequence are coming in loop:
$header = "seq1";
$sequence = "GTGGTCAGAAAAGTGGCCTCAGCCCATTTCCAGCATCCTATGGCTATCTAAGTAGGAAGACGATGAGCTATGGAA";
Sequence is single line without newline.
I want output multi-fasta like this below. Sequence should have newline after each 60 bases.
>seq1
GTGGTCAGAAAAGTGGCCTCAGCCCATTTCCAG
CATCCTATGGCTATCTAAGTAGGAAGACGATGA
GCTATGGAA
>seq2
AAGTGGCCTCAGCCCATTTCCAGCATCCTATGGC
TATCTAAGTAGGAAGACGATGAGCTATGGAA
Thanks
This was asked before here and the solution (pre-v5.10) is:
That formats the sequence, then you just need to join the id and sequence with a newline when you print.
Thanks a lot SES.
It was a fantastic solution with a line code. It worked good when I added this in my script.
Can you please give me some hint to create loop in perl? I need that at the end of my perl code.
Thanks Ram and Dylan
Look at the
Text::Wrap
module if you need a perl specific and easy method.Thanks. I will try that
I think the following lines could be an alternative solution.
Yes, the loop is a good basic alternative, but the RegEx is better, this being Perl.
The problem with the regex is that it is limited to a max sequence length of ~32k, which gives you trouble with contigs, etc. Here is a loop solution that should be faster than regex.