Skip to content

Repository files navigation

pyQUEST

Count unique reads and optionally match them to a given library (exact matching only).

Input files:

  • SAM/BAM/CRAM/FASTQ file
  • library file (library-dependent mode only)

Caution

Aviti Element FASTQ files produced by bases2fastq=2.2.0 have a malformed header and as such cannot be parsed by pyQUEST. This was a bug and has been fixed in subsequent versions.

Output files:

Notes:

  • only supports single-sample input files
  • reads with ambiguous nucleotides are discarded
  • masked reads are discarded

Setup

Using a Python virtual environment:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install .

The Docker image can be built as follows:

docker build -t pyquest .

Usage

Usage: pyquest [OPTIONS] QUERIES
Count reads and optionally map them to a library.
QUERIES: Query sequence file (fastq[.gz], sam, bam, cram)
Options:
-o, --output PATH Final output to this filename prefix
[required]
--min-length INTEGER RANGE Minimum read length [default: 1; x>=1]
--most-common INTEGER RANGE Output top X most common unique read
sequences in FASTA format [1<=x<=50]
Input sample metadata: Options adding information to the input
-s, --sample TEXT Sample name to apply to count column,
required for fastq, interrogate header for
others when not defined.
-r, --reference FILE Required for CRAM
Library-dependent: Options specific to library-dependent
counting
-l, --library FILE Expanded library definition TSV file with
optional headers (common format for
single/dual/other)
--low-count INTEGER RANGE *.stats.json includes
low_count_guides_lt_{15,30}, this option
allow specification of an additional cut-
off. [x>=0]
Performance: Options to tune the performance
-c, --cpus INTEGER RANGE CPUs to use (0 to detect) [default: 1;
x>=0]
Debug: Options specific to troubleshooting, testing
and debugging
--loglevel [WARNING|INFO|DEBUG]
Set logging verbosity [default: INFO]
--no-compression Disable output compression
--version Show the version and exit.
--help Show this message and exit.

With Docker:

# Output in the current directory
mkdir -p output
docker run \
-v "$PWD/test.queries.bam":/tmp/x.bam:ro \
-v "$PWD/output":/output \
pyquest \
pyquest \
-o /output/something \
--sample XYZ \
--no-compression \
/tmp/x.bam

File header formats

TSV headers may contain metadata in the form of key-value pairs thus formatted:

##<KEY>: <VALUE>

The column headers, separated by tabs, immediately follow the metadata lines and are preceded by a single # character, e.g.:

#<FIELD 1>	<FIELD 2>	<FIELD 3>

Count header

FieldFormatDescription
CommandstringFull command
Versionx.y.zTool version

Library header

Currently, ignored.

File formats

Library

Format: TSV with library header

The headers are ignored, and therefore the relevant fields are identified by their position. Here we indicate the field positions as one-based, with their corresponding field names in the library-dependent counts.

PositionCounts fieldFormatDescription
1IDstringLibrary sequence identifier
2NAMEstringLibrary sequence name
3SEQUENCE[ACGT]+DNA sequence

E.g.:

## ...
# ...
1	some-name-1	AAAAAAAAATCCAGAACCT
2	some-name-2	AAAAAAATATGCCCGTGGA
3	some-name-3	AAAAAAGCATTTAGGCAGG
4	some-name-4	AAAAAAGCTTGCATTAGAC
5	some-name-5	AAAAAATATCGTGTCAAGT
6	some-name-6	AAAAAATCAGCCACGCGAC

Library-independent counts

Format: TSV with count header (gzip'ed by default)

FieldFormatDescription
SEQUENCE[ACGT]+Unique DNA sequence
LENGTHintegerLength of the sequence
COUNTintegerNumber of reads

E.g.:

##Command: pyquest -o output --min-length 0 --low-count 2 -l guides.tsv --sample XYZ --no-compression test.queries.bam
##Version: 1.0.0
#SEQUENCE	LENGTH	COUNT
AAAAAAGCTTGCATTAGAC	19	25
AAAAAATATCGTGTCAAGT	19	26
AAAAAATGTCAGTCGAGTG	19	34
AAAAACAAGCGCACCACCG	19	1
AAAAACACTTCCATGCAAA	19	25
AAAAACGTATTTAGCCGAA	19	23

Library-dependent counts

Format: TSV with count header (gzip'ed by default)

FieldFormatDescription
IDstringLibrary sequence identifier
NAMEstringLibrary sequence name
SEQUENCE[ACGT]+DNA sequence
LENGTHintegerLength of the DNA sequence
COUNTintegerNumber of reads
UNIQUE0|1Whether the sequence is unique in the library
SAMPLEstringName of the sample of origin of the reads

E.g.:

##Command: pyquest -o output --min-length 0 --low-count 2 -l guides.tsv --sample XYZ --no-compression test.queries.bam
##Version: 1.0.0
#ID	NAME	SEQUENCE	COUNT	UNIQUE	SAMPLE
1	some-name-1	AAAAAAAAATCCAGAACCT	0	1	XYZ
2	some-name-2	AAAAAAATATGCCCGTGGA	0	1	XYZ
3	some-name-3	AAAAAAGCATTTAGGCAGG	0	1	XYZ
4	some-name-4	AAAAAAGCTTGCATTAGAC	25	1	XYZ
5	some-name-5	AAAAAATATCGTGTCAAGT	26	1	XYZ
6	some-name-6	AAAAAATCAGCCACGCGAC	0	1	XYZ

Library-independent stats file

Format: JSON

FieldFormatDescription
sample_namestringName of the sample
input_readsintegerTotal input reads
total_readsintegerTotal reads passed on to counting
discarded_readsintegerTotal reads discarded before counting
vendor_failed_readsintegerTotal reads with the QCFAIL flag
length_excluded_readsintegerTotal reads discarded because shorter than a user-defined threshold
ambiguous_nt_readsintegerTotal reads with ambiguous nucleotides
masked_readsintegerTotal soft-masked reads
zero_length_readsintegerTotal zero-length reads

E.g.:

{
"version": "1.0.0",
"command": "pyquest -o output --min-length 0 --low-count 2 -l guides.tsv --sample XYZ --no-compression test.queries.bam",
"sample_name": "XYZ",
"total_reads": 1020769,
"vendor_failed_reads": 0,
"length_excluded_reads": 0,
"ambiguous_nt_reads": 0,
"masked_reads": 0
}

Library-dependent stats file

Format: JSON

The library-dependent count statistics include the library-dependent count statistics.

All statistics are computed on the read counts of unique targets, excluding those discarded based on their length. The number of low count templates (zero_count_templates and low_count_templates_*) also excludes the targets with short sequences.

FieldFormatDescription
mapped_to_template_readsintegerTotal reads mapping to the library
mean_count_per_templatedecimalMean reads per template
median_count_per_templatedecimalMedian reads per template
multimap_readsintegerTotal reads mapping to more than one template
unmapped_readsintegerTotal reads mapping to no template
total_templatesintegerTotal number of templates
total_unique_templatesintegerTotal number of unique templates
length_excluded_templatesintegerTotal number of unique templates excluded by length
zero_count_templatesintegerTotal number of unique templates with no reads mapping to them
low_count_templates_lt_15integerTotal number of unique templates with less than 15 reads mapping to them
low_count_templates_lt_30integerTotal number of unique templates with less than 30 reads mapping to them
low_count_templates_userobject|nullTotal number of unique templates with less than a user-defined number of reads mapping to them (optional)
gini_coefficientdecimalGini coefficient of the mapping read counts

E.g.:

{
"version": "1.0.0",
"command": "pyquest -o output --min-length 3 --low-count 2 -l guides.tsv --sample XYZ --no-compression test.queries.sam",
"sample_name": "XYZ",
"input_reads": 1020770,
"total_reads": 1020766,
"discarded_reads": 4,
"vendor_failed_reads": 0,
"length_excluded_reads": 1,
"ambiguous_nt_reads": 2,
"masked_reads": 2,
"mapped_to_template_reads": 1020766,
"mean_count_per_template": 10.1,
"median_count_per_template": 0,
"multimap_reads": 0,
"unmapped_reads": 0,
"total_templates": 101064,
"total_unique_templates": 101064,
"length_excluded_templates": 0,
"zero_count_templates": 60927,
"low_count_templates_lt_15": 72265,
"low_count_templates_lt_30": 84339,
"low_count_templates_user": {
"lt": 2,
"count": 61744
},
"gini_coefficient": 0.73
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages