Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: add letters to the begin of the sentence

by Kenosis (Priest)
on Sep 12, 2013 at 17:56 UTC ( #1053777=note: print w/replies, xml ) Need Help??


in reply to add letters to the begin of the sentence

Since you're working with fasta files, consider becoming familiar with Bio::SeqIO--a module that's a powerful tool for working with fasta and other such formats.

For example, to achieve your desired results using the module, you can do the following:

use strict; use warnings; use Bio::SeqIO; my $in = Bio::SeqIO->new( -file => 'file1.fasta', -format => 'Fasta' + ); my $out = Bio::SeqIO->new( -file => '>file2.fasta', -format => 'Fasta' + ); while ( my $seq = $in->next_seq() ) { my $newSeq = Bio::Seq->new( -display_id => $seq->id, -seq => 'aaaa' . $seq->seq ); $out->write_seq($newSeq); }

Output results:

>dddd aaaaabcdef >eeee aaaabcdef

Notice that the module permits you to access sequences and ids as objects, using the "->" notation. For example, in the above, we prepend "aaaa" to the original sequence by doing the following:

'aaaa' . $seq->seq

Then, create a new object with the modified sequence that's written to a new file.

The module offers many more options for working with fasta (and other similarly formatted) files.

Hope this helps!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053777]
help
Chatterbox?
[choroba]: I often can't log in to pause. But after it fails for the first time, everything works for the second time.
[cavac]: Ok, thanks for the information
[choroba]: Yes, tried now. Login didn't show the login window at all, timed out, but worked for the second time instantly.
[choroba]: Trying the daemon log...
[choroba]: It seems very slow. But the internet is weird here in Vietnam...
[choroba]: again, stopping it and trying for the second time fixed the problem

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-02-22 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (325 votes). Check out past polls.