| 1 | package Bio::ToolBox; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use Carp qw(cluck); | ||
| 6 | use Bio::ToolBox::Data; | ||
| 7 | |||
| 8 | our $VERSION = '2.041'; | ||
| 9 | |||
| 10 | sub load_file { | ||
| 11 | my $self = shift; | ||
| 12 | if ( scalar(@_) == 1 ) { | ||
| 13 | return Bio::ToolBox::Data->new( file => $_[0], ); | ||
| 14 | } | ||
| 15 | else { | ||
| 16 | return Bio::ToolBox::Data->new(@_); | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | sub parse_file { | ||
| 21 | my $self = shift; | ||
| 22 | if ( scalar(@_) == 1 ) { | ||
| 23 | return Bio::ToolBox::Data->new( | ||
| 24 | file => $_[0], | ||
| 25 | parse => 1, | ||
| 26 | simplify => 1, | ||
| 27 | subfeature => 'exon,cds,utr', | ||
| 28 | ); | ||
| 29 | } | ||
| 30 | else { | ||
| 31 | my %args = @_; | ||
| 32 | $args{parse} ||= 1; # make sure this is present | ||
| 33 | return Bio::ToolBox::Data->new(%args); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | sub new_data { | ||
| 38 | my $self = shift; | ||
| 39 | |||
| 40 | # check for possible option keys to the new() function | ||
| 41 | if ( scalar(@_) and scalar(@_) % 2 == 0 ) { | ||
| 42 | my $check = 0; | ||
| 43 | for ( my $i = 0; $i < scalar(@_); $i += 2 ) { | ||
| 44 | if ( $_[$i] =~ | ||
| 45 | /^( columns | datasets | file | in | parse | [sS]tream | db | feature s? | bed | gff | ucsc | noheader )$/nx | ||
| 46 | ) | ||
| 47 | { | ||
| 48 | $check++; | ||
| 49 | } | ||
| 50 | else { | ||
| 51 | $check--; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | if ( $check > 0 ) { | ||
| 55 | |||
| 56 | # looks like an argument list for new() function | ||
| 57 | return Bio::ToolBox::Data->new(@_); | ||
| 58 | } | ||
| 59 | else { | ||
| 60 | # put provided list into an array | ||
| 61 | return Bio::ToolBox::Data->new( columns => [@_] ); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | else { | ||
| 65 | # put provided list into an array | ||
| 66 | return Bio::ToolBox::Data->new( columns => [@_] ); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | sub read_file { | ||
| 71 | my $self = shift; | ||
| 72 | return Bio::ToolBox::Data->open_to_read_fh(@_); | ||
| 73 | } | ||
| 74 | |||
| 75 | sub write_file { | ||
| 76 | my $self = shift; | ||
| 77 | return Bio::ToolBox::Data->open_to_write_fh(@_); | ||
| 78 | } | ||
| 79 | |||
| 80 | sub open_database { | ||
| 81 | my $self = shift; | ||
| 82 | return Bio::ToolBox::Data->open_new_database(@_); | ||
| 83 | } | ||
| 84 | |||
| 85 | sub new_bed { | ||
| 86 | my $self = shift; | ||
| 87 | my $number = shift || 6; | ||
| 88 | return Bio::ToolBox::Data->new( bed => $number ); | ||
| 89 | } | ||
| 90 | |||
| 91 | 1; | ||
| 92 | |||
| 93 | __END__ |