intect has asked for the wisdom of the Perl Monks concerning the following question:
Hi my fasta file looks like:
>dddd
abcdef
>eeee
bcdef
There is no space between lines. I want to add 'aaaa' to the beginning of the sequences (i.e., abcdef and bcdef in the example). I used the following script but it gives me a connected long sequence. Can anyone help me identify the problem? Thanks XFuse warnings; use strict; my $read_mid1 = 'Reads.fna'; my $read_mid1_correct = 'Reads_correct.fa'; open ( my $input_fh, "<", $read_mid1 ); open ( my $output_fh, ">", $read_mid1_correct); while (my $line = <$input_fh> ) { unless ($line =~ /^>/) { $line =~ s/^/ACGAGTGCGT/; print $output_fh $line; } } close ( $input_fh ); close ( $output_fh );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: add letters to the begin of the sentence
by choroba (Cardinal) on Sep 12, 2013 at 16:31 UTC | |
|
Re: add letters to the begin of the sentence
by Kenosis (Priest) on Sep 12, 2013 at 17:56 UTC | |
|
Re: add letters to the begin of the sentence
by kcott (Archbishop) on Sep 12, 2013 at 21:46 UTC | |
by intect (Initiate) on Sep 13, 2013 at 13:18 UTC | |
by kcott (Archbishop) on Sep 13, 2013 at 19:03 UTC | |
|
Re: add letters to the begin of the sentence
by Laurent_R (Canon) on Sep 12, 2013 at 17:12 UTC |