G::IO FastaI
Included librariesPackage variablesGeneral documentationMethods
Package variables
Privates (from "my" definitions)
%FH;
Included modules
Carp
G::Messenger
IO::File
IO::Zlib
Inherit
G::IO::GenBankO G::IO::Handler
Synopsis
No synopsis!
Description
No description!
Methods
DESTROY
No description
Code
getnucs
No description
Code
new
No description
Code
next_locus
No description
Code
open_gb
No description
Code
read_locus
No description
Code
Methods description
None available.
Methods code
DESTROYdescriptionprevnextTop
sub DESTROY {
    if(exists $_[0]->{INSTANCE} && $FH{$_[0]->{INSTANCE}}){
	close ($FH{$_[0]->{INSTANCE}});
	delete($FH{$_[0]->{INSTANCE}});
    }
}
getnucsdescriptionprevnextTop
sub getnucs {
    my $this = shift;

    my $fh = $FH{$this->{INSTANCE}};

    while(<$fh>){
	$this->{PREVLINE} = $_;
	last if (/^\s*\n$/ || /^>/);
	s/[^A-Za-z]//g;
	$this->{SEQ} .= lc($_);
    }
}
newdescriptionprevnextTop
sub new {
    my $pkg = shift;
    my $this = {};
    bless $this;

    return $this;
}
next_locusdescriptionprevnextTop
sub next_locus {
    my $this = shift;
    my $msg  = shift;
    my $file = $this->{FILENAME};
    my $prev = $this->{PREVLINE};
    my $inst = $this->{INSTANCE};

    undef %$this;

    $this->{FILENAME} = $file;
    $this->{PREVLINE} = $prev;
    $this->{INSTANCE} = $inst;

    $this->read_locus();
    $this->getnucs();

    if (defined($this->{SEQ})){
        $this->seq_info() unless($msg);
        return 1;
    }elsif(defined($this->{LOCUS}->{id})){
	carp('No sequence found for ' . $this->{LOCUS}->{id});
	return -1;
    }else{	
        return 0;
    }
}
open_gbdescriptionprevnextTop
sub open_gb {
    my $this = shift;
    my $filename = shift;
    $this->{PREVLINE} = '';
    $this->{FILENAME} = $filename;
    $this->{INSTANCE} = $filename . '-' . time() . '-' . rand();

    if($filename =~ /\.gz$/){
	$FH{$this->{INSTANCE}} = new IO::Zlib;
	$FH{$this->{INSTANCE}}->open($filename, 'rb') or croak("Error at G::IO::FastaI: $!\n");;
    }else{
	$FH{$this->{INSTANCE}} = new IO::File;
	open($FH{$this->{INSTANCE}}, $filename) or croak("Error at G::IO::FastaI: $!\n");
    }
    return $FH{$this->{INSTANCE}};
}
read_locusdescriptionprevnextTop
sub read_locus {
    my $this = shift;

    if($this->{PREVLINE} =~ /^>(.*)$/){
	$this->{LOCUS}->{id} = $1;
	return;
    }

    my $fh = $FH{$this->{INSTANCE}};

    while(<$fh>){
	chomp;
	if (/^>(.*)$/){
	    $this->{LOCUS}->{id} = $1;
	    last;
	}
    }
}
General documentation
No general documentation available.