Skip to main content

Read and write FASTA format.

Project description

oldowan.fasta is a small bioinformatic utility to read and write sequence data in the FASTA format. FASTA is the most commonly used simple file format for storing multiple DNA, RNA, or protein sequences in a single file. It is a text-based, human-readable format.

Installation Instructions

This package is pure Python and has no dependencies outside of the standard library. The easist way to install is using easy_install from the setuptools package. This usually goes something like this:

$ easy_install oldowan.fasta

or on a unix-like system, assuming you are installing to the main Python site-packages directory as a non-privileged user, this:

$ sudo easy_install oldowan.fasta

You may also use the standard python distutils setup method. Download the current source archive from the file list towards the bottom of this page, unarchive it, and install. On Mac OS X and many other unix-like systems, having downloaded the archive and changed to the directory containing this archive in your shell, this might go something like:

$ tar xvzf oldowan.fasta*
$ cd oldowan.fasta*
$ python setup.py install

Quick Start

oldowan.fasta has an interface based on the standard Python file. Import oldowan.fasta:

>>> from oldowan.fasta import fasta

Read a FASTA format file:

>>> for entry in fasta('sequences.fasta', 'r'):
...     print entry['name'], len(entry['sequence'])

A more cumbersome, but equivalent way of doing the above:

>>> fasta_file = fasta('sequences.fasta', 'r')
>>> for entry in fasta_file:
...     print entry['name'], len(entry['sequence'])
>>> fasta_file.close()

Even more cumbersome, and if the FASTA file is large, potentially memory-draining version (the previous two methods only read one entry at a time from the file, this reads the whole file into memory at once):

>>> fasta_file = fasta('sequence.fasta', 'r')
>>> entries = fasta_file.readentries()
>>> fasta_file.close()
>>> for entry in entries:
...     print entry['name'], len(entry['sequence'])

Read a string of FASTA format sequences:

>>> fasta_string = open('sequences.fasta', 'r').read()
>>> for entry in fasta(fasta_string, 's'):
...     print entry['name'], len(entry['sequence'])

Read a file object:

>>> fasta_file = open('sequences.fasta', 'r')
>>> for entry in fasta(fasta_file, 'f'):
...     print entry['name'], len(entry['sequence'])

Write to a file:

>>> fasta_file = open('sequences.fasta', 'w')
>>> fasta_file.write({'name':'Sequence1', 'sequence':'AGCTAGCT'})
>>> fasta_file.close()

Release History

1.0.0 (August 16, 2008)

initial release of module.

1.0.1 (March 25, 2009)

bug fix updates

1.0.2 (March 26, 2009)

update VERSION info

1.0.4 (August 4, 2015)

actually fix version loading problem this time

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oldowan.fasta-1.0.4.tar.gz (5.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page