Debian Codegraph @

pipelines/fetch/fetchNt.sh

raw symbols SCIP
1 #!/bin/bash
2 #SBATCH -J sketch_refseq
3 #SBATCH -q genepool
4 #SBATCH -A gtrqc
5 #SBATCH -N 1
6 #SBATCH -C haswell
7 #SBATCH -t 71:00:00
8 #SBATCH --error=log_%j.err
9 #SBATCH --output=log_%j.out
10 #SBATCH --exclusive
11
12 set -e
13
14 #Written by Brian Bushnell
15 #Last updated August 7, 2019
16
17 #Fetches and sketches nt.
18 #Be sure taxonomy is updated first!
19 #To use this script outside of NERSC, modify $TAXPATH to point to your directory with the BBTools taxonomy data,
20 #e.g. TAXPATH="/path/to/taxonomy_directory/"
21
22 TAXPATH="auto"
23
24 #Ensure necessary executables are in your path
25 #module load pigz
26
27 #Fetch nt.
28 wget -q -O - ftp://ftp.ncbi.nih.gov/blast/db/FASTA/nt.gz | gi2taxid.sh -Xmx1g in=stdin.fa.gz out=renamed.fa.gz pigz=32 unpigz bgzip zl=8 server ow shrinknames maxbadheaders=5000 badheaders=badHeaders.txt taxpath=$TAXPATH
29
30 #Sort by taxonomy.
31 #This makes sketching by taxa use much less memory because sketches can be written to disk as soon as they are finished.
32 time sortbyname.sh -Xmx96g in=renamed.fa.gz out=sorted.fa.gz ow taxa tree=auto fastawrap=1023 zl=9 pigz=32 minlen=60 bgzip unbgzip
33
34 #Make a blacklist of kmers occuring in at least 100 different genuses.
35 time sketchblacklist.sh -Xmx31g in=sorted.fa.gz prepasses=1 tree=auto taxa taxlevel=genus ow out=blacklist_nt_genus_100.sketch mincount=120 k=32,24 taxpath=$TAXPATH
36
37 #Generate 31 sketch files, with one sketch per species.
38 #Multiple files allow sketches to load faster on multicore systems.
39 time bbsketch.sh -Xmx31g in=sorted.fa.gz out=taxa#.sketch mode=taxa tree=auto files=31 ow unpigz minsize=300 prefilter autosize blacklist=blacklist_nt_genus_100.sketch k=32,24 depth taxpath=$TAXPATH
40
41 #A query such as contigs.fa can now be compared to the new reference sketches like this:
42 #comparesketch.sh in=contigs.fa k=32,24 tree=auto taxa#.sketch blacklist=blacklist_nt_genus_100.sketch
43
44 #On NERSC systems, you can then set the default path to nt by pointing /global/projectb/sandbox/gaag/bbtools/nt/current at the path to the new sketches.
45 #Then you can use the default set of nt sketches like this:
46 #comparesketch.sh in=contigs.fa nt tree=auto
47 #That command automatically adds the default path to the sketches, the blacklist, and the correct values for K.