################################################################################
#                             CONFIGURATION FILE                               #
#------------------------------------------------------------------------------#
# Configuration file for the Amplicon Metagenomic analysis Workflow.           #
# Set the parameters below, save the file and run snakemake.                   #
# The file format is yaml (http://www.yaml.org/) In this file, you only need   #
# to overwrite settings according to your needs, most values are already       #
# pre-configured. It is very important to keep the indentation of the file     #
# (don’t change the tabs and spaces), as well as the name of the               #
# parameters/variables. But you can change the values of the parameters to     #
# deviate from the default settings. Any text after a hash tag is considered a #
# comment and will be ignored by snakemake.                                    #
#                                                                              #
# Author: Julia Engelmann and Alejandro Abdala                                 #
# Last update: 15/02/2018                                                      #
################################################################################

################################################################################
#                          GENERAL PARAMS SECTION                              #
#------------------------------------------------------------------------------#
# The general parameters section defines variables that are global or general  #
# for the complete work-flow execution, as well as extra information for the   #
# report generation.                                                           #
################################################################################

#------------------------------------------------------------------------------#
#                             Project Name                                     #
#------------------------------------------------------------------------------#
# The name of the project for which the pipe line will be executed.            #
#------------------------------------------------------------------------------#
PROJECT: "NIOZ_DMEC_amp_pipeline_may"

#------------------------------------------------------------------------------#
#                               LIBRARY                                        #
#------------------------------------------------------------------------------#
# SAMPLE/LIBRARY you will like to include in the analysis                     #
# use the script 'init_sample.sh' to link the data such that the pipeline can #
# find it.
#------------------------------------------------------------------------------#
LIBRARY: ["NIOZ47","NIOZ51"]

#------------------------------------------------------------------------------#
#                             INPUT FILES                                      #
#------------------------------------------------------------------------------#
# Here you have to enter FULL PATH! to the raw reads and to the metadata file  #
# fw_reads:  Full path to raw reads in forward direction                       #
# rw_reads:  Full path to raw reads in reverse direction                       #
# metadata:  Full path to metadata with barcodes for library splitting         #
#------------------------------------------------------------------------------#
fw_reads: ""
rv_reads: ""
metadata: ""

#------------------------------------------------------------------------------#
#                               RUN                                            #
#------------------------------------------------------------------------------#
# Name of the RUN - Only use alphanumeric characters and don't use spaces.     #
# This argument helps the user to execute different runs (pipeline execution)  #
# with the same input data but with different parameters (ideally).            #
# The RUN variable can be set here or remain empty, in the latter case, the    #
# user must assign this value via the command line --config RUN=User_run_name  #
#------------------------------------------------------------------------------#
RUN: "23_may"

#------------------------------------------------------------------------------#
#                           Description                                        #
#------------------------------------------------------------------------------#
# Brief description for the pipeline. Any description written here will be     #
# included on the final report. This field is not mandatory so it can remain   #
# empty                                                                        #
#------------------------------------------------------------------------------#
description: "focus on barcodes"

#------------------------------------------------------------------------------#
#                           PDF Report                                         #
#------------------------------------------------------------------------------#
# By default, the pipeline creates the final report in HTML format. In order to#
# create the report as a pdf file, set this flag to T                          #
#Important! in order to convert the file to pdf format, it is necessary execute#
#the pipeline within a X server environment i.e MobaXterm or ssh -X. One way to#
#validate if your active session is ussing any Xserver execute echo $DISPLAY   #
#If the previous command returns empty you do not have an x server session,    #
#therefore set this flag to F                                                  #
#------------------------------------------------------------------------------#
pdfReport: "T"

################################################################################
#                   Specific Parameters Section                                #
#------------------------------------------------------------------------------#
# In this section of the configuration file, you can find all the values used  #
# to run the different rules during the pipeline execution.                    #
# Some of the parameters below, contains an option called "extra_params".      #
# This option is designed to allow the user enter any other extra parameter    #
# available on the program to be executed, therefore if the default            #
# configuration of the pipeline doesn't consider some particular user desired  #
# argument, it can be specified on the extra_params section for each rule      #
#------------------------------------------------------------------------------#

#------------------------------------------------------------------------------#
#                                FastQC                                        #
# rule: validateQC                                                             #
#------------------------------------------------------------------------------#
# FastQC evaluates 12 main concepts on the sequences: (Basic Statistics, Per   #
# base sequence quality, Per tile sequence quality, Per sequence quality scores#
# Per base sequence content, Per sequence GC content,Per base N content,       #
# Sequence Length Distribution, Sequence Duplication Levels, Overrepresented   #
# sequences, Adapter Content and Kmer Content). Here you can set the max number#
# of FAILS accepted on fastqc without sending a warning message                #
# -qcLimit: Number of max fails                                                #
#------------------------------------------------------------------------------#
qcLimit : 3

#------------------------------------------------------------------------------#
#                                Pear                                          #
# rule: pear                                                                   #
#------------------------------------------------------------------------------#
# This step is performed to extend paired reads.                               #
# - t: Minimum length of reads after trimming the low                          #
# - v: Minimum overlap size. The minimum overlap may be set to 1 when the      #
#      statistical test is used. (default in pear: 10)                         #
# - j: Number of threads to use                                                #
# - p: Specify  a p-value for the statistical test. Valid options are: 0.0001, #
#      0.001, 0.01, 0.05 and 1.0. Setting 1.0 disables the test (default: 0.01)#
# - extra_params: Extra parameters. See pear --help for more info              #
# - prcpear: The minimun percentage of expected peared reads, if less a warning#
#            will be shown                                                     #
#------------------------------------------------------------------------------#
pear:
  t: 20
  v: 7
  j: 6
  p: 0.05
  extra_params: ""
  prcpear: 90

#------------------------------------------------------------------------------#
#                      FastQC on extended fragments                            #
# rule: fastQCPear                                                             #
#------------------------------------------------------------------------------#
#  Once that the paired end fragments have been extended, run FastQC again to  #
#  check the quality for the extended reads. Set this option to T (true) or F  #
# (false) in order to execute or skip this step respectively                   #
#------------------------------------------------------------------------------#
fastQCPear: T

#------------------------------------------------------------------------------#
#                        extract_barcodes.py                                   #
# rule: extract_barcodes                                                       #
#------------------------------------------------------------------------------#
# This rule extract barcodes from the reads, at the end generates two files one#
# with all the barcodes and a second one with the sequences without those      #
# barcodes.                                                                    #
# - c: "INPUT_TYPE" barcode_single_end (Input is a single fastq file, that     #
#       starts with the barcode sequence.) barcode_paired_stitched (Input is a #
#       single fastq file that has barcodes at the beginning and end)          #
#       The option barcode_paired_end is not valid here since the fragments are#
#       already extended!                                                      #
# - bc_length: If c equal to "barcode_paired_stitched" use both: --bc1_len X   #
#              --bc2_len Y. If c equal to "barcode_single_end" only use        #
#              --bc1_len X. Where X and Y is the length of the barcode         #
# - extra_params: Extra parameters. See extract_barcodes.py -help              #
#------------------------------------------------------------------------------#
ext_bc:
  c: "barcode_paired_stitched"
  bc_length: "--bc1_len 6 --bc2_len 6"
  extra_params: ""

#------------------------------------------------------------------------------#
#                     Scripts/errorCorrectBarcodes.R                           #
# rule: correct_barcodes & correct_barcodes_unassigned                         #
#------------------------------------------------------------------------------#
# This rule allows bar code missmatch correction.                              #
#                                                                              #
#    bc_missmatch: Number of allowed missmatches.                              #
#                  If bc_missmatch = 0 don't allow missmatch                   #
#                  iF bc_missmatch > 0 correct bc_missmatch bases as maximum   #
#------------------------------------------------------------------------------#
bc_missmatch: 0

#------------------------------------------------------------------------------#
#                             Split libraries                                  #
# rule: split_libraries and split_libraries_rc                                 #
#------------------------------------------------------------------------------#
# This script performs demultiplexing of Fastq sequence data where barcodes and#
# sequences are contained in two separate fastq files                          #
# - barcode_type: The type of barcode used. This can be an integer, e.g. for   #
#   length 6 barcodes, or “golay_12” for golay error-correcting barcodes.      #
# - q: he maximum unacceptable Phred quality score (e.g., for Q20 and better,  #
#      specify -q 19) [default: 3]                                             #
# - r: --max_bad_run_length=MAX_BAD_RUN_LENGTH max number of consecutive low   #
#       quality base calls allowed before truncating a read [default: 3]       #
# - extra_params: Any extra parameter. Run split_libraries_fastq -h for options#
#------------------------------------------------------------------------------#
split:
  q: "23"
  r: "5"
  barcode_type:  "12"
  extra_params: "--phred_offset=33"

#------------------------------------------------------------------------------#
#                             Remove adapters                                  #
# rule: cutadapt                                                               #
#------------------------------------------------------------------------------#
# This rule runs Cutadapt program. Cutadapt searches for the adapter in all    #
# reads and removes it when it finds it. Unless you use a filtering option, all#
# reads that were present in the input file will also be present in the output #
# file, some of them trimmed, some of them not.                                #
# For details, see: http://cutadapt.readthedocs.io/en/stable/guide.html        #
# - cutAdapters: if T (true) remove adapter. F (false) do not remove adapters  #
# - adapters: Use -a ADAPTER to remove adapter ligated to the 3' end of the DNA#
#             Cutadapt deals with 3’ adapters by removing the adapter itself   #
#             and any sequence that may follow. Add the $ character to the end #
#             of an adapter sequence specified via -a in order to anchor the   #
#             adapter to the end of the read, such as -a ADAPTER$. The adapter #
#             will only be found if it is a suffix of the read.                #
#             use -a ADAPTER$ to remove the adapter. To remove adapters at the #
#             5' use -g ADAPTER. If you want to trim only if the adapter is at #
#             the beginning, use -g ^ADAPTER. The ^ is supposed to indicate    #
#             that the adapter is “anchored” at the beginning of the read. In  #
#             other words: The adapter is expected to be a prefix of the read. #
#             If your sequence of interest ist “framed” by a 5’ and a 3’adapter#
#             and you want to remove both adapters, then you may want to use a #
#             linked adapter. A linked adapter combines an anchored 5’ adapter #
#             and a 3’ adapter. The 3’ adapter can be regular or anchored. The #
#             idea is that a read is only trimmed if the anchored adapters     #
#             occur. Thus, the 5’ adapter is always required, and if the 3’    #
#             adapter was specified as anchored, it also must exist for a      #
#          successful match: i.e-a GTGYCAGCMGCCGCGGTAA...ATTAGAWACCCVNGTAGTCC  #
#  - extra_params: Any extra parameter. A good extra parameter here is         #
#             --match-read-wildcards which interpret IUPAC wildcards in reads. #
#             Default: False                                                   #
# more info and options at http://cutadapt.readthedocs.io/en/stable/guide.html #
#------------------------------------------------------------------------------#
cutAdapters: "F"
cutadapt:
  adapters: ""
  extra_params: "--match-read-wildcards"

#------------------------------------------------------------------------------#
#                         identify_chimeric_seqs.py                            #
# rule: search_chimera                                                         #
#------------------------------------------------------------------------------#
# This rule will be executed if and only if the option search="T" otherwise it #
# wont be executed!!!                                                          #
#                                                                              #
# This rule try to identify chimerics sequence using usearch61. This algorithm #
# performs both de novo (abundance based) chimera and reference based detection#
# Unclustered sequences should be used as input rather than a representative   #
# sequence set, as these sequences need to be clustered to get abundance data. #
# The results can be taken as the union or intersection of all input sequences #
# not flagged as chimeras.                                                     #
# For details, see: http://drive5.com/usearch/usearch_docs.html                #
# It is possible to use two other methods Blast_fragments approach and         #
# ChimeraSlayer, however we recomend to use usearch61 since it uses unclustered#
# sequences unlike the other two algorithms, which use representative sequences#
# If you are using usearch61 method, bare in mind that you can use a reference #
# database: extra_params: "-r /export/data/databases/gold_db/gold.fa"          #
# Params:                                                                      #
# - method: This method could be any of the ones used by identify_chimeric_seqs#
#            script, however because of the timeline in which the script is    #
#            executed, for the moment only  usearch61 is available             #
# - threads: Number of threads to use                                          #
# - extra_params: Any extra parameter. It is recomended to run the chimeric    #
#            search against a chimeric DB:                                     #
#                                    -r /export/data/databases/gold_db/gold.fa #
# -search: "T" | "F" true or false to execute the chimera checking             #
#------------------------------------------------------------------------------#
chimera:
  search: "T"
  method: "usearch61"
  threads: 6
  extra_params: "-r /export/data01/databases/gold_db/gold.fa  --suppress_usearch61_ref"

#------------------------------------------------------------------------------#
#                    Remove too long and too short reads                       #
# rule: remove_short_long_reads                                                #
#------------------------------------------------------------------------------#
# This rule execute a python script in order to remove the reads.              #
# Params:                                                                      #
# - longs    Max read length                                                   #
# - shorst   Min read length                                                   #
# The script take the values from this variables, however the script also      #
# compute the sequence length distribution in order to suggest the user with   #
# the best option in order to select the correct fragment length               #
#------------------------------------------------------------------------------#
rm_reads:
  longs: 154
  shorts: 134

#------------------------------------------------------------------------------#
#                         Sample Chart distribution                            #
# rule: distribution_chart                                                     #
#------------------------------------------------------------------------------#
# This option tells the pipeline to create a pie chart or a bar chart with the #
# sample distribution for the library.                                         #
# -sample_chart Chart type. Valid values are bar or pie any other value will   #
# produce BOTH charts, pie and bar, if you want this, please use both          #
#------------------------------------------------------------------------------#
sample_chart: "both"

#------------------------------------------------------------------------------#
#                              pick_otus.py                                    #
# rule: cluster_OTUs                                                           #
#------------------------------------------------------------------------------#
# The OTU picking step assigns similar sequences to operational taxonomic      #
# units, or OTUs, by clustering sequences based on a user-defined similarity   #
# threshold.                                                                   #
# Params:                                                                      #
# - s    SIMILARITY, --similarity=SIMILARITY Sequence similarity threshold     #
#        (for blast, cdhit, uclust, uclust_ref, usearch, usearch_ref, usearch61#
#         usearch61_ref, sumaclust, and sortmerna) [default:0.97]              #
# - m    OTU_PICKING_METHOD, --otu_picking_method=OTU_PICKING_METHOD Method for#
#        picking OTUs.  Valid choices are: sortmerna, mothur, trie, uclust_ref,#
#        usearch                                                               #
# - extra_params Any extra desired parameter run pick_otus.py -h to see all    #
#        the options
#------------------------------------------------------------------------------#
pickOTU:
  s: "0.97"
  m: "uclust"
  extra_params: ""

#------------------------------------------------------------------------------#
#                              pick_rep_set.py                                 #
# rule: pick_representatives                                                   #
#------------------------------------------------------------------------------#
# After picking OTUs, this rule pick a representative set of sequences. For    #
# each OTU, you will end up with one sequence that can be used in subsequent   #
# analyses.                                                                    #
# Params:                                                                      #
# - m --rep_set_picking_method=REP_SET_PICKING_METHOD Method for picking       #
#       representative sets.  Valid choices are random, longest, most_abundant,#
#       first [default: first (first chooses cluster seed when picking otus    #
#       with uclust)]                                                          #
# - extra_params  Any extra desired parameter run pick_rep_set.py -h to see all#
#       the options
#------------------------------------------------------------------------------#
pickRep:
  m: "longest"
  extra_params: ""

################################################################################
#                            Assign taxonomy                                   #
# rule: assign_taxonomy                                                        #
#------------------------------------------------------------------------------#
# Step performed for taxonomy assignation on the representative sequences      #
# This step could be performed by three different methods:                     #
#   1) BLAST. To use this method type "blast" for the <method> variable below. #
#      This method can work with dbType: "-b" and dbFile: "path/to/blast/db"   #
#      or with dbTYpe: "-r" and dbFile: "path/to/fasta/file"                   #
#   2) UCLUST. Method based on sequence clustering. To use this method type    #
#      "uclust" for the <method> variable below. This method ONLY work with    #
#      dbType: "-r" and dbFile: "path/to/fasta/file"                           #
#   3) RDP. The Ribosomal Database Project (RDP) Classifier, a naïve Bayesian  #
#      classifier, can rapidly and accurately classify bacterial 16S rRNA      #
#      sequences. To use this method type "rdp" for the <method> variable below#
#      NOTE! in order to run rdp it is necessary to provide the classifier path#
#      To do so, please include the following line on the extra_params         #
#      --rdp_classifier_fp /usr/share/rdp-classifier/rdp_classifier-2.2.jar    #
#      Due to some compatibility issues, RDP needs some custome fasta file and #
#      taxonomy mapping. so please use the following references:               #
#    dbFile: "/usr/share/qiime/data/gg_13_8_otus/rep_set/97_otus.fasta"        #
#    mappFile:"/usr/share/qiime/data/gg_13_8_otus/taxonomy/97_otu_taxonomy.txt"#
# This 3 different methods can use a different set of options in order to      #
# fine tune the taxonomy classification. This options can be included via the  #
# <extra_params> variable. To see what options are available for each method   #
# just typ eon the command line parallel_assign_taxonomy_<method>.py -h        #
# Params                                                                       #
# - method assignationmethod. Choose one between: blast, uclus or rdp          #
# - mapFile: full path to id_to_taxonomy mapping file.                         #
#          Use "/usr/share/qiime/data/gg_13_8_otus/taxonomy/97_otu_taxonomy.txt#
#          for RDP assignation                                                 #
# - dbFile: full path to fasta file or blast DB                                #
#         Use "/usr/share/qiime/data/gg_13_8_otus/rep_set/97_otus.fasta"       #
#         for RDP assignation                                                  #
# - dbType: If dbFile points to a fasta file use -r. If dbFile points to a     #
#          blast db use -b                                                     #
# - jobs: Number of jobs to start
#------------------------------------------------------------------------------#
assignTaxonomy:
  method: "uclust"
  mapFile: "/export/data/jengelmann/Databases/12Sfish_20180320/12Sfish_20180320_id_to_tax.map"
  dbFile: "/export/data/jengelmann/Databases/12Sfish_20180320/12Sfish_20180320_oneLine_degapped.fa"
  dbType: "-r"
  jobs: "6"
  extra_params: ""

#------------------------------------------------------------------------------#
#                               make_otu_table.py                              #
# rule: make_otu_table                                                         #
#------------------------------------------------------------------------------#
# The rule tabulates the number of times an OTU is found in each sample, and   #
# adds the taxonomic predictions for each OTU in the last column if a taxonomy #
# file is supplied                                                             #
# Params:                                                                      #
# - extra_params  Any extra desired parameter run make_otu_table.py --help to  #
# see all the options                                                          #
#------------------------------------------------------------------------------#
makeOtu:
  extra_params: ""

#------------------------------------------------------------------------------#
#                           filter_otus_from_otu_table.py                      #
# rule: filter_otu                                                             #
#------------------------------------------------------------------------------#
# This rule filter the otu table in order to ride of singletons                #
# Params:                                                                      #
# - n  MIN_COUNT, --min_count=MIN_COUNT the minimum total observation count of #
#      an otu for that otu to be retained [default: 2]                         #
# - extra_params  Any extra desired parameter run filter_otus_from_otu_table.py#
#                 --help to  see all the options                               #
#------------------------------------------------------------------------------#
filterOtu:
  n: "2"
  extra_params: ""

#------------------------------------------------------------------------------#
#                               biom convert                                   #
# rule: convert_table                                                          #
#------------------------------------------------------------------------------#
# This rule converts the OTU biom table into a tab separated OTU table         #
# Params:                                                                      #
# - tableType  [OTU table|Pathway table|Function table|Ortholog table|Gene     #
#              table|Metabolite table|Taxon table|Table]                       #
#              default: --table-type 'OTU table'                               #
# - headerKey: The observation metadata to include from the input BIOM table   #
#              file when creating a tsv table file. By default no observation  #
#              metadata will be included. default: "--header-key taxonomy"     #
# - outFormat: "--to-tsv" Output as TSV-formatted (classic) table. --to-json   #
#              and --to-hdf5 also available                                    #
# - extra_params: Any extra desired parameter run biom convert --help to see   #
#                all the options                                               #
#------------------------------------------------------------------------------#
biom:
  tableType: "--table-type 'OTU table'"
  headerKey: "--header-key taxonomy"
  outFormat: "--to-tsv"
  extra_params: ""

#------------------------------------------------------------------------------#
#                           summarize_taxa.py                                  #
# rule: summarize_taxa                                                         #
#------------------------------------------------------------------------------#
# This rule provides summary information of the representation of taxonomic    #
# groups within each sample.                                                   #
# Params:                                                                      #
# - extra_params: Any extra desired parameter run summarize_taxa.py --help to  #
#                 see all the options.                                         #
#                 Taxonomic level to summarize by default: 2,3,4,5,6]          #
#------------------------------------------------------------------------------#
summTaxa:
  extra_params: "--level 2,3,4,5,6,7"

#------------------------------------------------------------------------------#
#                           filter_fasta.py                                    #
# rule: filter_rep_seqs                                                        #
#------------------------------------------------------------------------------#
# This rule performs OTU map-based filtering: Keep all sequences that show up  #
# in an OTU map.
# Params:                                                                      #
# - extra_params: Any extra desired parameter run filter_fasta.py --help to    #
#                 see all the options.                                         #
#------------------------------------------------------------------------------#
filterFasta:
  extra_params: ""

#------------------------------------------------------------------------------#
#                           align_seqs.py                                      #
# rule: align_rep_seqs                                                        #
#------------------------------------------------------------------------------#
# This rule aligns the sequences in a FASTA file to each other or to a template#
# sequence alignment, depending on the method chosen.                          #
# Params:                                                                      #
# - align: Some analysis so not require the alignment, therefore the user can  #
#          skip this rule by assign value "F" default "T"                      #
# -m:  ALIGNMENT_METHOD,Method for aligning sequences. Valid choices are:      #
#      pynast, infernal, clustalw, muscle, infernal, mafft. default "pynast"   #
# - extra_params: Any extra desired parameter run align_seqs.py --help to      #
#                 see all the options.                                         #
#------------------------------------------------------------------------------#
alignRep:
  align: "T"
  m: "pynast"
  extra_params: ""

#------------------------------------------------------------------------------#
#                           filter_alignment.py                                #
# rule: filter_alignment                                                       #
#------------------------------------------------------------------------------#
# This rule will remove positions which are gaps in every sequence.            #
# Additionally, the user can supply a lanemask file, that defines which        #
# positions should included when building the tree, and which should be ignored#
# Params:                                                                      #
# - extra_params: Any extra desired parameter run filter_alignment.py --help to#
#                 see all the options.                                         #
#------------------------------------------------------------------------------#
filterAlignment:
  extra_params: ""

#------------------------------------------------------------------------------#
#                           make_phylogeny.py                                  #
# rule: make_tree                                                              #
#------------------------------------------------------------------------------#
# Many downstream analyses require that the phylogenetic tree relating the OTUs#
# in a study be present. This rule produces this tree from a multiple sequence #
# alignment                                                                    #
# Params:                                                                      #
# - method:  Method for tree building. Valid choices are: clustalw, raxml_v730,#
#            muscle, fasttree, clearcut [default: fasttree]                    #
# - extra_params: Any extra desired parameter run make_phylogeny.py --help to  #
#                 see all the options.                                         #
#------------------------------------------------------------------------------#
makeTree:
  method: "fasttree"
  extra_params: ""
