No Perl Class today

5 views
Skip to first unread message

Sofia Robb

unread,
Dec 7, 2011, 1:24:00 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hello Everyone,

I have not heard back from anyone that attempted the problem and can make the meeting today, so we will meet on another day to discuss this exercise.

Sofia


Zhigang Wu

unread,
Dec 7, 2011, 1:29:07 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hey,
I have figured out a solution for the problem.

Zhigang

--

---------------------------------------------------------------------------------------------
PhD Candidate in Plant Biology
Department of Botany and Plant Sciences
University of California, Riverside

Sofia Robb

unread,
Dec 7, 2011, 1:39:23 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hi Zhigang,

You are the only one that has mentions that they attempted the problem and can make it today. I have another person's solution. Would you like me to share it with you? What would you like to do?

sofia

Sahar Nohzadeh-Malakshah

unread,
Dec 7, 2011, 1:43:57 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hi;
I worked on the reg exp part and almost got it right, but the last character has problem:

#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
my $usage="$0 <.fa>";
my($fa)=$ARGV[0];
# N-X-S/T where X is not P

open (FA,$fa) or die "cannot open $fa:$!";
my $i=0;
while(<FA>){
        if($_=~/(N[^P](\S|\T))/){
                print "$1\n";
                $i++;}
};
print "totNum:$i\n";
 

On Wed, Dec 7, 2011 at 10:24 AM, Sofia Robb <sofi...@gmail.com> wrote:



--
Sahar N.Malakshah
PhD Candidate
University of California, Riverside

Department of Botany and Plant Sciences

Zhigang Wu

unread,
Dec 7, 2011, 1:58:15 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Sofia,
I'd like to let's share the code and discuss with each other in
another day when we meet.


Zhigang

Sofia Robb

unread,
Dec 7, 2011, 2:07:49 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hi Sahar,

Good Work :)

You do not need to use a '\' in front of the S and the T. They are not special characters. And the way your regular expression is written you are only looking to find the pattern once.  if you want to continue to search for matches after you find one match in your sequence you need to use the 'g' modifier  /pattern/g

And I see that you have 'use::Bio::SeqIO;';
you can use this module for getting a complete sequence record from your fasta file.  The way you using the while loop 'while(<FA>)'  you will only be able to check for your pattern in one line of your sequence at a time.

here is how you would use Bio::SeqIO to get a complete sequence record from your fasta file.


my $seqIO_object = Bio::SeqIO->new( -file => $fa, -format => "fasta" );
while (my $seq_object = $seqIO_object->next_seq){
my $seq = $seq_object->seq;
   
        ##add your regex here to search complete sequence
           if($seq=~/(N[^P](S|T))/){
          
            }
 
}
      
sofia

Sofia Robb

unread,
Dec 7, 2011, 2:11:50 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Hi Zhigang,

That sounds like a good plan.

Here is the only solution that was shared with me. I am not sure if she would like me to share her name or not. It runs without errors.

PNGS_charge.pl

Zhigang Wu

unread,
Dec 7, 2011, 3:27:25 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Thanks. sofia.
I have separated retrieving a fasta file from genbank and searching
the pattern in a fasta file into two different program. Here I am
sending you the code just doing the second job.


Zhigang

> Sofia

tranlsated.pl

Sahar Nohzadeh-Malakshah

unread,
Dec 7, 2011, 4:58:09 PM12/7/11
to ucr-perl-bi...@googlegroups.com
Thanks so much:)
Reply all
Reply to author
Forward
0 new messages