A tool for submitting to NCBI (SRA, BioSample, & GenBank).
Project description
ncbi-submit
Submitting data to public databases is super important for publically funded laboratories, but it is not always a quick or intuitive process. ncbi-submit
provides a simple and repeatable way to upload programmatic submissions to NCBI's SRA and GenBank with shared or unique BioProjects and BioSamples. Data can be uploaded as XML or zip files to either the Test or Production environments, and once there, the reports produced by NCBI can be analyzed to check on submission status and get BioSample accessions.
Installation:
To install from PyPI in a virtual environment .venv
:
python3 -m venv .venv
. .venv/bin/activate
pip install ncbi-submit
To install from conda (not yet set up) in a new environment ncbi
:
conda create -n ncbi ncbi-submit
Testing
Add NCBI credentials to file ./.login_credentials
or edit them in either:
./example/test.sh
or./config/config.py
To test creating all example files, run:
./example/test.sh
This script ^^^ could also be a good starting point for your own NCBI submission pipelines. Note: There are several blocks of code in there can be commented in/out, as needed.
Usage
ncbi_submit.py
is intended for use on the command line, but the class ncbi.NCBI
can be imported and used within custom python scripts. If the package is pip installed, it can be run via the command ncbi_submit
.
There are three main actions the script can do:
file_prep
:- Prepares .tsv & .xml files for SRA, BioSample, & BioProject submissions
- Used to prepare all files for initial submission to NCBI
- To add in biosample accessions and prepare for GenBank submission, include the flag
prep_genbank
:- Prepares .zip, .sbt, & .tsv files for GenBank Submission
- Used to add BioSample accessions from a BioSample submission for a GenBank submission
ftp
submission or checkup:- Interacts with NCBI's ftp host to do either of the following:
submit
data to NCBI databasescheck
on previous ftp submissions
- Interacts with NCBI's ftp host to do either of the following:
example
:- Writes out example files for one or both of:
- config.py file (tells
ncbi_submit
lots of important info) - template.sbt (used for genbank submission)
- config.py file (tells
- Writes out example files for one or both of:
Setup
The required parameters vary by which of the above actions you're attempting but at minimum require a plate
and outdir
. To limit the number of parameters required via command line, a config
file must be used. When running from the command line, one of the three actions (file_prep
or ftp
) must be specified. With python, these are associated methods you may use on a single NCBI object.
Get example config.py
file:
ncbi_submit example --config --outdir "nbci"
Python instantiation (not needed on command line):
Note: This is the minimum required info for preparing data. Other parameters may be necessary for more functionality or other tasks.
from ncbi_submit import ncbi_submit
ncbi = ncbi_submit.NCBI(
fastq_dir = myFastqDir,
seq_report = mySeqReport,
plate = myPlate,
outdir = myOutdir,
config_file = myConfig,
)
ncbi.write_presubmission_metadata()
File Preperation
Shell:
ncbi_submit file_prep \
--test_mode --test_dir \
--config "${NCBI_CONFIG}" \
--seq_report "${SEQ_REPORT}" \
--primer_map "${PRIMER_MAP}" \
--primer_scheme "${SCHEME_VERSION}" \
--outdir "${NCBI_DIR}" \
--gisaid_log "${GENERIC_GISAID_LOG//PLATE/$PLATE}" \
--fastq_dir ${FASTQS} \
--plate "${PLATE}"
Python:
ncbi.write_presubmission_metadata()
File Submission
Shell:
ncbi_submit ftp \
--submit --db bs_sra \
--test_mode --test_dir \
--config "${NCBI_CONFIG}" \
--outdir "${NCBI_DIR}" \
--fastq_dir "${FASTQS}"
# wait a while and try this to download reports and view submission status
ncbi_submit ftp \
--check --db bs_sra \
--test_mode --test_dir \
--config "${NCBI_CONFIG}" \
--outdir "${NCBI_DIR}"
Python:
ncbi.submit(db="bs_sra)
# wait a while and try this to download reports and view submission status
ncbi.check(db="bs_sra)
GenBank submission
(NOTE: not fully tested) To link your fasta in GenBank to the associated reads, you'll want to add in the BioSample accessions before submitting.
- Acquire BioSample accessions via one of these methods:
- download accessions.tsv file from NCBI and then use
ncbi_submit
- (Do this if you submitted to BioSample via NCBI's Submission Portal)
- use
ncbi_submit --prep_genbank
.- (Do this to avoid manual uploads via NCBI's Submission Portal)
- if you submitted to BioSample via
ncbi_submit
, it can retrieve accessions automatically
- download accessions.tsv file from NCBI and then use
Then run ncbi_submit ftp --submit
to submit to GenBank
Shell:
# dowload report.xml files to get accesssions and add them to genbank.tsv
ncbi_submit file_prep --prep_genbank \
--outdir "${NCBI_DIR}" \
--config ${NCBI_CONFIG} \
--fasta "${GENERIC_CONSENSUS//PLATE/$PLATE}" \
--plate "${PLATE}"
# submit to GenBank (NOTE: db='gb')
ncbi_submit ftp \
--submit --db gb \
--test_mode --test_dir \
--config "${NCBI_CONFIG}" \
--outdir "${NCBI_DIR}" \
--fastq_dir "${FASTQS}"
Python:
# dowload report.xml files to get accesssions
ncbi.check(db="bs_sra")
# prepare genbank submission files and submit
ncbi.submit(db="gb")
## or
# files can also be prepared without submitting via:
ncbi.write_genbank_submission_zip()
Check Submission Status
Wait awhile (10+ minutes) for NCBI to start processing the submission. Then run this to download reports and view submission status. This works for whichever db you want to check on. If not specified, you'll get results on all submitted dbs.
Shell:
# check status of GenBank submission (NOTE: db='gb')
ncbi_submit ftp \
--check --db gb \
--test_mode --test_dir \
--config "${NCBI_CONFIG}" \
--outdir "${NCBI_DIR}"
Python:
# check GenBank submission (NOTE: db='gb')
ncbi.check(db="gb)
Input Paths
Required Files:
config
: Contains preset values and details about your lab, team, and submission plans that are necessary for submission.seq_report
: Main metadata file with sample details - can be equivalent to NCBI's BioSample TSV for use with the Submission Portal.
Optional Files
exclude_file
: Contains a list of "sample_name"s to exclude from NCBI submission (each one on a new line).barcode_map
: Used as a cross-reference. If all samples frombarcode_map
appear inseq_report
, that's great. Otherwise, you'll get a warning with directions for adding samples to theexclude_file
if they shouldn't be submitted. File should have no headers. Lines must be: "{barcode}\t{sample_name}".
Sometimes Required Paths
fastq_dir
: Required forfile_prep
andftp
if submitting reads to SRA. Indicates where the fastqs should be gathered from. Any fastqs with "sample_name" values that aren't supposed to be submitted will be ignored.outdir
: Highly recommended but will defualt to "./ncbi" or "./ncbi_test". A directory to house output (submission reports,exclude_file
, output fromfile_prep
). Will be created, if needed.subdir
: Only used forftp
tasks. A prefix to use for submissions for the given dataset. Defaults toplate
, if plate is provided.
Links to xml template examples/schema:
File type | BioProject | BioSample | SRA | GenBank | Description/Link |
---|---|---|---|---|---|
Webpage | ✓ | ✓ | ✓ | ✓ | Protocols & TSVs for use at Submission Portal |
XML | create | create | create | SRA submission w/ new BioSample & BioProject | |
XML | link | create | create | SRA submission w/ new BioSample & existing BioProject | |
XML | link | link | create | SRA submission w/ existing BioSample & BioProject | |
XML | create | GenBank XML | |||
doc | example | Example GenBank submission zip | |||
XSD | schema | BioSample XML Schema | |||
XSD | schema | BioProject XML Schema | |||
err | validate | Submission Error Explanations |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ncbi_submit-0.4.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2300e10c0a32b936f2e74e0611250e0e0e26501b9ceacbcad38a78df89f83d3 |
|
MD5 | fec2c54f06e5225d37df40f9a242f455 |
|
BLAKE2b-256 | 62c06fb5e61afce29bd7cf289824e9e97eee5ff0081ed8799f5d7510f67dc528 |