-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathM2_pipeline_tree.sh
61 lines (44 loc) · 1.35 KB
/
M2_pipeline_tree.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash -e
#$ -V # Pass environment variables to the job
#$ -N CPO_pipeline # Replace with a more specific job name
#$ -cwd # Use the current working dir
#$ -pe smp 8 # Parallel Environment (how many cores)
#$ -l h_vmem=11G # Memory (RAM) allocation *per core*
#$ -e ./logs/$JOB_ID.err
#$ -o ./logs/$JOB_ID.log
#input parameters: 1 = id, 2= outputdir
#step 1, mash QC
source activate snippy
threads=8
ram=80
outputDir="$1"
reference="$2"
contigs="$3"
echo "parameters: "
echo "outputDir: $outputDir"
echo "outputDir: $reference"
echo "outputDir: $contigs"
echo "outputDir: $threads"
echo "outputDir: $ram"
#treeDir="$outputDir"/trees
treeFileDir="$outputDir"/trees
#mkdir -p "$treeDir"
mkdir -p "$treeFileDir"
contigArray=()
#find snps within each genome
IFS=',' read -ra ADDR <<< "$contigs" #hax to read in a csv
for i in "${ADDR[@]}"; do
refG=`basename $i`
echo $refG
snippy --cpus "$threads" --outdir "$treeFileDir"/"$refG" --reference $reference --ctgs $i
contigArray+=($refG)
done
cd $treeFileDir
#create an alignment from the snps
snippy-core --prefix core *
#create a distance matrix from alignment
snp-dists core.full.aln > distance.tab
#make a nj tree from the matrix
clustalw2 -tree -infile=core.full.aln -outputtree=nj
source deactivate
echo "done step 4"