Skip to main content

The fasta python package enables you to deal with biological sequence files easily.

Project description

PyPI version

fasta version 2.0.8

This python package enables you to deal with biological sequence files easily.

The FASTA file format is a standard for storing several short or long DNA sequences inside a text file, use this package to manipulate and transform these files quickly and with short instructions.

Prerequisites

Since fasta is written in python, it is compatible with all operating systems: Linux, macOS and Windows. The only prerequisite is python3 (which is often installed by default) along with the pip3 package manager.

To check if you have python3 installed, type the following on your terminal:

$ python3 -V

If you do not have python3 installed, please refer to the section obtaining python3.

To check you have pip3 installed, type the following on your terminal:

$ pip3 -V

If you do not have pip3 installed, please refer to the section obtaining pip3.

Installing

To install the fasta package, simply type the following commands on your terminal:

$ pip3 install --user fasta

Alternatively, if you want to install it for all users of the system:

$ sudo pip3 install fasta

Usage

Bellow are some examples to illustrate the various ways there are to use this package.

Let's say you have a FASTQ file somewhere inside your home directory and you want to analyze it. To validate it, you can start by doing the following:

>>> from fasta import FASTQ
>>> fastq = FASTQ("~/repos/fasta/test/data/seqs.fastq")
>>> print(fastq.validator())
True

To check the number of reads inside the file, do the following:

>>> from fasta import FASTQ
>>> fastq = FASTQ("~/repos/fasta/test/data/seqs.fastq")
>>> print(len(fastq))
1401

Then, to run the FastQC software on that file automatically, do the following:

>>> from fasta import FASTQ
>>> fastq = FASTQ("~/repos/fasta/test/data/seqs.fastq")
>>> print(fastq.fastqc())
~/repos/fasta/test/data/seqs.fastqc/

Subsampling sequences

Next, to randomly pick a hundred sequences from the FASTQ file and put them in a new FASTQ file, use these commands:

from fasta import FASTQ
#TODO this example is not completed yet

Working with forward and reverse reads

The fasta package also offers convenient ways of dealing with paired sequence files, where one has two FASTQ files with the same number of sequences in each file. Here is an example:

from fasta import FASTQ
#TODO this example is not completed yet

Splitting FASTA files into sub-files

The fasta package also offers convenient ways of dealing with large number of sequences by automatically splitting them into an arbitrary number of smaller FASTA files. This is useful for the parallelization of certain operations. Here is an example:

from fasta import FASTQ
#TODO this example is not completed yet

Parsing FASTA files with primers

The fasta package also offers functionality to parse reads from a FASTA file while automatically detecting the position of any forward and reverse primers, as well as the lack thereof. This is useful for filtering sequences and controlling quality. Here is an example:

from fasta import FASTQ
#TODO this example is not completed yet

Producing visualizations

The fasta package is capable of producing certain types of graphs, such as a histogram of the sequence length distribution within a FASTA file:

from fasta import FASTQ
#TODO this example is not completed yet

Others

The fasta package offers many other functions which have not been documented here yet. They can be discovered by looking at the source code or exploring the extra documentation below.

Extra documentation

More documentation is available at:

http://xapple.github.io/fasta/fasta

This documentation is simply generated from the source code with:

$ pdoc --html --output-dir docs --force fasta

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

fasta-2.0.8.tar.gz (19.3 kB view details)

Uploaded Source

File details

Details for the file fasta-2.0.8.tar.gz.

File metadata

  • Download URL: fasta-2.0.8.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for fasta-2.0.8.tar.gz
Algorithm Hash digest
SHA256 c2256bb92eb2f5487273b1fb7f4f7177a7b90c1d5d81941657af287ff8c1165a
MD5 ca0b17703aab85af27691e619692f845
BLAKE2b-256 83dcbc0bd854eee54c9d08d541b7d0fc8ef6c20d5d1885334de2cbf9a01a06cb

See more details on using hashes here.

Supported by

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