Skip to content

Commit

Permalink
Fixed bug where description was not updated as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Nov 25, 2011
1 parent c60036f commit 6b81602
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
20 changes: 10 additions & 10 deletions Bio/Seq/SimulatedRead.pm
Expand Up @@ -102,14 +102,14 @@ use base qw( Bio::Seq::Quality Bio::LocatableSeq );
-end => 135 ,
-strand => 1 ,
);
Arguments: -reference => Bio::SeqI, Bio::PrimarySeqI object representing the
reference sequence to take the read from. See
reference().
-errors => Hashref representing the position of errors in the read
See errors().
-mid => String of a MID to prepend to the read. See mid().
-track => Track where the read came from in the read description?
See track().
Arguments: -reference => Bio::SeqI, Bio::PrimarySeqI object representing the
reference sequence to take the read from. See
reference().
-errors => Hashref representing the position of errors in the read
See errors().
-mid => String of a MID to prepend to the read. See mid().
-track => Track where the read came from in the read description?
See track().
-coord_style => Define what coordinate system to use. See coord_style().
All other methods from Bio::LocatableSeq are available.
Returns : new Bio::Seq::SimulatedRead object
Expand Down Expand Up @@ -354,7 +354,7 @@ sub _update_desc_mid {
# Sequencing errors introduced in the read
my $mid_str = "mid=".$mid;
my $desc_str = $self->desc;
$desc_str =~ s/(strand=\S+)( mid=\S+)?/$1 $mid_str/g;
$desc_str =~ s/((position|strand)=\S+)( mid=\S+)?/$1 $mid_str/g;
$self->desc( $desc_str );
}
return 1;
Expand Down Expand Up @@ -583,7 +583,7 @@ sub _update_desc_errors {
}
$err_str =~ s/,$//;
my $desc_str = $self->desc;
$desc_str =~ s/(strand=\S+( mid=\S+)?)( errors=\S+)?/$1 $err_str/g;
$desc_str =~ s/((position|strand)=\S+( mid=\S+)?)( errors=\S+)?/$1 $err_str/g;
$self->desc( $desc_str );
}
return 1;
Expand Down
15 changes: 13 additions & 2 deletions t/Seq/SimulatedRead.t
Expand Up @@ -35,7 +35,7 @@ $ref4 = Bio::LocatableSeq->new( -id => 'a_thaliana',
-seq => 'CGTATTCTGAGGAGAGCTCT' );


# Basic object
## Basic object

ok $read = Bio::Seq::SimulatedRead->new( );
isa_ok $read, 'Bio::Seq::SimulatedRead';
Expand Down Expand Up @@ -203,12 +203,23 @@ is $read->desc, 'reference=human_id start=1 end=12 strand=+1 errors=6+G,6+G desc

# More tracking tests

ok $read = Bio::Seq::SimulatedRead->new( -reference => $ref, -mid => 'ACGT', -qual_levels => [], -coord_style => 'genbank' );
is $read->desc, 'reference=human_id position=1..12 mid=ACGT description="The human genome"';

ok $read->mid('AAAA');
is $read->desc, 'reference=human_id position=1..12 mid=AAAA description="The human genome"';

$errors = {};
$errors->{'6'}->{'+'} = 'GG';
ok $read->errors($errors);
is $read->desc, 'reference=human_id position=1..12 mid=AAAA errors=6+G,6+G description="The human genome"';

ok not($read->track(0)), 'track()';
is $read->track, 0;
is $read->desc, undef;
ok $read->track(1);
is $read->track, 1;
is $read->desc, 'reference=human_id start=1 end=12 strand=+1 errors=6+G,6+G description="The human genome"';
is $read->desc, 'reference=human_id position=1..12 mid=AAAA errors=6+G,6+G description="The human genome"';


# qual_levels() method
Expand Down

0 comments on commit 6b81602

Please sign in to comment.