Code Monkey home page Code Monkey logo

bioutil's Introduction

FastaReader

FastaReader - class for reading a fasta-like formatted file

The assumption is that the file contains a set of multi-line records separated by single-line headers starting with a specific separator (by default '>')

Example

#!/usr/bin/perl
use FastaReader;

my $file = shift;
open(IN,$file) || die "Cannot open $ARGV[0]: $!\n";

my $parser = new FastaReader(\*IN);
while (my $seqobj = $parser->next_seq()) {
    printf ("%s\n", $seqobj->seq);
    printf ("%s\n", $seqobj->name);
    printf ("%s\n", $seqobj->length); 
}

DESCRIPTION

This module iterates through a fasta-like file retrieving the records in (header, data) pairs. When creating a new parser, the user may specify both the prefix (as a string) that indicates a header (record separator) line (default is '>'), and a line separator that is used when concatenating the lines in the input forming the body of each record. This separator is useful, for example, when parsing a .qual file where the quality values are separated by spaces.

METHOD

  • $parser = new FastaReader($file, $head, $sep)

    Creates a new parser object reading from file $file and using a specific header separator ($header - default '>') and a line separator ($sep - default '')

  • $seq = $parser->next_seq()

    Reads a record into an object of obj. If no more records remain returns undef.

  • $name = $seq->name()

    Return name of current record

  • $length = $seq->length()

    Return length of current record

  • $posn = $seq->tell()

    Return offset of current record

  • $parser->seek(posn)

    Resets the parser to a specific location (posn) in the file stream.

AUTHOR

Wenchao Lin <linwenchao(at)yeah.net>

bioutil's People

Contributors

wenchaolin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.