#!/bin/bash
#
#   script: Here we run riboPicker and riboPicker* on Set 5: 85% id. 16S 
#			bacteria & archaea (7659 rRNA); The same script can be launched 
#			for all database sets and their respective reads. 
#
#			Step (1) - format database (only for representative database, and 16S SILVA
#                      database from the comprehensive set)
#			Step (2) - 300,000 Roche rRNA reads
#			Step (3) - 1,000,000 Illumina rRNA reads
#			Step (4) - 1,000,000 Roche non-rRNA reads
#			Step (5) - 1,000,000 Illumina non-rRNA
#			Step (6) - SRR106861 filtered reads (for 16S testing)
# 			Step (7) - SRR013513 filtered reads (for 23S testing)*
#
#           *same as Step (6), however use Set 6: 98% id. 23S bacteria & archaea (2811 rRNA)
#
#   note:   all fasta files should have .fasta suffix; modify riboPickerConfig.pm to include
#           new database names.
#
#           riboPicker source http://sourceforge.net/projects/ribopicker/files/standalone/

#
#   contact: evguenia.kopylova@lifl.fr
#
#   date: July 2012
#

# path to 300,000 Roche 454 rRNA reads (produced by clean-reads.sh)
ROCHERRNA="set5-roche-rrna-reads.fasta"

# path to 1,000,000 Illumina rRNA reads (produced by clean-reads.sh)
ILLUMINARRNA="set5-illumina-rrna-reads.fasta"

# path to 1,000,000 Roche 454 non-rRNA reads
ROCHENONRRNA="roche-non-rrna-reads.fasta"

# path to 1,000,000 Illumina non-rRNA reads
ILLUMINANONRRNA="illumina-non-rrna-reads.fasta"

# path to metatranscriptomic filtered set SRR106861
METAT1="SRR106861-filtered.fasta"

# path to metatranscriptomic filtered set SRR013513
METAT2="SRR013513-filtered.fasta"

# path to rRNA database file
DBSPATH="set5-database.fasta"

# indexed represenative database name 
DBS="bac16S-85id"

# indexed comprehensive database names
DBS2="ssr108arcbac,rdp1028,gg20110531,ncbibact2012011716S,hmp2011120616S"

#----------------------------------------
# Step (1) format representative database 

bwa64 index -p $DBS $DBSPATH

#----------------------------------------
# Step (2) 300,000 Roche rRNA reads

echo "300,000 Roche rRNA reads -- representative database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS -f $ROCHERRNA -id ${ROCHERRNA%.fasta}-rep

echo "300,000 Roche rRNA reads -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS2 -f $ROCHERRNA -id ${ROCHERRNA%.fasta}-comp

echo `grep -c '>' ${ROCHERRNA%.fasta}-rep_*fa`
echo `grep -c '>' ${ROCHERRNA%.fasta}-comp_*fa`

#----------------------------------------
# Step (3) 1,000,000 Illumina rRNA reads 
#

echo "1,000,000 Illumina rRNA reads -- representative database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS -f $ILLUMINARRNA -id ${ILLUMINARRNA%.fasta}-rep

echo "1,000,000 Illumina rRNA reads -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS2 -f $ILLUMINARRNA -id ${ILLUMINARRNA%.fasta}-comp

echo `grep -c '>' ${ILLUMINARRNA%.fasta}-rep_*fa`
echo `grep -c '>' ${ILLUMINARRNA%.fasta}-comp_*fa`

#-----------------------------------------
# Step (4) 1,000,000 Roche non-rRNA reads 
#

echo "1,000,000 Roche non-rRNA reads -- representative database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS -f $ROCHENONRRNA -id ${ROCHENONRRNA%.fasta}-rep

echo "1,000,000 Roche non-rRNA reads -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS2 -f $ROCHENONRRNA -id ${ROCHENONRRNA%.fasta}-comp

echo `grep -c '>' ${ROCHENONRRNA%.fasta}-rep_*fa`
echo `grep -c '>' ${ROCHENONRRNA%.fasta}-comp_*fa`

#-----------------------------------------
# Step (5) 1,000,000 Illumina non-rRNA 
#

echo "1,000,000 Illumina non-rRNA -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS -f $ILLUMINANONRRNA -id ${ILLUMINANONRRNA%.fasta}-rep

echo "1,000,000 Illumina non-rRNA -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS2 -f $ILLUMINANONRRNA -id ${ILLUMINANONRRNA%.fasta}-comp

echo `grep -c '>' ${ILLUMINANONRRNA%.fasta}-rep_*fa`
echo `grep -c '>' ${ILLUMINANONRRNA%.fasta}-comp_*fa`

#----------------------------------------------------
# Step (6) SRR106861 filtered reads (for 16S testing)
#

echo "SRR106861 filtered reads (for 16S testing) -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS -f $METAT1 -id ${METAT1%.fasta}-rep

echo "SRR106861 filtered reads (for 16S testing) -- comprehensive database"
time perl ribopicker.pl -c 50 -i 75 -z 3 -dbs $DBS2 -f $METAT1 -id ${METAT1%.fasta}-comp

echo `grep -c '>' ${METAT1%.fasta}-rep_*fa`
echo `grep -c '>' ${METAT1%.fasta}-comp_*fa`

echo "Done."




