Bio::Chaos::Parser::fasta - fasta sequence input/output stream


Bio-Chaos documentation Contained in the Bio-Chaos distribution.

Index


Code Index:

NAME

Top

Bio::Chaos::Parser::fasta - fasta sequence input/output stream

SYNOPSIS

Top

Do not use this module directly. Use it via the Bio::Chaos::Parser class.

DESCRIPTION

Top

generates events with this schema:

  (fastaseqset
   (fastaseq*
    (header "str")
    (residues "str")
    (seqlen "int")))

FEEDBACK

Top

AUTHORS - Chris Mungall

Top

Email: cjm AT fruitfly DOT org

APPENDIX

Top

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


Bio-Chaos documentation Contained in the Bio-Chaos distribution.

# $Id: fasta.pm,v 1.4 2004/03/08 21:45:49 cjm Exp $
# BioPerl module for Bio::Chaos::Parser::fasta
#
# cjm
#
# POD documentation - main docs before the code

# Let the code begin...

package Bio::Chaos::Parser::fasta;
use vars qw(@ISA);
use strict;
# Object preamble - inherits from Bio::Root::Object

#use Bio::Chaos::Parser;

use base qw(Bio::Chaos::Parser::base_parser);

sub _initialize {
    my($self,@args) = @_;
    $self->SUPER::_initialize(@args);  
}

sub record_tag {'fastaseqset'}

sub next_record {
    my $self = shift;

    my $hdr = $self->_readline;
    return unless $hdr;

    $hdr =~ s/^\>//;

    $self->start_event('fastaseq');
    $self->event(header => $hdr);
    my ($id, $desc);
    if ($hdr =~ /(\S+)\s+(.*)/) {
	($id, $desc) = ($1, $2);
	$self->event(id => $id);
	$self->event(desc => $desc);
	my ($F1, $v1, $F2, $v2full, $v2) = split(/\|/, $id);
	if (defined $v1) {
	    $self->event($F1 => $v1);
	    if (defined $v2full) {
		$self->event($F2->$v2full);
	    }
	    if (defined $v2) {
		$self->event(symbol => $v2);
	    }
	}
    }

    my $seq = "";
    while ($_ = $self->_readline) {
        chomp;
        if (/^\>/) {
            $self->_pushback($_);
            last;
        }
        $seq .= $_;
    }
    $self->event(residues => $seq);
    $self->event(seqlen => length($seq));
    $self->end_event('fastaseq');

    return 1;
}

1;