Bio-MAGETAB
view release on metacpan or search on metacpan
lib/Bio/MAGETAB/Util/Reader/SDRF.pm view on Meta::CPAN
return unless ( $material && $char );
my @preexisting;
if ( blessed($char) eq 'Bio::MAGETAB::ControlledTerm' ) {
@preexisting = $material->get_characteristics();
}
elsif ( blessed($char) eq 'Bio::MAGETAB::Measurement' ) {
@preexisting = $material->get_measurements();
}
else {
croak("Cannot process argument: $char (" . blessed($char) .")");
}
my $new_category = $self->_get_characteristic_type( $char );
my $new_value = $char->get_value();
my $new_class = blessed $char;
my $found = first {
$self->_get_characteristic_type( $_ ) eq $new_category
&& $_->get_value() eq $new_value
&& blessed $_ eq $new_class
} @preexisting;
unless ( $found ) {
push @preexisting, $char;
if ( blessed($char) eq 'Bio::MAGETAB::ControlledTerm' ) {
$material->set_characteristics( \@preexisting );
}
else { # Must therefore be Bio::MAGETAB::Measurement
$material->set_measurements( \@preexisting );
}
$self->get_builder()->update( $material );
}
return;
}
# Make the classes immutable. In theory this speeds up object
# instantiation for a small compilation time cost.
__PACKAGE__->meta->make_immutable();
no Moose;
=head1 NAME
Bio::MAGETAB::Util::Reader::SDRF - SDRF parser class.
=head1 SYNOPSIS
use Bio::MAGETAB::Util::Reader::SDRF;
my $parser = Bio::MAGETAB::Util::Reader::SDRF->new({
uri => $sdrf_filename,
});
my $sdrf = $parser->parse();
=head1 DESCRIPTION
This class is used to parse SDRF files. It can be used on its own, but
more often you will want to use the main Bio::MAGETAB::Util::Reader
class which handles extended parsing options more transparently.
=head1 ATTRIBUTES
See the L<TabFile|Bio::MAGETAB::Util::Reader::TabFile> class for superclass attributes.
=over 2
=item magetab_object
A Bio::MAGETAB::SDRF object. This can either be set upon
instantiation, or a new object will be created for you. It can be
retrieved at any time using C<get_magetab_object>.
=back
=head1 METHODS
=over 2
=item parse
Parse the SDRF pointed to by C<$self-E<gt>get_uri()>. Returns the
Bio::MAGETAB::SDRF object updated with the SDRF contents.
=back
=head1 SEE ALSO
L<Bio::MAGETAB::Util::Reader::Tabfile>
L<Bio::MAGETAB::Util::Reader>
L<Bio::MAGETAB::SDRF>
=head1 AUTHOR
Tim F. Rayner <tfrayner@gmail.com>
=head1 LICENSE
This library is released under version 2 of the GNU General Public
License (GPL).
=cut
1;
# Below is the Parse::RecDescent grammar used to parse the SDRF header
# line and generate the row-level parser.
__DATA__
header: section_list
| { # Display errors using our own report format.
# Adapted from P::RD demo/demo_errors.pl
for ( @{ $thisparser->{errors} } ) {
my $t = $_->[0];
$t =~ s/\x0/ | /g;
print $::ERROR_FH "$t\n";
}
return;
}
( run in 0.510 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )