[Bioperl-l] new-person question

Jason Stajich jason@chg.mc.duke.edu
Sun, 24 Sep 2000 20:37:31 -0400


The typical reply you'll get from this group is to use the
Bio::SeqIO classes, but I'm guessing if you are a newby to perl this might
seem daunting.

If you can get the bioperl modules installed on your system you should be
able to write the following code:

use Bio::SeqIO;

my $seq;
my $seqio = new Bio::SeqIO(-file=>'filename.fa',-format=>'Fasta');
while( $seq = $seqio->next_seq ) {
    # do something with the $seq object
    # this is a Bio::SeqI object so learn about this by typing
    # perldoc Bio::SeqI in your unix/dos shell.
    # if you cannot install Bioperl try looking at the website
    # http://www.bioperl.org first and then posting a question to the
    # bioperl list if you are still stuck

   # some typical things to do - print the actual sequence
    print "the sequence is ", $seq->seq(), "\n";
    print "the length is ", $seq->length(), "\n";
}
Hope this gets you started.
----- Original Message -----
From: Beth Chaplin <bchaplin@hsph.harvard.edu>
To: <bioperl-l@bioperl.org>
Cc: Beth Chaplin <bchaplin@hsph.harvard.edu>
Sent: Sunday, September 24, 2000 3:38 PM
Subject: [Bioperl-l] new-person question


> I am just learning perl, and am trying to write a program that will read
> in a file of sequences in Fasta format.
>
> >title
> sequence...
> >title
> sequence...
>
> I have a loop that takes each line, and if the line starts with '>',
> should store that line in an array that will contain only sequence names.
> However, the '>' is causing problems. The coding is:
>
> while (<>)
> {
>         $templine = $_;
>         if ($templine =~ /\b>/)
>         {
>                 other stuff;
>         }
> }
>
> and it works for perfectly if I use a character, such as '>', but not with
> '>'. I tried putting a backslash (in the code) before the >, but that
> didn't help.
>
> If you have time to answer, thanks. If this question is too basic, or in
> any way an inappropriate posting for this mailing list, please let me
> know.
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>