Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: PROTEIN FILE help me pleaseee

by Kenosis (Priest)
on Jan 30, 2013 at 16:59 UTC ( #1016101=note: print w/ replies, xml ) Need Help??


in reply to PROTEIN FILE help me pleaseee

You've been given excellent suggestions (!):

  • choroba shows the three-argument open, including using lexically-scoped variables (don't use global variables for file opens).
  • 2teez shows a crucial first step: always use strict; use warnings;
  • pvaldes imparted a hint on counting the number of "F"s in the sequence

Not to confuse matters here, but for your future reference (since you appear to be on a bioinformatics path), consider becoming well acquainted with Bio::SeqIO and its set of related modules.

Just as there are well-developed modules to parse HTML, XML, and CSV files, Bio::SeqIO lives to do the same for Fasta and other such formats.

For example, to retrieve and process each sequence within a Fasta file, you can do the following:

use strict; use warnings; use Bio::SeqIO; print "Please type the file name of the protein sequence data: "; chomp( my $proteinfilename = <STDIN> ); print "\n"; my $fastaIN = Bio::SeqIO->new( -file => $proteinfilename, -format => ' +Fasta' ); while ( my $seq = $fastaIN->next_seq() ) { print $seq->seq, "\n"; }

Each sequence in the Fasta file is accessible using the $seq->seq notation. The first part before the arrow operator is the sequence object; the part after the arrow operator is the method. These methods are covered in detail in the Bio::Seq module's documentation. In the example above, the sequence is printed, but a character count could be done there, too.

Hope this helps!


Comment on Re: PROTEIN FILE help me pleaseee
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016101]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-09-22 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (191 votes), past polls