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):
What happens here?"if( $self->{'_seq'}->{$name} ) { $self->warn("Replacing one sequence [ +$name]\n") unless $self->verbose < 0; }
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:Warning message: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
My script:-------------------- WARNING --------------------- MSG: Replacing one sequence [hit1_EF374296.1_1-432/1-432] ---------------------------------------------------
The package: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;
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |