Sha256: 5ba3b349ec8d8b3c3d11253f2f0d6087410de0b6a545be35b6c20f3733085ff9

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

# ParseFasta #

[![Gem Version](https://badge.fury.io/rb/parse_fasta.svg)](http://badge.fury.io/rb/parse_fasta) [![Build Status](https://travis-ci.org/mooreryan/parse_fasta.svg?branch=master)](https://travis-ci.org/mooreryan/parse_fasta) [![Coverage Status](https://coveralls.io/repos/mooreryan/parse_fasta/badge.svg)](https://coveralls.io/r/mooreryan/parse_fasta)

So you want to parse a fasta file...

## Installation ##

Add this line to your application's Gemfile:

```ruby
gem 'parse_fasta'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install parse_fasta

## Overview ##

Provides nice, programmatic access to fasta and fastq files. It's faster and more lightweight than BioRuby. And more fun!

## Documentation ##

Checkout
[parse_fasta docs](http://rubydoc.info/gems/parse_fasta)
for the full api documentation.

## Usage ##

Here are some examples of using ParseFasta. Don't forget to `require "parse_fasta"` at the top of your program!

Print header and length of each record.

```ruby
ParseFasta::SeqFile.open(ARGV[0]).each_record do |rec|
  puts [rec.header, rec.seq.length].join "\t"
end
```

You can parse fastQ files in exatcly the same way.

```ruby
ParseFasta::SeqFile.open(ARGV[0]).each_record do |rec|
  printf "Header: %s, Sequence: %s, Description: %s, Quality: %s\n",
	     rec.header,
	     rec.seq,
	     rec.desc,
	     rec.qual
end
```

The `Record#desc` and `Record#qual` will be `nil` if the file you are parsing is a fastA file.

```ruby
ParseFasta::SeqFile.open(ARGV[0]).each_record do |rec|
  if rec.qual
    puts "@#{rec.header}"
    puts rec.seq
    puts "+#{rec.desc}"
    puts rec.qual
  else
    puts ">#{rec.header}"
    puts rec.sequence
  end  
end
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parse_fasta-2.0.1 README.md
parse_fasta-2.0.0 README.md