跳转到主要内容

从基因突变预测抗生素的效果

项目描述

gpas_testing

创建用于测试的SARS-CoV-2 WHO谱系的完美FASTQ文件

安装

首先,让我们获取存储库并在虚拟环境中工作

git clone git@github.com:GenomePathogenAnalysisService/gpas-testing.git
cd gpas-testing
python -m venv env
source env/bin/activate

现在让我们手动下载constellations SARS-CoV-2谱系定义

git clone https://github.com/cov-lineages/constellations.git

现在我们可以自动安装其余依赖项

pip install -e .

我已指定-e--editable标志,这样如果您对gpas-testing进行更改,它们将自动流入已安装的版本,因此您无需每次都重新安装。如果您使用的是静态版本,则这不是必需的。

完成后,让我们检查数量适中的单元测试是否正常工作

py.test tests/

此存储库包含三个脚本,有助于使用GPAS创建和分析SARS-CoV-2样本批次。

gpas-synreads-covid-create.py -- 创建合成SARS-CoV-2读取

usage: gpas-synreads-covid-create.py [-h] [--variant_definitions VARIANT_DEFINITIONS] [--pango_definitions PANGO_DEFINITIONS]
                                     [--output OUTPUT] [--variant_name VARIANT_NAME] [--reference REFERENCE] --tech TECH
                                     [--primers PRIMERS [PRIMERS ...]] [--read_length READ_LENGTH]
                                     [--read_stddev READ_STDDEV] [--depth DEPTH [DEPTH ...]] [--depth_stddev DEPTH_STDDEV]
                                     [--snps SNPS [SNPS ...]] [--repeats REPEATS] [--error_rate ERROR_RATE [ERROR_RATE ...]]
                                     [--drop_amplicons DROP_AMPLICONS [DROP_AMPLICONS ...]] [--write_fasta]
                                     [--bias_amplicons BIAS_AMPLICONS [BIAS_AMPLICONS ...]]
                                     [--bias_primers BIAS_PRIMERS [BIAS_PRIMERS ...]]
                                     [--drop_forward_amplicons DROP_FORWARD_AMPLICONS [DROP_FORWARD_AMPLICONS ...]]

optional arguments:
  -h, --help            show this help message and exit
  --variant_definitions VARIANT_DEFINITIONS
                        the path to the variant_definitions repository/folder from phe-genomics
  --pango_definitions PANGO_DEFINITIONS
                        the path to the constellations repository/folder from cov-lineages
  --output OUTPUT       the stem of the output file
  --variant_name VARIANT_NAME
                        the name of the variant, default is Reference
  --reference REFERENCE
                        the GenBank file of the covid reference (if not specified, the MN908947.3.gbk reference will be used)
  --tech TECH           whether to generate illumina (paired) or nanopore (unpaired) reads
  --primers PRIMERS [PRIMERS ...]
                        the name of the primer schema, must be on of articv3, articv4, midnight1200, ampliseq
  --read_length READ_LENGTH
                        if specified, the read length in bases, otherwise defaults to the whole amplicon
  --read_stddev READ_STDDEV
                        the standard deviation in the read lengths (default value is 0)
  --depth DEPTH [DEPTH ...]
                        the depth (default value is 500)
  --depth_stddev DEPTH_STDDEV
                        the standard deviation of the depth distribution (default value is 0)
  --snps SNPS [SNPS ...]
                        the number of snps to randomly introduce into the sequence
  --repeats REPEATS     how many repeats to create
  --error_rate ERROR_RATE [ERROR_RATE ...]
                        the percentage base error rate (default value is 0.0)
  --drop_amplicons DROP_AMPLICONS [DROP_AMPLICONS ...]
                        the number (int) of one or more amplicons to drop i.e. have no reads.
  --write_fasta         whether to write out the FASTA file for the variant
  --bias_amplicons BIAS_AMPLICONS [BIAS_AMPLICONS ...]
                        whether to introduce an incorrect SNP in one or more specified amplicons
  --bias_primers BIAS_PRIMERS [BIAS_PRIMERS ...]
                        whether to introduce an incorrect SNP in both primers of an amplicon
  --drop_forward_amplicons DROP_FORWARD_AMPLICONS [DROP_FORWARD_AMPLICONS ...]
                        the names of one or more amplicons where there will be no reads mapping to the forward strand.

如安装部分所述,您已经安装了(pangolin) SARS-CoV-2谱系的constellation定义。代码还可以处理phe-genomics集,然而在编写本文时,这些更新并不频繁。此外,定义不可互换,例如,如果您想创建一个pangolin将其分类为BA.2的基因组,则需要使用pangolin定义,这些是constellations。因此,尽管两者都提供,但我们目前建议使用constellations

首先,我们可以简单地创建一组完美的cBA.1 Illumina读取

gpas-synreads-covid-create.py --pango_definitions constellations/ --tech illumina --variant_name cBA.1 --write_fasta
ls illumina-*
illumina-articv3-cBA.1-cov-0snps-500d-0.0e-0.fasta   illumina-articv3-cBA.1-cov-0snps-500d-0.0e-0_2.fastq
illumina-articv3-cBA.1-cov-0snps-500d-0.0e-0_1.fastq
gzip illumina*fastq

请注意,fastq 文件是以未压缩格式写入的,因此我们首先需要使用 gzip 进行压缩。另外,由于我们没有告诉代码文件应如何命名(使用 --output),它已经为文件分配了一个层次描述性名称。正如您所看到的,许多选项已经采用默认值,例如,默认扩增子方案为 Artic v3,默认深度为 500 条读取,没有错误和单核苷酸多态性。

让我们创建一个更实际的例子;一个使用 Midnight 引物通过 Nanopore 测序的 cBA.3 样本。这个样本的平均深度为 500,标准差为 100,因此一个或多个扩增子只有 250 的读取深度是合理的可能性。其中一个扩增子(2)没有与之关联的读取,并且所有读取的错误率为 2%。这个样本与 cBA.3 参考定义有 2 个单核苷酸多态性。

gpas-synreads-covid-create.py --pango_definitions constellations/ --tech nanopore --variant_name cBA.3 --write_fasta --depth 400 --read_stddev 100 --primers midnight1200 --snps 2 --error_rate 2 --drop_amplicons 2 --write_fasta
ls nanopore-*
nanopore-midnight1200-cBA.3-cov-2snps-400d-0.02e-a2da-0.fasta nanopore-midnight1200-cBA.3-cov-2snps-400d-0.02e-a2da-0.fastq
$ gzip nanopore*fastq

这种程度的可定制性允许您构建一批样本来测试“遗传空间”,例如,可以创建一个包含所有在流行中的常见 SARS-CoV-2 线系的批次,或者一个包含不同错误率的批次,以探索 GPAS 无法再产生参考基因组等。

为了演示目的,让我们构建一个简单的 Illumina cBA.2 样本批次。

mkdir batch-0
cd batch-0
gpas-synreads-covid-create.py --pango_definitions constellations/ --tech illumina --variant_name cBA.2 --write_fasta --depth 300 --read_stddev 100 --primers articv4 --snps 2 --error_rate 1 --write_fasta --repeats 3
gzip *fastq

在这个文件夹中,我们有三对压缩的 FASTQ 文件可以上传,更重要的是,有创建它们的基因组(FASTA 文件),因此我们有 预期 我们可以稍后将其与比较并断言等价性。

现在我们可以使用下一个脚本

gpas-build-uploadcsv.py - 自动创建上传 CSV

您总是可以手动编写上传 CSV,但这既耗时又无聊,还可能引入错误,因此有了这个辅助脚本。如果您在一个包含压缩 fastq 文件的文件夹(如 batch-0)中运行它,并提供一些参数,它将为您创建一个有效的上传 CSV,您可以使用它通过 Electron 客户端/应用程序或 CLI 将批次上传到 GPAS 进行处理。

gpas-build-uploadcsv.py --help
usage: gpas-build-uploadcsv.py [-h] [--country COUNTRY] [--tech TECH] [--file_type FILE_TYPE] [--tag_file TAG_FILE]
                               [--uuid_length UUID_LENGTH] [--number_of_tags NUMBER_OF_TAGS] [--old_format]
                               [--organisation ORGANISATION]

optional arguments:
  -h, --help            show this help message and exit
  --country COUNTRY     the name of the country where the samples were collected
  --tech TECH           whether to generate illumina (paired) or nanopore (unpaired) reads
  --file_type FILE_TYPE
                        whether to look for FASTQ or BAM files
  --tag_file TAG_FILE   a plaintext file with one row per tag
  --uuid_length UUID_LENGTH
                        whether to use a long or short UUID4
  --number_of_tags NUMBER_OF_TAGS
                        how many tags to give each sample. Can be zero, or up to the number of rows in <tag_file>. Default is 2 so as to test the delimiter
  --old_format          whether to use the original upload CSV format and headers
  --organisation ORGANISATION
                        the name of the organisation (the user must belong to it otherwise validation will fail)

我们在这里只关注新的(2022 年 5 月 / Electron 客户端 v1.0.7 / gpas-uploader v1.1.1)上传 CSV 格式,因此最后两个参数不会涉及我们。首先,我们需要创建一个包含每个我们希望代码单独选取的标签的纯文本文件。我创建了一个名为 tags.txt 的文件,其中包含单个包含 test 的行。

根据使用的测序技术,代码将在运行的地方检测样本,然后自动为每个样本生成例如本地的 batchrun_number,以及从最近过去随机创建一个 collection_date。它不会添加任何 controlregiondistrict。您总是可以在之后编辑该文件以进行自定义(例如,通过添加故意的错误来测试上传器的验证规则)。它还将所有 fastq 文件重命名为附加一个长或短的 uuid 字符串。这确保了即使包含“相同的”样本,每个上传 CSV 也是不同的。结果打印到 STDOUT,因此如果您想保留它,需要将其重定向到文件。

gpas-build-uploadcsv.py --country USA --tag_file tags.txt --uuid_length short --number_of_tags 1 --tech illumina > upload.csv

您现在可以使用此上传 CSV 与 Electron 客户端或 gpas CLI 一起使用。

gpas-synreads-covid-create.py - 检查 GPAS 参考基因组是否与构建读取的基因组匹配

此脚本将输出参考基因组与用于构建 FASTQ 文件的基因组进行比较,如果输入基因组包含输出基因组并且后者长度超过 29k 个碱基,则声明成功。它还比较输入的谱系与检测到的谱系。由于它需要样本通过 GPAS 运行,因此在这里不再描述,但它假设您有将本地与 gpas 标识符映射的文件,这里我将它称为 sample_names.csv

培养的“真实”样本

这些可以从以下两个ENA项目获得: PRJEB50520PRJEB51850,其中包含描述相对于武汉参考变异的 vcf 文件,可在此处找到 此处

Docker 使用

提供了一个Dockerfile,以便您制作自己的容器或将镜像发布到Dockerhub(oxfordmmm/gpas_testing)。两种版本都将 constellationsvariant_definitions 目录放置在容器的根目录下。

(PWF: 我对此进行了修改,所以需要更新..)

可以使用如下命令运行容器

docker run -v /path/to/output:/output oxfordmmm/gpas_testing python3 /gpas_testing/bin/gpas_testing.py  --pango_definitions /constellations/ --output /output/reference --tech illumina --variant_name reference --write_fasta 

docker run -v .:/output oxfordmmm/gpas_testing python3 /gpas_testing/bin/gpas-synreads-covid-create.py --pango_definitions /constellations/ --tech illumina --variant_name cBA.1 --write_fasta --output /output/BA.1

Philip W Fowler,2022年7月7日

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码发行版

gpas_testing-1.0.1.tar.gz (3.2 MB 查看哈希值)

上传时间 源代码

构建发行版

gpas_testing-1.0.1-py3-none-any.whl (3.2 MB 查看哈希值)

上传时间 Python 3

由以下组织支持