Skip to main content

Sanity check your FASTA DB before release.

Project description

Sanity check a FASTA DB

FASTA DB are easy to corrupt, and we are in need of a simple tool to double check the DB has no unforeseen entries.

This tool will check for:

  1. Duplicate entries with the same ID
  2. Entries with different IDs but with overlapping sequences (i.e., 100% overlap, or one sequence completely included in another)
  3. Optionally, it will try to parse the meaningful category or label off the FASTA header (e.g., ST allele number) and ensure that distinct labels are given to completely or partially overlapping sequences.

The tool outputs:

  1. A log to stderr signalling any potential issues.
  2. A report in Markdown straight to stdout. You can then add it to your GitHub, or post it as a GitHub Issue, or push it through pandoc to transform it in to any supported format you like (e.g., PDF for your paper).
  3. Optionally, the output files produced by CD-HIT

What does completely and/or partially overlapping sequences mean?

Under the hood, db-check is running CD-HIT (in particular, cd-hit-est). Here, db-check runs cd-hit-est to identify any sequences that have 100% identity and 100% coverage (i.e., have all the same bases and are exactly the same length, and thus are identical) OR where one sequence is 100% identical to another, but it is shorter (i.e., one sequence is exactly containted within another). The first case is what we call completely overlapping and the second case is what we call partially overlapping.

Obviously, neither case is ideal. The case of completely overlapping means your DB has redundant sequences that should be removed. It can be especially problematic if you have two identical sequences but they are identified as distinct categories.

The case of partially overlapping sequences is less clear cut whether it is an issue or not. We have seen cases where novel MLST alleles were added to a scheme as exact subsets of already established alleles. In those case, it turned out the new alleles were caused by a break in the assembly, and thus were NOT novel alleles at all. However, there are cases where partially overlapping sequences might be biologically real (e.g. indicating a real deletion or insertion), and you do wish to keep that in your DB. If that is the case, additional logic will have to be applied to your BLAST filtering steps to make sure you get the right variant.

Whatever your case, hopefully, this tool will help you get a quick assessment of your FASTA DB, and be aware of any internal issues before releasing it in to the wild. Or, if you are a user of a FASTA DB, and you are getting funny results, hopefully this tool can help you troubleshoot the DB and pass on the developer any issues they may have with their FASTA DB.

Dependencies

  • CD-HIT
  • Python >=3.6

Optionally, pandoc.

Installation

Conda

conda -c bioconda cd-hit
pip3 install db-check

Brew

brew install cd-hit
pip3 install db-check

NOTE: I found that brew install on my MacOSX Mojave machine failed because the bottled version was compiled with a different set of headers. I fixed it by forcing it to install from source like so:

brew uninstall cd-hit
brew install -s cd-hit

Running

db-check <db.fasta> > report.md

Running an example

db-check --example

Parsing categories from sequence ID

Using --delimiter and --field:

In some cases your category is encoded in the sequence ID with a particular delimiter (e.g., | or ~~), and once the ID is split along this delimiter, the field of interest might be the second (--field 1 --- 1 because it is 0-indexed) or, perhaps, the last one (--field -1).

For example, let us say you have IDs coded with the following pattern: >seq1~~catA. In this case, you would do the following:

db-check --delimiter "~~" --field -1 /path/to/db

Using --regex:

In some cases your category might be encoded in a more convoluted manner, and perhaps a regex expression with a capture group would work best. The above case could thus be equally parsed with:

db-check --regex ".*~~(.*)" /path/to/db

Using a callback function

Implementation pending

Command-line options

Usage: db-check [OPTIONS] FASTA

  Check a FASTA DB for potential issues.

Options:
  -d, --delimiter TEXT   When parsing a category from seqid, split on this
                         delimiter (use -1 for last element, -2 for second to
                         last, etc.).
  -f, --field INTEGER    When parsing a category from seqid using a delimiter,
                         keep this field number (0-index).
  -r, --regex TEXT       When parsing a category from seqid extract using this
                         regex.
  -a, --author TEXT      Who is running the check. (default: $USER)
  -n, --db_name TEXT     Name of the Database. (default: filename)
  -t, --threads INTEGER  How many threads to give CD-HIT (default: 1)
  -p, --prefix TEXT      Prefix of output files from CD-HIT (default: cdhit)
  -k, --keep_files       Whether to keep CD-HIT output files (default: False)
  --example              Run an example set
  --version              Show the version and exit.
  -h, --help             Show this message and exit.

Examples using pandoc to convert the output to other formats

Convert to HTML

db-check --example | pandoc --from markdown --to html5 > report.html

Convert to PDF

db-check --example | pandoc --from markdown --to latex -o report.pdf

Conver to plain text

db-check --example | pandoc --from markdown --to plain > report.txt

TODO

  • add conda recipe
  • add brew recipe
  • add travisCI recipe

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

db_check-0.1.5.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

db_check-0.1.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file db_check-0.1.5.tar.gz.

File metadata

  • Download URL: db_check-0.1.5.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.1

File hashes

Hashes for db_check-0.1.5.tar.gz
Algorithm Hash digest
SHA256 6aafb368eebc2a4fdc3c31338ad55028017d7fe8e723f12fe6997ee9efcf6d87
MD5 6251d70d17fdb8e50b1817bf83c3d345
BLAKE2b-256 b1c878eae2915abe0031564a3cebfb3aea811eb7ad45cb0e68ac990ee724fb61

See more details on using hashes here.

File details

Details for the file db_check-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: db_check-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.1

File hashes

Hashes for db_check-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 834c9489e5fa8dfb7a18aa1d1de29f59ef3267069fc2614476a7589e1bba3113
MD5 9ad241f9aff786b0ff8797d8ba192264
BLAKE2b-256 634a1dea6b198920efb8f509f2211ec656e0ee0d663378aa2daf1586ca7d08b8

See more details on using hashes here.

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