root/lib/FastaChunk.pm

Revision 89, 2.5 kB (checked in by cholt, 1 year ago)

error

Line 
1 #----------------------------------------------------------------------------
2 #----                            FastaChunk                              ----
3 #----------------------------------------------------------------------------
4 package FastaChunk;
5 use strict;
6 use vars qw(@ISA @EXPORT $VERSION);
7 use Exporter;
8 use PostData;
9 use FileHandle;
10 use Fasta;
11 use FastaFile;
12
13 @ISA = qw(
14        );
15
16 #------------------------------------------------------------------------------
17 #--------------------------------- METHODS ------------------------------------
18 #------------------------------------------------------------------------------
19 sub new {
20         my $class = shift;
21
22         my $self = {};
23         bless $self;
24
25         return $self;
26 }
27 #-------------------------------------------------------------------------------
28 sub write_file {
29         my $self      = shift;
30         my $file_name = shift;
31
32
33         $self->fasta_file_location($file_name);
34
35         FastaFile::writeFile($self->fasta, $file_name);
36 }
37 #-------------------------------------------------------------------------------
38 sub erase_fasta_file {
39         my $self     = shift;
40         my $location = shift;
41
42         if    (defined($location)){
43                 unlink($location);
44         }
45         elsif (defined($self->fasta_file_location)){
46                 unlink($self->fasta_file_location);
47         }
48         else {
49                 print STDERR "cant find a file to erase!\n";
50         }
51 }
52 #-------------------------------------------------------------------------------
53 sub fasta {
54         my $self = shift;
55
56         my $def = $self->def();
57         my $seq = $self->seq();
58
59         return Fasta::toFasta($def, \$seq);
60 }
61 #-------------------------------------------------------------------------------
62 #---------------------------  CLASS FUNCTIONS ----------------------------------
63 #-------------------------------------------------------------------------------
64
65 #-------------------------------------------------------------------------------
66 #------------------------------ FUNCTIONS --------------------------------------
67 #-------------------------------------------------------------------------------
68 sub AUTOLOAD {
69         my ($self, $arg) = @_;
70
71         my $caller = caller();
72         use vars qw($AUTOLOAD);
73         my ($call) = $AUTOLOAD =~/.*\:\:(\w+)$/;
74         $call =~/DESTROY/ && return;
75
76         #print STDERR "FastaChunk::AutoLoader called for: ",
77         #      "\$self->$call","()\n";
78         #print STDERR "call to AutoLoader issued from: ", $caller, "\n";
79
80         if (defined($arg)){
81                 $self->{$call} = $arg;
82         }
83         else {
84                 return $self->{$call};
85         }
86 }
87 #------------------------------------------------------------------------
88 1;
89
90
Note: See TracBrowser for help on using the browser.