Hello Chromatic!
I have revised it to make it simpler. I need to parse a blast report. I am using an if/else to print to 2 different
out files. $hd_out should have:
Name: 13426|HD
Percent Identity: 97.0856102003643
Alignment: Bio::SimpleAlign=HASH(0x4012f2c)

and $hu_out should have:
Name: 13426|HU
Percent Identity: 99.7737556561086
Alignment: Bio::SimpleAlign=HASH(0x401965c)

Where "Bio::SimpleAlign=HASH(object)" is should have the actual data, which is an alignment.
I am confused about dereferencing the hash object since it is a scalar($hu_aln, $hd_aln) in my code

my $in = new Bio::SearchIO(-format => 'blast', -file => $maid_dir."\\".$maid."_aln.out", -report_type => 'blastn'); open (my $hu_out,">".$maid_dir."\\".$maid."_hu_parsed.out"); open (my $hd_out,">".$maid_dir."\\".$maid."_hd_parsed.out"); while(my $result = $in->next_result){ # get info about the first hit my $hit = $result->next_hit; my $hu_name = $hit->name; my $hd_name = $hit->name; if($hu_name =~ /^>.*HU/){ # get info about the first hsp of the first hit my $hsp = $hit->next_hsp; my $best_hsp = $hit->hsp('best'); my $hu_Percent_id = $hsp->percent_identity; print $hu_out "Name: ", $hu_name, "\n"; + print $hu_out "Percent Identity: ", $hu_Percent_id, "\n"; my $hu_aln = $hsp->get_aln; my $alnIO = Bio::AlignIO->new(-format =>"clustalw", -file +=> ">$hu_out"); $alnIO->write_aln($hu_aln); print $hu_out "Alignment: ", $hu_aln, "\n"; } else { $hd_name =~ /^>.*HD/; # get info about the first hsp of the first hit my $hsp = $hit->next_hsp; my $best_hsp = $hit->hsp('best'); my $hd_Percent_id = $hsp->percent_identity; print $hd_out "Name: ", $hd_name, "\n"; + print $hd_out "Percent Identity: ", $hd_Percent_id, "\n"; my $hd_aln = $hsp->get_aln; my $alnIO = Bio::AlignIO->new(-format =>"clustalw", -file +=> ">$hd_out"); $alnIO->write_aln($hd_aln); print $hd_out "Alignment: ", $hd_aln, "\n"; } } close $hu_out; close $hd_out;

I am expecting to get two files. Each with the name, Percent ID, and the sequence alignment.
Your help is appreciated!
LomSpace

In reply to Re^2: Problem with getting the right object by lomSpace
in thread Problem with getting the right object by lomSpace

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.