Dear Monks,

Same question as before, this time no longer as an anonymous monk.

My original question:

"At a certain point in my code the Bio::SimpleAlign add_seq method is called. This method will give a warning if (chunk of the add_seq code):

if( $self->{'_seq'}->{$name} ) { $self->warn("Replacing one sequence [ +$name]\n") unless $self->verbose < 0; }
What happens here?"

You kindly replied that the most likely thing was that there are two sequences with the same name. I checked this and True, there are more sequences with the same name. But only one of them involkes this warning!?!

Now what?

To clarify:

Sample input file:
hit1_AM161438.1_1-497/20-516 gAGAAACCCUGGAA hit1_AM161438.1_1-497/1-1:497-993 gGAAAAUCCGUCGA hit1_EF374296.1_1-432/1-432 uauGGAAACWUACU hit1_EF374296.1_1-432/1-1:432-863 UGAAAAUCCGUCGA hit1_EF374296.1_509-949/509-509:949-1389 GGAAAAUCCGUCGA hit1_EF374296.1_509-949/938-1382 AUAGUAAGAGGAAA hit1_EF374297.1_30-470/30-30:470-910 GGAAAAUCCGUCGA
Warning message:
-------------------- WARNING --------------------- MSG: Replacing one sequence [hit1_EF374296.1_1-432/1-432] ---------------------------------------------------
My script:
use strict; use warnings; use MyAlign; my $aln = new MyAlign; open ( ALIGN, "<inputAlignmentFile" ) or die "failed to open inputAlig +nmentFile"; $aln -> read_alignment ( \*ALIGN ); close ALIGN;
The package:

use Bio::SimpleAlign; sub new { my $caller = shift; my $class = ref( $caller ) || $caller; my $self = $class -> SUPER::new(); return $self; } sub read_alignment { my $self = shift; my $in = shift; my( %align, %c2name, $count ); while( <$in> ) { /^([^\#]\S+)\s+([A-Za-z\.\-]+)\s*/ && do { my $name = $1; my $seq = $2; if( ! defined $align{$name} ) { $count++; $c2name{$count} = $name; } $align{$name} .= $seq; next; }; } $count = 0; foreach my $no ( sort { $a <=> $b } keys %c2name ) { my $name = $c2name{$no}; my( $seqname, $start, $end, $strand ); if( $name =~ /(\S+)\/(\d+)-(\d+)$/ ) { $seqname = $1; $start = $2; $end = $3; } elsif ( $name =~ /(\S+)\/(\d+)-(\d+):(\d+)-(\d+)/ ) { $seqname = $1; my $ns = $2; my $s = $3; my $e = $4; my $ne = $ +5; $start = "$ns-$s"; $end = "$e-$ne"; # surprise: this is le +gal $strand = 1; } my $seq = new Bio::LocatableSeq( '-seq'=>$align{$name}, '-id'= +>$seqname, '-start'=>$start, '-end'=>$end, '-strand'=>$strand, '-type'=>' +aligned' ); $self -> add_seq($seq); $count++; } return $count; }


In reply to [BioPerl] add_seq gives warning: why? by BioNick

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.