Hi

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"; } } }

In reply to Re^2: Bioperl + perl modules by Anonymous Monk
in thread Bioperl + perl modules by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.