Mercurial > repos > biomonika > linkyx
comparison scripts/to_get_Y_variants.sh @ 9:695d28139f3e
toolshed8
| author | biomonika <biomonika@psu.edu> |
|---|---|
| date | Tue, 09 Sep 2014 14:31:02 -0400 |
| parents | 1955f03f092e |
| children |
comparison
equal
deleted
inserted
replaced
| 8:983278b1fdb2 | 9:695d28139f3e |
|---|---|
| 1 #!/bin/bash | |
| 2 set -e; | |
| 3 | |
| 4 #read config variables | |
| 5 echo "Reading config...." >&2 | |
| 6 #echo `ls -l` | |
| 7 computer_name=`hostname`; | |
| 8 if [ $computer_name == "misa" ]; then | |
| 9 #local_computer | |
| 10 source config_devel; | |
| 11 else | |
| 12 #metacentrum machine | |
| 13 source config_meta; | |
| 14 fi | |
| 15 | |
| 16 #files needed: reference_male.fasta $reads_1 $reads_2 | |
| 17 | |
| 18 reference=$1; | |
| 19 reads_1="input/$2"; echo "reads_1: " $reads_1; | |
| 20 reads_2="input/$3"; echo "reads_2: " $reads_2; | |
| 21 name=$4; | |
| 22 fragments=$5; | |
| 23 | |
| 24 #INDEXING FILES | |
| 25 | |
| 26 if [ -e "references/reference_male.dict" ]; | |
| 27 then | |
| 28 echo "Reference exists. Not being created again."; | |
| 29 else | |
| 30 echo "seconds of run: $SECONDS"; | |
| 31 java -jar $CreateSequenceDictionary R=$reference O=references/reference_male.dict >mlogfile 2>>errlogfile; | |
| 32 echo "0/9 INDEXING FILES successful"; | |
| 33 echo "seconds of run: $SECONDS"; | |
| 34 fi | |
| 35 | |
| 36 if [ -e "references/reference_male.fai" ]; | |
| 37 then | |
| 38 echo "Samtools reference exists. Not being created again."; | |
| 39 else | |
| 40 echo "seconds of run: $SECONDS"; | |
| 41 echo "reference:"$reference; | |
| 42 samtools faidx $reference 2>>errlogfile; | |
| 43 echo "0/9 INDEXING FILES successful"; | |
| 44 echo "seconds of run: $SECONDS"; | |
| 45 fi | |
| 46 | |
| 47 #1 MAPPING WITH BWA | |
| 48 bwa index $reference >>mlogfile 2>>errlogfile; | |
| 49 | |
| 50 #differs based on the fact whether reads are single or paired-end | |
| 51 bwa aln -t 2 $reference $reads_1 > bam/aln_sa1_${name}_male.sai & 2>>errlogfile; | |
| 52 wait; | |
| 53 | |
| 54 if [[ $fragments =~ (single) ]]; then | |
| 55 #single end reads | |
| 56 bwa samse $reference bam/aln_sa1_${name}_male.sai $reads_1 > bam/aln_${name}_male.sam 2>>errlogfile; | |
| 57 echo "bwa samse $reference bam/aln_sa1_${name}_male.sai $reads_1 > bam/aln_${name}_male.sam 2>>errlogfile"; | |
| 58 else | |
| 59 #pair-end reads | |
| 60 bwa aln -t 2 $reference $reads_2 > bam/aln_sa2_${name}_male.sai & 2>>errlogfile; | |
| 61 echo "bwa aln -t 2 $reference $reads_2 > bam/aln_sa2_${name}_male.sai & 2>>errlogfile"; | |
| 62 wait; | |
| 63 bwa sampe $reference bam/aln_sa1_${name}_male.sai bam/aln_sa2_${name}_male.sai $reads_1 $reads_2 > bam/aln_${name}_male.sam 2>>errlogfile; | |
| 64 echo "bwa sampe $reference bam/aln_sa1_${name}_male.sai bam/aln_sa2_${name}_male.sai $reads_1 $reads_2 > bam/aln_${name}_male.sam 2>>errlogfile"; | |
| 65 fi | |
| 66 | |
| 67 wait; | |
| 68 rm -f bam/aln_sa1_${name}_male.sai bam/aln_sa2_${name}_male.sai | |
| 69 | |
| 70 | |
| 71 echo "1/6 MAPPING WITH BWA successful"; | |
| 72 echo "seconds of run: $SECONDS"; | |
| 73 | |
| 74 #2 CLEANING FILES - adjust MAPQ scores | |
| 75 echo "$SECONDS"; | |
| 76 java -jar $CleanSam I=bam/aln_${name}_male.sam O=bam/aln_cleaned_${name}_male.sam 2>>/dev/null; | |
| 77 echo "2/6 CLEANING FILES - adjust MAPQ scores successful"; | |
| 78 echo "seconds of run: $SECONDS"; | |
| 79 wait | |
| 80 | |
| 81 #3 CONVERTING TO BAM FILE | |
| 82 samtools view -bS bam/aln_cleaned_${name}_male.sam > bam/aln_cleaned_${name}_male.bam 2>>errlogfile; | |
| 83 echo "3/6 CONVERTING TO BAM FILE successful"; | |
| 84 echo "seconds of run: $SECONDS"; | |
| 85 wait | |
| 86 | |
| 87 #4 SORTING BAM FILE | |
| 88 samtools sort bam/aln_cleaned_${name}_male.bam bam/aln_cleaned_sorted_${name}_male >mlogfile 2>>errlogfile; | |
| 89 echo "4/6 SORTING BAM FILE successful"; | |
| 90 echo "seconds of run: $SECONDS"; | |
| 91 wait; | |
| 92 | |
| 93 #5 REMOVING DUPLICATES | |
| 94 java -jar $MarkDuplicates INPUT=bam/aln_cleaned_sorted_${name}_male.bam OUTPUT=bam/aln_cleaned_sorted_deduplicated_${name}_male.bam METRICS_FILE=picard_info.txt REMOVE_DUPLICATES=true ASSUME_SORTED=true VALIDATION_STRINGENCY=LENIENT MAX_FILE_HANDLES_FOR_READ_ENDS_MAP=1000 2>>/dev/null; | |
| 95 echo "5/6 REMOVING DUPLICATES successful"; | |
| 96 echo "seconds of run: $SECONDS"; | |
| 97 wait; | |
| 98 | |
| 99 #9 REMOVING FILES | |
| 100 rm -f bam/aln_${name}_male.sam bam/aln_cleaned_${name}_male.sam bam/aln_cleaned_${name}_male.bam bam/aln_cleaned_sorted_${name}_male.bam >>mlogfile 2>>errlogfile; | |
| 101 echo "6/6 REMOVING FILES successful"; | |
| 102 echo "seconds of run: $SECONDS"; | |
| 103 echo "DONE"; | |
| 104 |
