Bio::Factory
FTLocationFactory
Toolbar
Summary
Bio::Factory::FTLocationFactory - A FeatureTable Location Parser
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
# parse a string into a location object
$loc = Bio::Factory::FTLocationFactory->from_string("join(100..200, 400..500");
Description
Implementation of string-encoded location parsing for the Genbank feature table
encoding of locations.
Methods
Methods description
Title : _parse_location Usage : $loc = $locfactory->_parse_location( $loc_string)
Function: Parses the given location string and returns a location object
with start() and end() and strand() set appropriately.
Note that this method is private.
Returns : A Bio::LocationI implementing object or undef on failure
Args : location string |
Title : from_string Usage : $loc = $locfactory->from_string("100..200"); Function: Parses the given string and returns a Bio::LocationI implementing object representing the location encoded by the string.
This implementation parses the Genbank feature table
encoding of locations.
Example :
Returns : A Bio::LocationI implementing object.
Args : A string. |
Methods code
sub _parse_location
{ my ($self, $locstr) = @_;
my ($loc, $seqid);
$self->debug( "Location parse, processing $locstr\n");
if($locstr =~ /^(\S+):(.*)$/) {
$seqid = $1;
$locstr = $2;
}
my ($start, $end) = split(/\.\./, $locstr);
$start =~ s/^\(+//;
$start =~ s/\)+$//;
$end =~ s/^\(+// if $end;
$end =~ s/\)+$// if $end;
my $loctype = ".."; my $locclass = "Bio::Location::Simple";
if(! defined($end)) {
if($locstr =~ /(\d+)([\.\^])(\d+)/) {
$start = $1;
$end = $3;
$loctype = $2;
$locclass = "Bio::Location::Fuzzy"
unless (abs($end - $start) <= 1) && ($loctype eq "^");
} else {
$end = $start;
}
}
if ( ($start =~ /[\>\<\?\.\^]/) || ($end =~ /[\>\<\?\.\^]/) ) {
$locclass = 'Bio::Location::Fuzzy';
}
$loc = $locclass->new(-verbose => $self->verbose,
-start => $start,
-end => $end,
-strand => 1,
-location_type => $loctype);
if($seqid) {
$loc->is_remote(1);
$loc->seq_id($seqid);
}
return $loc;
}
1; } |
sub from_string
{ my ($self,$locstr,$is_rec) = @_;
my $loc;
$locstr =~ s/\s+//g if ! $is_rec;
if($locstr =~ /^([A-Za-z]+)\((.*)\)$/) {
my $op = $1;
my $oparg = $2;
if($op eq "complement") {
$loc = $self->from_string($oparg, 1);
$loc->strand(-1);
} elsif(($op eq "join") || ($op eq "order") || ($op eq "bond")) {
$loc = Bio::Location::Split->new(-verbose => $self->verbose,
-splittype => $op);
foreach my $substr (split(/,/, $oparg)) {
$loc->add_sub_Location($self->from_string($substr, 1));
}
} else {
$self->throw("operator\" $op\" unrecognized by parser");
}
} else {
$loc = $self->_parse_location($locstr);
}
return $loc; } |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
email or the web:
bioperl-bugs@bioperl.org
http://bugzilla.bioperl.org/
Email hlapp at gmx.net
Additional contributors names and emails here
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Title : new
Usage : my $obj = new Bio::Factory::FTLocationFactory();
Function: Builds a new Bio::Factory::FTLocationFactory object
Returns : an instance of Bio::Factory::FTLocationFactory
Args :