Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 romping around the Monastery: (5)
As of 2015-07-04 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls