[Bioperl-l] Reading protein from file - error

Florent Angly florent.angly at gmail.com
Tue May 31 22:03:39 UTC 2011


Hi Teja,

The code you wrote does not use Bioperl. If you want to use Bioperl, 
have a look here: http://www.bioperl.org/wiki/HOWTOs

As far as your script is concerned, I included some changes that should 
make it work:
> #! /usr/bin/env perl
>
> use strict;
> use warnings;
>
> # The filename of the file which contains the protein sequence
> my $proteinfilename =
> '/users/sukeerthiteja/desktop/perl/NM_021964fragment.pep';
>
> # First open the file and associate a filehandle with it. for readability
> purpose lets use the filehandle PROTEINFILE.
> open(PROTEINFILE, $proteinfilename) or die "Error: could not open file '$proteinfilename'\n$!\n";
>
> # Now we do the actual reading of the protein sequence data from the file,by
> using<  >  to get
> # input from the filehandle. We store the data into variable @protein.
> # This method is very inefficient for large files.
> my @protein =<PROTEINFILE>;
>
> #now that we got our data we can close the file
> close PROTEINFILE;
>
> #Print the protein onto the screen
> print "Here is the protein:\n\n";
>
> print "@protein\n";
>
> exit;
I encourage you to research what all these changes mean and to read a 
book or two to get more familiar with Perl: 
http://oreilly.com/catalog/9780596001322 or 
http://oreilly.com/catalog/9780596000806

Florent




On 30/05/11 13:12, sukeerthi teja Rallapalli wrote:
> Hi,
>
> I have been trying to execute this program and i am getting an error. Kindly
> help me.
>
> #!usr/bin/perl -w
>
> # The filename of the file which contains the protein sequence
> $proteinfilename =
> '/users/sukeerthiteja/desktop/perl/NM_021964fragment.pep';
>
> # First open the file and associate a filehandle with it. for readability
> purpose lets use the filehandle PROTEINFILE.
> open(PROTEINFILE, $proteinfilename);
>
> # Now we do the actual reading of the protein sequence data from the file,by
> using<  >  to get
> # input from the filehandle. We store the data into variable $protein
> $protein =<PROTEINFILE>;
>
> #now that we got our data we can close the file
> close PROTEINFILE;
>
> #Print the protein onto the screen
> print "Here is the protein:\n\n";
>
> print $protein;
>
> exit;
>
>
>
> ERROR:
>
> sukeerthi-tejas-macbook-pro:desktop sukeerthiteja$ perl 1.pl
> Here is the protein:
>
> {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
>
>
> I am not able to print the protein content on the screen.
>
> Thank you
> Regards
> Teja
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list