Debian Codegraph @

bwakit/run-gen-ref

raw
1 #!/bin/bash
2
3 root=`dirname $0`
4
5 url38="ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/001/405/GCA_000001405.15_GRCh38/seqs_for_alignment_pipelines.ucsc_ids/GCA_000001405.15_GRCh38_full_analysis_set.fna.gz"
6 url37d5="ftp://ftp.ncbi.nlm.nih.gov/1000genomes/ftp/technical/reference/phase2_reference_assembly_sequence/hs37d5.fa.gz"
7
8 if [ $# -eq 0 ]; then
9 echo "Usage: $0 <hs38|hs38a|hs38DH|hs37|hs37d5>"
10 echo "Analysis sets:"
11 echo " hs38 primary assembly of GRCh38 (incl. chromosomes, unplaced and unlocalized contigs) and EBV"
12 echo " hs38a hs38 plus ALT contigs"
13 echo " hs38DH hs38a plus decoy contigs and HLA genes (recommended for GRCh38 mapping)"
14 echo " hs37 primary assembly of GRCh37 (used by 1000g phase 1) plus the EBV genome"
15 echo " hs37d5 hs37 plus decoy contigs (used by 1000g phase 3)"
16 echo ""
17 echo "Note: This script downloads human reference genomes. For hs38a and hs38DH, it needs additional"
18 echo " sequences and ALT-to-REF mapping included in the bwa.kit package."
19 exit 1;
20 fi
21
22 if [ $1 == "hs38DH" ]; then
23 (wget -O- $url38 | gzip -dc; cat $root/resource-GRCh38/hs38DH-extra.fa) > $1.fa
24 [ ! -f $1.fa.alt ] && cp $root/resource-GRCh38/hs38DH.fa.alt $1.fa.alt
25 elif [ $1 == "hs38a" ]; then
26 wget -O- $url38 | gzip -dc > $1.fa
27 [ ! -f $1.fa.alt ] && grep _alt $root/resource-GRCh38/hs38DH.fa.alt > $1.fa.alt
28 elif [ $1 == "hs38" ]; then
29 wget -O- $url38 | gzip -dc | awk '/^>/{f=/_alt/?0:1}f' > $1.fa
30 elif [ $1 == "hs37d5" ]; then
31 wget -O- $url37d5 | gzip -dc > $1.fa 2>/dev/null
32 elif [ $1 == "hs37" ]; then
33 wget -O- $url37d5 | gzip -dc 2>/dev/null | awk '/^>/{f=/>hs37d5/?0:1}f' > $1.fa
34 else
35 echo "ERROR: unknown genome build"
36 fi
37
38 [ ! -f $1.fa.bwt ] && echo -e "\nPlease run 'bwa index $1.fa'...\n"
39