Skip to main content

Convert GenBank format files to a swath of other formats

Project description

genbank_to

Edwards Lab DOI License: MIT GitHub language count PyPi

A straightforward application to convert NCBI GenBank format files to a swath of other formats. Hopefully we have the format you need, but if not either post an issue using our template, or if you have already got it working, post a PR so we can add it and add you to the project.

You might also be interested deprekate's package called genbank which includes several of the features here, and you can import genbank into your Python projects.

What it does

Read an NCBI GenBank format file (like our test data) and convert it to one of many different formats.

Input formats

At the moment we only support NCBI GenBank format. If you want us to read other common formats, let us know and we'll add them.

Output formats

Here are the output formats you can request. You can request as many of these at once as you like!

These outputs are assuming you provide a (for example) genome file that contains ORFs, Proteins, and Genomes.

Nucleotide output

  • -n or --nucleotide outputs the whole DNA sequence (e.g. the genome)
  • -o or --orfs outputs the DNA sequence of the open reading frames

Protein output

  • -a or --aminoacids outputs the protein sequence for each of the open reading frames

Complex formats

  • -p or --ptt NCBI ptt protein table. This is a somewhat deprecated NCBI format from their genomes downloads
  • -f or --functions outputs tab separated data of protein ID and protein function (also called the product)
  • --gff3 outputs GFF3 format
  • --amr outputs a GFF file, an amino acid fasta file, and a nucleotide fasta file as required by AMR Finder Plus. Note that this format checks for validity that often crashes AMRFinderPlus
  • --phage_finder outputs a unique format required by phage_finder

Output options

  • --pseudo normally we skip pseudogenes (e.g. in creating amino acid fasta files). This will try and include pseudogenes, but often biopython complains and ignores them!
  • -i or --seqid only output this sequence, or these sequences if you specify more than one -i/--seqid
  • -z or --zip compress some of the outputs
  • --log write logs to a different file

Separate multi-GenBank files

If your GenBank files contains multiple sequence records (separated with //), you can provide the --separate flag. This will write each entry into its own file. This is compatible with -n/--nucleotide, -o/--orfs, and -a/--aminoacids. However, if you provide the --separate flag on its own, it will write each entry in your multi-GenBank file to its own GenBank file.

Examples

All of these examples use our test data

  1. Extract a fasta of the genome:
genbank_to -g test/NC_001417.gbk -n test/NC_001417.fna
  1. Extract the DNA sequences of the ORFs to a single file
genbank_to -g test/NC_001417.gbk -o test/NC_001417.orfs
  1. Extract the protein (amino acid) sequences of the ORFs to a file
genbank_to -g test/NC_001417.gbk -a test/NC_001417.faa
  1. Do all of these at once
genbank_to -g test/NC_001417.gbk -n test/NC_001417.fna -o test/NC_001417.orfs -a test/NC_001417.faa

Installation

You can install genbank_to in three different ways:

  1. Using conda

This is the easiest and recommended method.

mamba create -n genbank_to genbank_to
conda activate genbank_to
genbank_to --help
  1. Using pip

I recommend putting this into a virtual environment:

virtualenv venv
source venv/bin/activate
pip install genbank_to
genbank_to --help
  1. Directly from this repository

(Not really recommended as things might break)

git clone https://github.com/linsalrob/genbank_to.git
cd genbank_to
virtualenv venv
source venv/bin/activate
python setup.py install
genbank_to --help

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

genbank_to-0.42.tar.gz (16.0 kB view details)

Uploaded Source

File details

Details for the file genbank_to-0.42.tar.gz.

File metadata

  • Download URL: genbank_to-0.42.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for genbank_to-0.42.tar.gz
Algorithm Hash digest
SHA256 b59cb5a0f3e62abc9b3d5e2487e7204f939853e1cf95159755e695670684ae52
MD5 ccd8dcad93b140536788e36ba5159eb9
BLAKE2b-256 a924b6c8c7da768042a06799b592c731149a3b42ebde3e8ea156142a6dfa5929

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