Skip to main content

plasmidpredictor: predict which plasmid should be present from uncorrected long read data

Project description

# PlasmidPredictor
Given some raw uncorrected long reads, such as those from PacBio or Oxford Nanopore, predict which plasmid should be present. Assemblies of long read data can often miss out on plasmids, particularly if they are very small or have a copy number which is too high/low when compared to the chromosome. This software gives you an indication of which plasmids to expect, flagging potential issues with an assembly.

[![Build Status](](

# Paper
Coming soon.

Please remember to cite the plasmidFinder paper as their database makes this software work:

"In Silico Detection and Typing of Plasmids using PlasmidFinder and Plasmid Multilocus Sequence Typing", Carattoli et. al, Antimicrob Agents Chemother. 2014 Jul; 58(7): 3895–3903.

# Installation
The only dependancy is Python3. Assuming you have python 3.3+ and pip installed, just run:
pip3 install git+git://

## Debian/Ubuntu (Trusty/Xenial)
To install Python3 on Ubuntu, as root run:
apt-get update -qq
apt-get install -y git python3 python3-setuptools python3-biopython python3-pip
pip3 install git+git://

## Windows
Like virtually all Bioinformatics software, this software is unlikely to work on Windows. Try using a Linux virtual machine.

# Usage
## plasmidpredictor_database_downloader script
First of all you need plasmid database from PlasmidFinder. There is a snapshot bundled with this repository for your convenience, or alternatively you can use the downloader script to get the latest data. You will need internet access for this step. Please remember to cite the PlasmidFinder paper.

usage: plasmidpredictor_database_downloader [options] output_prefix

Download PlasmidFinder database

positional arguments:
output_prefix Output prefix

optional arguments:
-h, --help show this help message and exit
--verbose, -v Turn on debugging (default: False)
--version show program's version number and exit

Just run:
You will now have a file called 'plasmid_files.fa' which can be used with the main script.

## plasmidpredictor script
This is the main script of the application. The mandatory inputs are a FASTQ file of long reads, which can be optionally gzipped.
usage: plasmidpredictor [options] input.fastq

plasmid incompatibility group prediction from uncorrected long reads

positional arguments:
input_fastq Input FASTQ file (optionally gzipped)

optional arguments:
-h, --help show this help message and exit

Optional input arguments:
--plasmid_data PLASMID_DATA, -d PLASMID_DATA
FASTA file containing plasmid data from downloader
script, defaults to bundled database (default: None)
--kmer KMER, -k KMER k-mer size (default: 13)

Optional output arguments:
Filename to save matching reads to (default: None)
--output_file OUTPUT_FILE, -o OUTPUT_FILE
Output file [STDOUT] (default: None)
Print results every this number of reads (default:
--verbose, -v Turn on debugging [False]
--version show program's version number and exit

Optional advanced input arguments:
--max_gap MAX_GAP Maximum gap for blocks to be contigous, measured in
multiples of the k-mer size (default: 3)
--margin MARGIN Flanking region around a block to use for mapping
(default: 10)
--min_block_size MIN_BLOCK_SIZE
Minimum block size in bases (default: 130)
--min_fasta_hits MIN_FASTA_HITS, -m MIN_FASTA_HITS
Minimum No. of kmers matching a read (default: 10)
Minimum percentage coverage of typing sequence to
report (default: 85)
--min_kmers_for_onex_pass MIN_KMERS_FOR_ONEX_PASS
Minimum No. of kmers matching a read in 1st pass
(default: 10)

### Required argument

__input_fastq__: This is a single FASTQ file. It can be optionally gzipped. Alternatively input can be read from stdin by using the dash character (-) as the input file name. The file must contain long reads, such as those from PacBio or Oxford Nanopore. The quality scores are ignored.

### Optional input arguments

__plasmid_data__: This is a FASTA file containing all of the plasmid typing sequences. This is generated by the plasmidpredictor_database_downloader script. It comes from the PlasmidFinder website, so please be sure to cite their paper (citation gets printed every time you run the script).

__kmer__: The most important parameter. 13 works well for Nanopore, 15 works well for PacBio, but you may need to play around with it for your data. Long reads have a high error rate, so if you set this too high, nothing will match (because it will contain errors). If you set it too low, everything will match, which isnt much use to you. Thinking about your data, on average how long of a stretch of bases can you get in your read without errors? This is what you should set your kmer to. For example, if you have an average of 1 error every 10 bases, then the ideal kmer would be 9.

### Optional output arguments

__filtered_reads_file__: Save the reads which contain the rep/inc sequences to a new FASTQ file. This is useful if you want to undertake a further assembly just on the plasmids.This file should not already exist.

__output_file OUTPUT_FILE__: By default the results are printed to STDOUT. If you provide an output filename (which must not exist already), it will print the results to the file.

__print_interval__: By default the whole file is processed and the final results are printed out. However you can get intermediate results printed after every X number of reads, which is useful if you are doing real time streaming of data into the application and can halt when you have enough information. They are separated by "****".

__verbose__: Enable debugging mode where lots of extra output is printed to STDOUT.

__version__: Print the version number and exit.

### Optional advanced input arguments

__max_gap__: Maximum gap for blocks to be contigous, measured in multiples of the k-mer size. This allows for short regions of elevated errors in the reads to be spanned.

__margin__: Expand the analysis to look at a few bases on either side of where the sequence is predicted to be on the read. This allows for k-mers to overlap the ends.

__min_block_size__: This is the minimum sub read size of a read to consider for indepth analysis after matching k-mers have been identified in the read. This speeds up the analysis quite a bit, but there is the risk that some reads may be missed, particularly if they have partial rep/inc sequences.

__min_fasta_hits__: This is the minimum number of matching kmers in a read, for the read to be considered for analysis. It is a hard minimum threshold to speed up analysis.

__min_perc_coverage__: Only report rep/inc sequences above this percentage coverage. Coverage in this instance is kmer coverage of the underlying sequence (rather than depth of coverage).

__min_kmers_for_onex_pass__: The number of k-mers that must be present in the read for the initial onex pass of the database to be considered for further analysis. This speeds up the analysis quite a bit, but there is the risk that some reads may be missed, particularly if they have partial rep/inc sequences.

# Output
The output is tab delmited and printed to STDOUT by default. You can optionally print it to a file using the '-o' parameter. If you would like to see intermediate results, you can tell it to print every X reads with the '-p' parameter, separated by '****'. An example of the output is:

rep7.1 Full 100 AB037671 plasmidfinder rep7.1_repC(Cassette)_AB037671
rep7.5 Partial 99 AF378372 plasmidfinder rep7.5_CDS1(pKC5b)_AF378372
rep7.6 Partial 94 SAU38656 plasmidfinder rep7.6_ORF(pKH1)_SAU38656
rep7.9 Full 100 NC007791 plasmidfinder rep7.9_CDS3(pUSA02)_NC007791
rep7.10 Partial 91 NC_010284.1 plasmidfinder rep7.10_repC(pKH17)_NC_010284.1
rep7.12 Partial 93 GQ900417.1 plasmidfinder rep7.12_rep(SAP060B)_GQ900417.1
rep7.17 Full 100 AM990993.1 plasmidfinder rep7.17_repC(pS0385-1)_AM990993.1
rep20.11 Full 100 AP003367 plasmidfinder rep20.11_repA(VRSAp)_AP003367
repUS14. Full 100 AP003367 plasmidfinder repUS14._repA(VRSAp)_AP003367

__GENE__: The first column is the first part of the product name.

__COMPLETENESS__: If all of the k-mers in the gene are found in the reads, the completeness is noted as 'Full', otherwise if there are some k-mers missing, it is noted as 'Partial'.

__%COVERAGE__: The percentage coverage is the number of underlying k-mers in the gene where at least 1 matching k-mer has been found in the reads. 100 indicates that every k-mer in the gene is covered. Low coverage results are not shown (controlled by the --min_perc_coverage parameter).

__ACCESSION__: This is the accession number from where the typing sequence originates. You can look this up at NCBI or EBI.

__DATABASE__: This is where the data has come from, which is currently always plasmidfinder.

__PRODUCT__: This is the full product of the gene as found in the database.

# Resource usage
For an 800Mbyte FASTQ file (unzipped) of long reads from a Oxford Nanopore MinION containing Salmonella required 80MB of RAM and took under 1 minute.

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

plasmidpredictor-0.1.0.tar.gz (87.2 kB view hashes)

Uploaded source

Built Distribution

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