in reply to Re: Bioperl + perl modules
in thread Bioperl + perl modules
I have progressed slightly since my post. Here is my newer code below, it doesn't print any warnings or errors, I am having a problem in the loop starting foreach $key ( $ac->get_all_annotation_keys() ) {
. How can I tell whether $ac variable has a value? If I print it out, it looks like a hash.
+ my $seqio = $gb->get_Stream_by_id(['13474692']); #print $gb->get_Stream_by_id(['13474692']); + + while( my $seq = $seqio->next_seq ) { print "seq is ", $seq->display_id, "\n"; my @f=$seq->get_SeqFeatures; #This gives you the annotation of t +he retrieved sequence object + foreach my $feat (@f) { + print "Feature ",$feat->primary_tag," starts ",$feat->start," e +nds ", $feat->end," strand ",$feat->strand,"\n"; + # features retain link to underlying sequence object #print "Feature sequence is ",$feat->seq->seq(),"\n"; + my $ac=$feat->annotation(); + # HOW CAN I TELL IF $ac HAS A VALUE print "GETS TO HERE\n"; + foreach $key ( $ac->get_all_annotation_keys() ) { print "DOESN'T GET TO HERE\n"; @values = $ac->get_Annotations($key); foreach $value ( @values ) { # value is an Bio::AnnotationI, and defines a "as_text +" method print "Annotation ",$key," stringified value ",$value- +>as_text,"\n"; + # also defined hash_tree method, which allows data ori +entated # access into this object $hash = $value->hash_tree(); } } + + next unless ($ac->get_Annotations('coded_by')); my @coded=$ac->get_Annotations('coded_by'); foreach my $location (@coded) { print $location->value, " is the location that codes this pro +tein\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Bioperl + perl modules
by Joost (Canon) on Jun 27, 2005 at 10:35 UTC |