first pass cleanup of cistematic/genomes; change bamPreprocessing
[erange.git] / docs / runSNPAnalysis.sh
1 #!/bin/bash
2 #
3 # This is no longer supported.  It is recommended that the pythin script of the same name be used instead.
4 #
5 # runSNPAnalysis.sh
6 #
7 # Usages: $ERANGEPATH/runSNPAnalysis.sh mouse rdsfile label rmaskdbfile dbsnpfile uniqStartMin totalRatio rpkmfile cachepages
8 # Example: /getSNPs.sh mouse /woldlab/trog/sdc/alim/24T4spike_10212/24T4spike.rds 24Tspike /woldlab/trog/data1/wlee/db/rmask.db /woldlab/trog/data1/wlee/db/dbSNP128.db 5 0.75 ~/proj/c2c12rna24R/c2c12rna.24R.final.rpkm 5000000 
9
10 # set ERANGEPATH to the absolute or relative path to ERANGE, if it's not in the environment
11
12 if [ -z "$ERANGEPATH" ]
13 then
14     ERANGEPATH='../erange'
15 fi
16
17 echo 'runSNPAnalysis.sh: version 3.2'
18
19 cachepages=""
20 if [ $# -eq 9 ]; then
21     cachepages="--cache "$9
22 fi
23
24 nosplices=""
25 if [ $# -eq 10 ]; then
26     nosplices=" --nosplices "
27 fi
28
29 if [ $# -lt 8 ]; then
30     echo 'runSNPAnalysis.sh genome rdsfile label rmaskdbfile dbsnpfile uniqStartMin totalRatio rpkmfile [cachepages]'
31     echo 'where for each position S:'
32     echo '     uniqStartMin = # independent reads supporting base change at S'
33     echo '     totalRatio = total # reads supporting base change at S / total # reads that pass through S'
34 else
35 # log the parameters
36 arguments=$1' '$2' '$3' '$4' '$5' '$6' '$7' '$8' '$cachepages$nosplices
37 echo 'running with settings: ' $arguments
38 python $ERANGEPATH/recordLog.py snp.log runSNPAnalysis.sh "with parameters: $arguments"
39
40 # get all SNPs by extracting it from the RDS
41 python $ERANGEPATH/getSNPs.py $2 $6 $7 $3.snps.txt --enforceChr $cachepages $nosplices
42
43 # get SNPs in non-repeat regions only
44 python $ERANGEPATH/chkSNPrmask.py $4 $3.snps.txt $3.nr_snps.txt $cachepages
45
46 # Check to see if SNPs are found in dbSNP
47 # if dbSNP128.db is not built yet, build it by running buildsnpdb.py - build snp database using the dbSNP database file downloaded from UCSC
48 # usage: python2.5 buildsnpdb.py snpdbdir snpdbname
49 # the database flat file must be in the snpdbdir directory
50 # To build dbSNP database file, run the following command 
51 # python2.5 buildsnpdb.py snp128.txt dbSNP128
52
53 # get dbSNP info for SNPs that are found in the dbSNP database
54 python $ERANGEPATH/chksnp.py $5 $3.nr_snps.txt $3.nr_dbsnp.txt $cachepages
55
56 # get gene info for the snps found in dbSNP
57 python $ERANGEPATH/getSNPGeneInfo.py $1 $3.nr_dbsnp.txt $8 $3.nr_dbsnp_geneinfo.txt $cachepages
58
59 # get gene info for snps that are not found in dbSNP
60 python $ERANGEPATH/getNovelSNPs.py $1 $3.nr_dbsnp_geneinfo.txt $3.nr.final.txt 
61
62 # make bed file for displaying the snps on UCSC genome browser
63 python $ERANGEPATH/makeSNPtrack.py $3.nr_snps.txt $3 $3.nr_snps.bed
64 fi