There were a few issues with your posted code, but in simple script form this gave the same result:

use strict; use warnings; ++$|; ## buffering off my %align; my $count = 0; my %c2name; use Bio::SimpleAlign; my $self = Bio::SimpleAlign->new(); print "---> Reading data\n"; while( <DATA> ) { /^([^\#]\S+)\s+([A-Za-z\.\-]+)\s*/ && do { my $name = $1; my $seq = $2; if( ! defined $align{$name} ) { $count++; $c2name{$count} = $name; } $align{$name} .= $seq; print "Count >$count< - Adding Name >$name<\n\tSeq >$seq<\n"; }; } print "---> Forming alignment\n"; $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; } ## make sure id is unique #$seqname .= 'x' while ( exists $align{id}{$seqname} ); #++$align{id}{$seqname}; print "Name >$name<\n\tID >$seqname<\n"; my $seq = new Bio::LocatableSeq( '-seq'=>$align{$name}, '-id'= +>$seqname, '-start'=>$start, '-end'=>$end, '-strand'=>$strand, '-type'=>' +aligned' ); $self -> add_seq($seq); $count++; } print "Count : $count\n"; __DATA__ hit1_EF374296.1_1-432/1-432 uauGGAAACWUACU hit1_AM161438.1_1-497/20-516 gAGAAACCCUGGAA hit1_AM161438.1_1-497/1-1:497-993 gGAAAAUCCGUCGA 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

which gave :

---> Reading data Count >1< - Adding Name >hit1_EF374296.1_1-432/1-432< Seq >uauGGAAACWUACU< Count >2< - Adding Name >hit1_AM161438.1_1-497/20-516< Seq >gAGAAACCCUGGAA< Count >3< - Adding Name >hit1_AM161438.1_1-497/1-1:497-993< Seq >gGAAAAUCCGUCGA< Count >4< - Adding Name >hit1_EF374296.1_1-432/1-1:432-863< Seq >UGAAAAUCCGUCGA< Count >5< - Adding Name >hit1_EF374296.1_509-949/509-509:949-1389< Seq >GGAAAAUCCGUCGA< Count >6< - Adding Name >hit1_EF374296.1_509-949/938-1382< Seq >AUAGUAAGAGGAAA< Count >7< - Adding Name >hit1_EF374297.1_30-470/30-30:470-910< Seq >GGAAAAUCCGUCGA< ---> Forming alignment Name >hit1_EF374296.1_1-432/1-432< ID >hit1_EF374296.1_1-432< Name >hit1_AM161438.1_1-497/20-516< ID >hit1_AM161438.1_1-497< Name >hit1_AM161438.1_1-497/1-1:497-993< ID >hit1_AM161438.1_1-497< Name >hit1_EF374296.1_1-432/1-1:432-863< ID >hit1_EF374296.1_1-432< Name >hit1_EF374296.1_509-949/509-509:949-1389< ID >hit1_EF374296.1_509-949< -------------------- WARNING --------------------- MSG: Replacing one sequence [hit1_EF374296.1_1-432/1-432] --------------------------------------------------- Name >hit1_EF374296.1_509-949/938-1382< ID >hit1_EF374296.1_509-949< Name >hit1_EF374297.1_30-470/30-30:470-910< ID >hit1_EF374297.1_30-470< Count : 7

The problem i think was using $seqname as your object id, raher than the full (unique) id. Bio::SimpleAlign needs unique ids maybe?

Anyway, I added in the bit that made sure the ids are unique ( currently commented out in the above ), but still make sense to you(?), and it give the same as above, but the error is gone.

Maybe this is a little bit like just turning off warnings... but the problem does stem from your ids, not the code, so i think this is a reasonable workaround, which doesn't rely on users having to always provide unique ids...

Hope this helps?

Just a something something...

In reply to Re: [BioPerl] add_seq gives warning: why? by BioLion
in thread [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.