Skip to content

Commit

Permalink
Update gto_relative_complexity_profile pipeline and add gto_fasta_ali…
Browse files Browse the repository at this point in the history
…gn_bwa pipeline
  • Loading branch information
joaorafaelalmeida committed Dec 1, 2020
1 parent f364f5f commit 3cf64d8
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 43 deletions.
2 changes: 1 addition & 1 deletion conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cp pipelines/gto_sars_simulation_detection/gto_sars_simulation_detection.sh $PRE
cp pipelines/gto_download_sars2/gto_download_sars2.sh $PREFIX/bin/
cp pipelines/gto_find_best_sars2/gto_find_best_sars2.sh $PREFIX/bin/
cp pipelines/gto_relative_complexity_profile/gto_relative_complexity_profile.sh $PREFIX/bin/

cp pipelines/gto_fasta_align_bwa/gto_fasta_align_bwa.sh $PREFIX/bin/

cp bin/gto $PREFIX/bin/
cp bin/gto_amino_acid_compressor $PREFIX/bin/
Expand Down
4 changes: 2 additions & 2 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package:
name: gto
version: '1.5.4'
version: '1.5.6'

source:
git_rev: v1.5.4
git_rev: v1.5.6
git_url: https://github.com/cobilab/gto.git

requirements:
Expand Down
177 changes: 177 additions & 0 deletions pipelines/gto_fasta_align_bwa/gto_fasta_align_bwa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/bin/bash
#
TAG="X";
RUN="0";
THREADS="4";
REFERENCE="";
FORWARD="o_fw_pr.fq";
REVERSE="o_rv_pr.fq";
UNPAIRED="o_fw_unpr.fq,o_rv_unpr.fq";
#
################################################################################
#
SHOW_MENU () {
echo " ------------------------------------------------------- ";
echo " ";
echo " gto_align_reads.sh >> FASTQ reads alignment pipeline ";
echo " with sort, duplications removal, and indexes. ";
echo " ";
echo " Program options --------------------------------------- ";
echo " ";
echo " -h, --help Show this, ";
echo " -c, --install Installation (w/ conda), ";
echo " ";
echo " -n <STR>, --name <STR> TAG name for uniqueness, ";
echo " -t <INT>, --threads <INT> Number of threads. ";
echo " ";
echo " Input options ----------------------------------------- ";
echo " ";
echo " -r <FILE>, --reference <FILE> FASTA Reference filename, ";
echo " ";
echo " -1 <FILE>, --forward <FILE> FASTQ forward filename, ";
echo " -2 <FILE>, --reverse <FILE> FASTQ reverse filename, ";
echo " -U <FILE>, --unpaired <FILE> FASTQ unpaired filename. ";
echo " ";
echo " Example ----------------------------------------------- ";
echo " ";
echo " gto_align_reads.sh --threads 8 --reference B19.fa \\ ";
echo " --forward FW.fq --reverse RV.fq -U FW_U.fq,RV_U.fq ";
echo " ";
echo " ------------------------------------------------------- ";
}
#
################################################################################
#
CHECK_INPUT () {
FILE=$1
if [ -f "$FILE" ];
then
echo "Input filename: $FILE"
else
echo -e "\e[31mERROR: input file not found ($FILE)!\e[0m";
SHOW_MENU;
exit;
fi
}
#
################################################################################
#
PROGRAM_EXISTS () {
if ! [ -x "$(command -v $1)" ];
then
echo -e "\e[41mERROR\e[49m: $1 is not installed." >&2;
echo -e "\e[42mTIP\e[49m: Try: gto_align_reads.sh --install" >&2;
exit 1;
fi
}
#
################################################################################
#
if [[ "$#" -lt 1 ]];
then
HELP=1;
fi
#
POSITIONAL=();
#
while [[ $# -gt 0 ]]
do
i="$1";
case $i in
-h|--help|?)
HELP=1;
shift
;;
-c|--install|--compile)
INSTALL=1;
shift
;;
-n|--name|--tag)
TAG="$2";
shift 2;
;;
-t|--threads)
THREADS="$2";
shift 2;
;;
-r|--reference)
REFERENCE="$2";
RUN=1;
shift 2;
;;
-1|--forward)
FORWARD="$2";
shift 2;
;;
-2|--reverse)
REVERSE="$2";
shift 2;
;;
-U|--unpaired)
UNPAIRED="$2";
shift 2;
;;
-*) # unknown option with small
echo "Invalid arg ($1)!";
echo "For help, try: gto_align_reads.sh -h"
exit 1;
;;
esac
done
#
set -- "${POSITIONAL[@]}" # restore positional parameters
#
################################################################################
#
if [[ "$HELP" -eq "1" ]];
then
SHOW_MENU;
exit;
fi
#
################################################################################
#
if [[ "$INSTALL" -eq "1" ]];
then
conda install -c bioconda samtools --yes
conda install -c bioconda bowtie2 --yes
exit;
fi
#
################################################################################
#
if [[ "$RUN" -eq "1" ]];
then
#
echo "Using $THREADS threads ...";
#
PROGRAM_EXISTS "bowtie2";
PROGRAM_EXISTS "samtools";
#
CHECK_INPUT "$REFERENCE";
#
CHECK_INPUT "$FORWARD";
CHECK_INPUT "$REVERSE";
CHECK_INPUT "$UNPAIRED";
#
rm -f index_file_$TAG* aligned_sorted-$TAG.bam aligned_sorted-$TAG.bam.bai aligned_sorted-$TAG.bam
#
bowtie2-build $REFERENCE index_file_$TAG
bowtie2 -a --threads $THREADS --very-sensitive -x index_file_$TAG -1 $FORWARD -2 $REVERSE -U $UNPAIRED > aligned-$TAG.sam
samtools sort --threads $THREADS aligned-$TAG.sam > aligned_sorted-$TAG.bam
samtools sort --threads $THREADS -n aligned_sorted-$TAG.bam > aligned_sorted_sorted-$TAG.bam
samtools fixmate --threads $THREADS -m aligned_sorted_sorted-$TAG.bam aligned_sorted_sorted-$TAG-fixmate.bam
samtools sort --threads $THREADS -o aligned_sorted_sorted-$TAG-fixmate-sort.bam aligned_sorted_sorted-$TAG-fixmate.bam
samtools markdup --threads $THREADS -r aligned_sorted_sorted-$TAG-fixmate-sort.bam aligned_sorted-$TAG.bam
samtools index -@ $THREADS aligned_sorted-$TAG.bam aligned_sorted-$TAG.bam.bai
samtools flagstat -@ $THREADS aligned_sorted-$TAG.bam > Alignments-Stats-$TAG.txt
#
rm -f *.bt2 aligned-$TAG.sam aligned_sorted_sorted-$TAG.bam aligned_sorted_sorted-$TAG-fixmate.bam aligned_sorted_sorted-$TAG-fixmate-sort.bam
#
echo "Reference : $REFERENCE (index included)";
echo "Alignments : aligned_sorted-$TAG.bam (index included)";
#
fi
#
################################################################################
#
Loading

0 comments on commit 3cf64d8

Please sign in to comment.