Using the package prozor for creating standardized FASTA. The package can be used to:
This package provides several sets of typical contaminant proteins
and peptides, which can be loaded with load_contaminants();
no_human = TRUE leaves out the contaminants of human
origin. At the FGCZ we always are adding
contaminants to the database. To databases already containing human
proteins, we add the contaminants without the human ones. The
contaminants are easy to distinguish from other entries thanks to the
zz|FGCZCont prefix.
## [1] "zz|fgczContaminants2021|" "zz|Y-FGCZCont00001|"
## [3] "zz|Y-FGCZCont00002|" "zz|Y-FGCZCont00003|"
## [5] "zz|Y-FGCZCont00004|" "zz|Y-FGCZCont00005|"
## [1] 499
## [1] 343
To merge several FASTA databases into a single file place
them into a single folder and give the folder the name of the database.
At the FGCZ the database name is the
project number, e.g. p1000, a consecutive number,
e.g. db1, and a descriptive name,
e.g. example: p1000_db1_example.
Add to the folder also an annotation.txt file. The annotation file
should contain a single line formatted like a FASTA entry
header with the following content:
aa|p<project_number>_<database_name>|<YYYYMMDD> <detailed_description>.
Example :
AA|p1000_db1_example|20180119_Example https://github.com/prolfqua/prozor
The package provides an example of such a folder with the FASTA
files. create_fgcz_fasta_db() reads the FASTA files in it
(*.fasta, *.fa or *.faa,
optionally gzipped) and the first line of annotation.txt;
here we do the same step by step.
database_dir <- system.file("p1000_db1_example", package = "prozor")
files <- list.files(database_dir, pattern = "\\.(fasta|fa|faa)(\\.gz)?$", full.names = TRUE)
basename(files)## [1] "Annotation_allSeq.fasta.gz" "Annotation_canSeq.fasta.gz"
## [1] "AA|p1000_db1_example|20180118 Example: Homo sapiens UniProt entries (Swiss-Prot and TrEMBL, with isoforms) matched by the peptides of extdata/IDResults.txt.gz"
create_decoy_db() puts a dummy entry, whose header is
the annotation, first, followed by the sequences of the FASTA files and
the contaminants. Of entries with the same name, only the first is
kept.
db <- create_decoy_db(files, contaminants = load_contaminants("fgcz2021"), rev_lab = NULL, header = annotation)
length(db)## [1] 1572
Based on the directory name we build the name of the FASTA file adding the current date.
db_file <- file.path(tempdir(), paste0(basename(database_dir), "_", format(Sys.time(), "%Y%m%d"), ".fasta"))
basename(db_file)## [1] "p1000_db1_example_20261125.fasta"
To add decoys, reversed sequences, specify the rev_lab
parameter of create_decoy_db(). Apart from the dummy entry,
the resulting database is twice as long as the non-decoy database. The
names stay unique.
db_decoy <- create_decoy_db(files, contaminants = load_contaminants("fgcz2021"), rev_lab = "REV_", header = annotation)
db_decoy[[length(db_decoy)]]## [1] "ADAFGLESLKQHAEAYDAFFADEDAAYKDVLPRFVPDSLLAKDSPLQLLGEKEGSLLETFYSNDFILPNSTWPGEFGSREKHAAGITHGGSLAVIDQDTLGMAKGFVDRLHDSGKTADPLRGEPPPEPKDERGPHFPVEPGGTVEVAVVGALQYFDAYSLIPFEAKLPELLRVAIDLGNNASHALEAPHKITGFPGGTKTGKDFTGASHWALRLMLPACRKEAIFGRLKKKAKEVAKQYDASVTPYSKGM"
## attr(,"name")
## [1] "REV_zz|Y-FGCZCont00498|"
## attr(,"Annot")
## [1] ">REV_zz|Y-FGCZCont00498| tr|Q43758|Q43758_SOYBN L-ascorbate peroxidase OS=Glycine max OX=3847 GN=apx1 PE=1 SV=1"
## attr(,"class")
## [1] "SeqFastaAA"
## [1] 3143
## [1] 0
The name of a database with decoys ends in _d.
db_decoy_file <- file.path(
tempdir(),
paste0(basename(database_dir), "_d_", format(Sys.time(), "%Y%m%d"), ".fasta")
)
basename(db_decoy_file)## [1] "p1000_db1_example_d_20261125.fasta"
create_fgcz_fasta_db() runs these steps, writes the file
to output_dir and returns a summary.
res <- create_fgcz_fasta_db(
database_dir,
contaminants = load_contaminants("fgcz2021"),
output_dir = tempdir(),
make_summary = FALSE
)
cat(res$summary)## Database created with prozor 0.5.0
## database_dir : /tmp/Rtmpoz2bXc/Rinstb716c39cafa/prozor/p1000_db1_example
## contaminants : 499 sequences
## rev_lab : REV_
## output_dir : /tmp/RtmpBRfZke
## FASTA name : p1000_db1_example_d
## FASTA file name : p1000_db1_example_d_20261125.fasta
## annotation : AA|p1000_db1_example|20180118 Example: Homo sapiens UniProt entries (Swiss-Prot and TrEMBL, with isoforms) matched by the peptides of extdata/IDResults.txt.gz
## n_sequences : 3143
## R version 4.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_4.0.4 prozor_0.5.0 rmarkdown_2.32
##
## loaded via a namespace (and not attached):
## [1] vctrs_0.7.3 cli_3.6.6 knitr_1.52 rlang_1.3.0
## [5] xfun_0.62 otel_0.3.0 generics_0.1.4 S7_1.0.0
## [9] jsonlite_2.0.0 labeling_0.4.3 glue_1.8.1 buildtools_1.0.0
## [13] htmltools_0.5.9 maketools_1.3.2 sys_3.4.3 sass_0.5.0
## [17] scales_1.4.0 grid_4.6.2 tibble_3.3.1 evaluate_1.0.5
## [21] jquerylib_0.1.4 fastmap_1.2.0 yaml_2.3.12 lifecycle_1.0.5
## [25] compiler_4.6.2 dplyr_1.2.1 RColorBrewer_1.1-3 pkgconfig_2.0.3
## [29] farver_2.1.2 digest_0.6.39 R6_2.6.1 tidyselect_1.2.1
## [33] pillar_1.11.1 magrittr_2.0.5 bslib_0.12.0 withr_3.0.3
## [37] tools_4.6.2 gtable_0.3.6 cachem_1.1.0