Skip to content

Commit

Permalink
Translated other Blastn scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
plstonge committed Feb 26, 2024
1 parent ffef27b commit 7049665
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 43 deletions.
13 changes: 6 additions & 7 deletions scripts/blastn-array.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
#SBATCH --mem-per-cpu=2000M
#SBATCH --time=0-00:20

cd $SLURM_SUBMIT_DIR
if [ "$(basename $PWD)" = "scripts" ]; then
cd ..
fi
cd donnees
cd data

module load gcc/9.3.0 blast+/2.12.0 seqkit/0.15.0

INCONNUS=(M N O P Q R)
INC_X="${INCONNUS[$SLURM_ARRAY_TASK_ID]}"
UNKNOWNS=(M N O P Q R)
UNK_X="${UNKNOWNS[$SLURM_ARRAY_TASK_ID]}"
mkdir -p res_array

parallel blastn -db espece_{1} \
-query chr_$INC_X.fa.split/chr_$INC_X.part_0{2}.fa \
'>' res_array/align_${INC_X}_{1}_{2} ::: A B C D ::: {01..10}
parallel blastn -db species_{1} \
-query chr_$UNK_X.fa.split/chr_$UNK_X.part_0{2}.fa \
'>' res_array/align_${UNK_X}_{1}_{2} ::: A B C D ::: {01..10}
1 change: 0 additions & 1 deletion scripts/blastn-glost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#SBATCH --mem-per-cpu=2000M
#SBATCH --time=0-00:20

cd $SLURM_SUBMIT_DIR
if [ "$(basename $PWD)" = "scripts" ]; then
cd ..
fi
Expand Down
5 changes: 2 additions & 3 deletions scripts/blastn-parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
#SBATCH --mem-per-cpu=2000M
#SBATCH --time=0-00:20

cd $SLURM_SUBMIT_DIR
if [ "$(basename $PWD)" = "scripts" ]; then
cd ..
fi
cd donnees
cd data

module load gcc/9.3.0 blast+/2.12.0 seqkit/0.15.0

mkdir -p res_prll

parallel 'blastn -db espece_{1} -query chr_{2}.fa > res_prll/align_{2}_{1}' \
parallel 'blastn -db species_{1} -query chr_{2}.fa > res_prll/align_{2}_{1}' \
::: A B C D ::: K L M N O P Q R S T U V W X Y Z
18 changes: 9 additions & 9 deletions scripts/blastn-pipeline.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash

echo '- Aller à la racine du matériel ...'
echo '- Going to the root of the material ...'
cd $(dirname $0)/..
CIP201=$PWD

echo '- Importer les données dans $SCRATCH ...'
mkdir -p $SCRATCH/donnees
rsync -a donnees/ $SCRATCH/donnees/
echo '- Copying the data to $SCRATCH ...'
mkdir -p $SCRATCH/data
rsync -a data/ $SCRATCH/data/
cd $SCRATCH

echo '- Soumettre la première tâche ...'
TACHE1=$(sbatch --parsable $CIP201/scripts/blastn-gen-seq.sh)
echo ' - Numéro de tâche initiale :' $TACHE1
echo '- Submitting the first job ...'
JOB1=$(sbatch --parsable $CIP201/scripts/blastn-gen-seq.sh)
echo ' - First job ID:' $JOB1

echo '- Soumettre la tâche dépendante ...'
sbatch --dependency=afterok:$TACHE1 $CIP201/scripts/blastn-parallel.sh
echo '- Submitting the second job that depends on the first one ...'
sbatch --dependency=afterok:$JOB1 $CIP201/scripts/blastn-parallel.sh
squeue -u $USER
23 changes: 23 additions & 0 deletions scripts/blastn-postprocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

RESULTS=$SCRATCH/data/res_prll
MY_PROJECT=$(ls -d $HOME/projects/def-*/$USER)
FINAL_TSV=$MY_PROJECT/results.tsv

cd $RESULTS

echo -e 'unknown\tspecies\tpercentage' > $FINAL_TSV

for filename in $(ls); do
unknown=$(echo $filename | cut -d_ -f2)
species=$(echo $filename | cut -d_ -f3)
echo -en "$unknown\t$species\t"

grep Identities $filename | awk '{print $3}' | tr '/' ' ' | awk '
BEGIN {m=0; b=0;}
{m+=$1; b+=$2;}
END {b++; percent=100.0*m/b; print percent"%"}'
done >> $FINAL_TSV

echo $FINAL_TSV
cat $FINAL_TSV
23 changes: 0 additions & 23 deletions scripts/blastn-traitement.sh

This file was deleted.

0 comments on commit 7049665

Please sign in to comment.