Skip to main content

Sanitise protein FASTA files / data

Project description

tidyfasta

A python program to tidy and sanitise FASTA sequence files.

It can be imported as a package or used directly from the command line.

If run in non-strict mode (default), any sequence that a breaking issue, such as a non-canonical AA, dangerous characters (any non-alphanumeric character with the exception of _ -), or is just an ID without a sequence, will be ignored. If run in strict mode then an exception is raised.

When run from the command line interface the script will write a file to the same directory as the input file with the prefix tidied- followed by the input file name. If there is already an output file, then the prefix will be tidied-UNIXTIME- where UNIXTIME is the time at which the script was called.

If imported, after calling the class ProcessFasta, two member variables are available. ProcessFasta.fasta_array returns a minimally validated array of strings, where split lines are combined, excess whitespace is removed, and missing names are added. ProcessFasta.validated_array returns a validated_array of objects, where each object has two variables id and sequence. The validated array is checked for non-canonical AA in the sequence and banned characters from the ID.

Problems and fixes

Problem Fix (Strict mode)
Sequence without ID ID name added
Multiline sequence One line per sequence
ID without sequence Sequence ignored (Exception raised)
Non canonical AA Sequence ignored (Exception raised)
Dangerous characters in ID Sequence ignored (Exception raised)
Lowercase AA Converts to uppercase AA
Excessive Whitespace Removes excessive whitespace

Install

pip install tidyfasta

Usage

Command line interface

$ tidyfasta --input file.txt

$ tidyfasta --input file.txt --strict --single

$ tidyfasta --input file.txt --version

$ tidyfasta --input file.txt --help

Script

from tidyfasta.common.process import ProcessFasta

input_file = "sample.txt"

np = ProcessFasta(input_file, strict=True, single=False)

fasta_array = np.fasta_array
print(fasta_array)

for i in np.validated_array:
    print(i.id+"\n")
    print(i.sequence+"\n")

np.write_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

tidyfasta-1.0.5.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tidyfasta-1.0.5-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tidyfasta-1.0.5.tar.gz.

File metadata

  • Download URL: tidyfasta-1.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for tidyfasta-1.0.5.tar.gz
Algorithm Hash digest
SHA256 ec30c72c55319698f8365f7e6b47517e92e0ccc1bdeee59ee932df4ca171ecb0
MD5 7c021046b68e1e8351deee6884fd7131
BLAKE2b-256 106ea98718581a7bb2b9a4c74fcde3fb185999851e3642250f90f8f1e3e57dba

See more details on using hashes here.

File details

Details for the file tidyfasta-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: tidyfasta-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for tidyfasta-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 253e56fc311f3c391be4b263c15cc1b3b62788ccf4c54370f1c0f5837896181a
MD5 1077324e36f478b7ac616f9b5845ae0d
BLAKE2b-256 4e26b49a6298c465fa52e5f4d69dcd2db472139570e15aa854c7d02f68775fd2

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