Skip to content

Commit

Permalink
Using coord_style instead of coordstyle for clarity and consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Nov 25, 2011
1 parent 2997f00 commit c60036f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions Bio/Seq/SimulatedRead.pm
Expand Up @@ -110,7 +110,7 @@ use base qw( Bio::Seq::Quality Bio::LocatableSeq );
-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().
-coordstyle => Define what coordinate system to use. See coordstyle().
-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 All @@ -119,10 +119,10 @@ use base qw( Bio::Seq::Quality Bio::LocatableSeq );
sub new {
my ($class, @args) = @_;
my $self = $class->SUPER::new(@args);
my ($qual_levels, $reference, $mid, $errors, $track, $coordstyle) =
$self->_rearrange([qw(QUAL_LEVELS REFERENCE MID ERRORS TRACK COORDSTYLE)], @args);
$coordstyle = defined $coordstyle ? $coordstyle : 'bioperl';
$self->coordstyle($coordstyle);
my ($qual_levels, $reference, $mid, $errors, $track, $coord_style) =
$self->_rearrange([qw(QUAL_LEVELS REFERENCE MID ERRORS TRACK COORD_STYLE)], @args);
$coord_style = defined $coord_style ? $coord_style : 'bioperl';
$self->coord_style($coord_style);
$track = defined $track ? $track : 1;
$self->track($track);
$qual_levels = defined $qual_levels ? $qual_levels : [];
Expand Down Expand Up @@ -247,7 +247,7 @@ sub _create_desc {
}
# Position of read on reference sequence: start, end and strand
my $strand = $self->strand;
if ($self->coordstyle eq 'bioperl') {
if ($self->coord_style eq 'bioperl') {
$desc_str .= 'start='.$self->start.' end='.$self->end.' ';
if (defined $strand) {
# Strand of the reference sequence that the read is on
Expand Down Expand Up @@ -619,9 +619,9 @@ sub track {
}


=head2 coordstyle
=head2 coord_style
Title : coordstyle
Title : coord_style
Function : When tracking is on, define which 1-based coordinate system to use
in the read description:
* 'bioperl' uses the start, end and strand keywords (default),
Expand All @@ -631,22 +631,22 @@ sub track {
* 'genbank' does only provide the position keyword. Example:
position=1..10
position=complement(1..10)
Usage : my $coordstyle = $read->track();
Usage : my $coord_style = $read->track();
Arguments: 'bioperl' or 'genbank'
Returns : 'bioperl' or 'genbank'
=cut

sub coordstyle {
my ($self, $coordstyle) = @_;
sub coord_style {
my ($self, $coord_style) = @_;
my %styles = ( 'bioperl' => undef, 'genbank' => undef );
if (defined $coordstyle) {
if (not exists $styles{$coordstyle}) {
die "Error: Invalid coordinate style '$coordstyle'\n";
if (defined $coord_style) {
if (not exists $styles{$coord_style}) {
die "Error: Invalid coordinate style '$coord_style'\n";
}
$self->{coordstyle} = $coordstyle;
$self->{coord_style} = $coord_style;
}
return $self->{coordstyle};
return $self->{coord_style};
}


Expand Down
6 changes: 3 additions & 3 deletions t/Seq/SimulatedRead.t
Expand Up @@ -64,10 +64,10 @@ is join(' ',@{$read->qual}), '';
is $read->track, 1;
is $read->desc, 'reference=human_id start=1 end=12 strand=+1 description="The human genome"';

ok $read = Bio::Seq::SimulatedRead->new( -reference => $ref, -track => 1, -coordstyle => 'bioperl' );
ok $read = Bio::Seq::SimulatedRead->new( -reference => $ref, -track => 1, -coord_style => 'bioperl' );
is $read->desc, 'reference=human_id start=1 end=12 strand=+1 description="The human genome"';

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

ok $read = Bio::Seq::SimulatedRead->new( -reference => $ref, -qual_levels => [30, 10]);
Expand Down Expand Up @@ -98,7 +98,7 @@ is $read->seq, 'GGGGTTTTTTTA';
is join(' ', @{$read->qual}), '30 30 30 30 30 30 30 30 30 30 30 30';
is $read->desc, 'reference=human_id start=1 end=12 strand=-1 description="The human genome"';

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

ok $read = Bio::Seq::SimulatedRead->new( -reference => $ref, -start => 2, -end => 8, -qual_levels => [30, 10]);
Expand Down

0 comments on commit c60036f

Please sign in to comment.