Permalink
Browse files

initial work on unifying contained locations with layered features/lo…

…cations/etc, but breaks some tests
  • Loading branch information...
1 parent e120919 commit f714a9e56ccbf6ef2ce45d78ed74cd906cf9daad Chris Fields committed Feb 14, 2011
@@ -5,6 +5,9 @@ use namespace::clean -except => 'meta';
requires qw(start end strand from_string to_string);
+# This should not be set here, and should be Biome::Role::Identifiable to make
+# the primary ID less Seq-specific
+
has 'seq_id' => (
is => 'rw',
isa => 'Str'
@@ -260,11 +263,8 @@ __END__
=head1 NAME
-Biome::Role::Range - Base role for simple ranges or segments
-
-=head1 VERSION
-
-This documentation refers to Biome::Role::Range version 0.001.
+Biome::Role::Location::Locatable - Base role that defines methods for comparing
+ranges with start/end coordinates
=head1 SYNOPSIS
@@ -277,8 +277,10 @@ This documentation refers to Biome::Role::Range version 0.001.
=head1 DESCRIPTION
-This Role describes simple attributes and actions for a Range. In
-biological terms, a Range is a
+This role is set up to perform simple tests between two or more objects that
+have a designated start, end, and strand. This is not combined with any
+specific range-like implementation in order to decouple these methods from
+any assumptions made by the underlying range-like implementation.
=head1 ATTRIBUTES
@@ -9,10 +9,9 @@ use MooseX::Role::Parameterized;
parameter class => (
isa => 'Str',
- required => 1
);
-parameter abbrev => (
+parameter short_name => (
isa => 'Str',
required => 1
);
@@ -22,7 +21,7 @@ parameter abbrev => (
parameter plural => (
isa => 'Str',
lazy => 1,
- default => sub { shift->class.'s' }
+ default => sub { shift->short_name.'s' }
);
parameter layered => (
@@ -33,12 +32,13 @@ parameter layered => (
role {
my $p = shift;
- my $singular = $p->class;
- my $plural = $p->plural;
-
+ my ($class, $singular, $plural) = ($p->class, $p->short_name, $p->plural);
+
+ $class ||= 'Biome::Role::Location::Simple'; # any location consumer
+
if ($p->layered) {
- $singular = "sub_$singular";
- $plural = "sub_$plural";
+ $singular = "sub$singular";
+ $plural = "sub$plural";
}
has $singular => (
@@ -58,8 +58,6 @@ role {
requires "add_$singular";
};
-
-
no Biome::Role;
1;
@@ -85,9 +83,23 @@ container.
=head1 DESCRIPTION
-<TODO>
-A full description of the module and its features.
-May include numerous subsections (i.e., =head2, =head3, etc.).
+Simple parameterizable role for anything that has one or more Locations
+(Biome::Role::Location::Simple consumers). This requires the implementation
+provide several things:
+
+=over3
+
+=item *
+
+
+
+=item *
+
+A method to add new Locations; as this is implementation-specific,
+this is required for anything consuming this class. For instance, a consumer
+
+
+=back
=head1 SUBROUTINES/METHODS
@@ -17,6 +17,17 @@ has end => (
default => 0
);
+sub ucsc_start {
+ my ($self, $newstart) = shift;
+ if (defined $newstart) {
+ $self->start($newstart + 1);
+ }
+ my $st = $self->start;
+ $st ? $st - 1 : 0;
+}
+
+sub ucsc_end {shift->end}
+
sub length {$_[0]->end - $_[0]->start + 1;}
sub to_string {
@@ -39,7 +50,7 @@ __END__
=head1 NAME
-Biome::Role::Range - Base role for simple ranges or segments
+Biome::Role::Range - Base role for simple biological ranges or segments.
=head1 VERSION
@@ -56,8 +67,13 @@ This documentation refers to Biome::Role::Range version 0.001.
=head1 DESCRIPTION
-This Role describes simple attributes and actions for a Range. In
-biological terms, a Range is a
+This Role describes simple attributes and actions for a Range. In biological
+terms, a Range is a segment with a start and an end. Ranges may optionally have
+a strand defined; the strand must be 1 (forward, or '+'), -1 (reverse, or '-'),
+or 0 (strand is not set or not defined, the default). The coordinate system is
+the same as for BioPerl, namely coordinates are completely inclusive and start
+at 1 (as opposed to the UCSC system, where coordinates are 0-based, start
+inclusive only).
=head1 ATTRIBUTES
@@ -53,8 +53,6 @@ sub length {
}
}
-sub sub_Locations { }
-
has 'start_pos_type' => (
isa => Location_Pos_Type,
is => 'rw',
@@ -150,10 +148,12 @@ sub is_fuzzy {
exists $IS_FUZZY{$self->end_pos_type}) ? 1 : 0;
}
+# TODO: possibly leave unimplemented?
sub valid_Location {
defined($_[0]->start) && defined($_[0]->end) ? 1 : 0;
}
+# TODO: maybe leave up to the implementing class?
sub to_string {
my ($self) = @_;
@@ -206,6 +206,8 @@ sub to_string {
{
my @STRING_ORDER = qw(start loc_type end);
+# TODO: should be renamed from_FTstring, from_string is too generic...
+
sub from_string {
my ($self, $string) = @_;
return unless $string;
@@ -272,6 +274,174 @@ sub flip_strand {
__END__
+=head1 NAME
+
+Biome::Role::Location::Simple - Role for describing simple biological locations
+and coordinates.
+
+=head1 SYNOPSIS
+
+ with 'Biome::Role::Location::Simple';
+ # Brief but working code example(s) here showing the most common usage(s)
+
+ # This section will be as far as many users bother reading,
+
+ # so make it as educational and exemplary as possible.
+
+=head1 DESCRIPTION
+
+This role describes a biological location or segment, one which has a simple
+start, end, and strand (all attributes).
+
+=head1 SUBROUTINES/METHODS
+
+=head1 DIAGNOSTICS
+
+<TODO>
+A list of every error and warning message that the module can generate
+(even the ones that will "never happen"), with a full explanation of each
+problem, one or more likely causes, and any suggested remedies.
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+<TODO>
+A full explanation of any configuration system(s) used by the module,
+including the names and locations of any configuration files, and the
+meaning of any environment variables or properties that can be set. These
+descriptions must also include details of any configuration language used.
+
+=head1 DEPENDENCIES
+
+<TODO>
+A list of all the other modules that this module relies upon, including any
+restrictions on versions, and an indication of whether these required modules are
+part of the standard Perl distribution, part of the module's distribution,
+or must be installed separately.
+
+=head1 INCOMPATIBILITIES
+
+<TODO>
+A list of any modules that this module cannot be used in conjunction with.
+This may be due to name conflicts in the interface, or competition for
+system or program resources, or due to internal limitations of Perl
+(for example, many modules that use source code filters are mutually
+incompatible).
+
+=head1 BUGS AND LIMITATIONS
+
+There are no known bugs in this module.
+
+User feedback is an integral part of the evolution of this and other Biome and
+BioPerl modules. Send your comments and suggestions preferably to one of the
+BioPerl mailing lists. Your participation is much appreciated.
+
+ bioperl-l@bioperl.org - General discussion
+ http://bioperl.org/wiki/Mailing_lists - About the mailing lists
+
+Patches are always welcome.
+
+=head2 Support
+
+Please direct usage questions or support issues to the mailing list:
+
+L<bioperl-l@bioperl.org>
+
+rather than to the module maintainer directly. Many experienced and reponsive
+experts will be able look at the problem and quickly address it. Please include
+a thorough description of the problem with code and data examples if at all
+possible.
+
+=head2 Reporting Bugs
+
+Preferrably, Biome bug reports should be reported to the GitHub Issues bug
+tracking system:
+
+ http://github.com/cjfields/biome/issues
+
+Bugs can also be reported using the BioPerl bug tracking system, submitted via
+the web:
+
+ http://bugzilla.open-bio.org/
+
+=head1 EXAMPLES
+
+<TODO>
+Many people learn better by example than by explanation, and most learn better
+by a combination of the two. Providing a /demo directory stocked with
+well-commented examples is an excellent idea, but your users might not have
+access to the original distribution, and the demos are unlikely to have been
+installed for them. Adding a few illustrative examples in the documentation
+itself can greatly increase the "learnability" of your code.
+
+=head1 FREQUENTLY ASKED QUESTIONS
+
+<TODO>
+Incorporating a list of correct answers to common questions may seem like extra
+work (especially when it comes to maintaining that list), but in many cases it
+actually saves time. Frequently asked questions are frequently emailed
+questions, and you already have too much email to deal with. If you find
+yourself repeatedly answering the same question by email, in a newsgroup, on a
+web site, or in person, answer that question in your documentation as well. Not
+only is this likely to reduce the number of queries on that topic you
+subsequently receive, it also means that anyone who does ask you directly can
+simply be directed to read the fine manual.
+
+=head1 COMMON USAGE MISTAKES
+
+<TODO>
+This section is really "Frequently Unasked Questions". With just about any kind
+of software, people inevitably misunderstand the same concepts and misuse the
+same components. By drawing attention to these common errors, explaining the
+misconceptions involved, and pointing out the correct alternatives, you can once
+again pre-empt a large amount of unproductive correspondence. Perl itself
+provides documentation of this kind, in the form of the perltrap manpage.
+
+=head1 SEE ALSO
+
+<TODO>
+Often there will be other modules and applications that are possible
+alternatives to using your software. Or other documentation that would be of use
+to the users of your software. Or a journal article or book that explains the
+ideas on which the software is based. Listing those in a "See Also" section
+allows people to understand your software better and to find the best solution
+for their problem themselves, without asking you directly.
+
+By now you have no doubt detected the ulterior motive for providing more
+extensive user manuals and written advice. User documentation is all about not
+having to actually talk to users.
+
+=head1 (DISCLAIMER OF) WARRANTY
+
+<TODO>
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+=head1 ACKNOWLEDGEMENTS
+
+<TODO>
+Acknowledging any help you received in developing and improving your software is
+plain good manners. But expressing your appreciation isn't only courteous; it's
+also enlightened self-interest. Inevitably people will send you bug reports for
+your software. But what you'd much prefer them to send you are bug reports
+accompanied by working bug fixes. Publicly thanking those who have already done
+that in the past is a great way to remind people that patches are always
+welcome.
+
+=head1 AUTHOR
+
+Chris Fields C<< <cjfields at bioperl dot org> >>
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2011 Chris Fields (cjfields at bioperl dot org). All rights reserved.
+
+followed by whatever licence you wish to release it under.
+For Perl code that is often just:
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
=head2 location_type
Title : location_type
Oops, something went wrong.

0 comments on commit f714a9e

Please sign in to comment.