Mercurial > repos > hepcat72 > lumpyexpress
comparison lumpy_wrapper.tcsh @ 0:e5150e64206a draft
planemo upload for repository https://github.com/hepcat72/robs_galaxy_tools/tree/master/tools/lumpyexpress commit 9c7264014db750b32a8fa78f511c7efbd12529d9-dirty
author | hepcat72 |
---|---|
date | Tue, 16 Oct 2018 15:55:49 -0400 |
parents | |
children | bfd745cf84c2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e5150e64206a |
---|---|
1 #!/bin/tcsh | |
2 | |
3 #USAGE: lumpy_pipeline.tcsh PAIREDENDRUN OUTVCF BAMS | |
4 #EXAMPLE: lumpy_pipeline.tcsh 1 lumpy.vcf *.bam | |
5 | |
6 #PAIREDENDRUN - 1=paired end 0=single end | |
7 #BAMS - Any bam files (will be sorted if not sorted & indexed if not indexed) | |
8 | |
9 #REQUIRED DEPENDENCIES: | |
10 #lumpy | |
11 #samtools | |
12 #samblaster | |
13 | |
14 setenv PAIREDENDRUN `echo $argv | cut -f 1 -d " "` | |
15 setenv OUTVCF `echo $argv | cut -f 2 -d " "` | |
16 setenv MYARGV `echo $argv | cut -f 3-999 -d " "` | |
17 | |
18 setenv BAMS '' | |
19 setenv SPLTS '' | |
20 setenv DSCDS '' | |
21 setenv SPLTOPTS '' | |
22 | |
23 foreach b ( $MYARGV ) | |
24 | |
25 echo | |
26 echo Preparing $b | |
27 | |
28 echo | |
29 echo Parsing sample name | |
30 set SAMPLE=`echo $b | perl -e 'while(<>){s/\.bam//;print}'` | |
31 | |
32 if ( $status ) then | |
33 echo "Unable to parse sample name in $b" | |
34 exit 1 | |
35 endif | |
36 | |
37 echo | |
38 echo "Checking BAM $b" | |
39 samtools view -H $b | perl -e '$y=0;while(<>){if(/SO:coordinate/){$y=1;}}if($y == 0){exit(2)}' | |
40 | |
41 if ( $status ) then | |
42 echo | |
43 echo "Sorting BAM $b" | |
44 samtools sort -o $b.sort -O BAM $b | |
45 if ( $status ) then | |
46 echo "Error sorting BAM $b" | |
47 exit 2 | |
48 endif | |
49 mv -f $b.sort $b | |
50 if ( $status ) then | |
51 echo "Error renaming BAM $b.sort $b" | |
52 exit 3 | |
53 endif | |
54 endif | |
55 | |
56 perl -e 'unless(-e "$ARGV[0].bai"){exit(3)}' $b | |
57 if ( $status ) then | |
58 echo | |
59 echo "Indexing BAM $b" | |
60 samtools index -b $b | |
61 if ( $status ) then | |
62 echo "Error indexing BAM" | |
63 exit 4 | |
64 endif | |
65 endif | |
66 | |
67 echo | |
68 echo Getting splitters | |
69 samtools sort -n -O sam $b | samblaster -q -s /dev/stdout -o /dev/null | samtools view -Sb - | samtools sort - -o ${SAMPLE}.splitters.bam | |
70 | |
71 if ( $status ) then | |
72 echo "Getting splitters from $b failed" | |
73 exit 5 | |
74 endif | |
75 | |
76 echo | |
77 echo Indexing splitters | |
78 samtools index -b ${SAMPLE}.splitters.bam | |
79 | |
80 if ( $status ) then | |
81 echo "Indexing discordants in $b failed" | |
82 exit 6 | |
83 endif | |
84 | |
85 if ( $PAIREDENDRUN ) then | |
86 echo | |
87 echo Getting discordants | |
88 samtools view -b -F 1294 $b | samtools sort - -o ${SAMPLE}.discordants.bam | |
89 | |
90 if ( $status ) then | |
91 echo "Getting discordants from $b failed" | |
92 exit 7 | |
93 endif | |
94 | |
95 echo | |
96 echo Indexing discordants | |
97 samtools index -b ${SAMPLE}.discordants.bam | |
98 | |
99 if ( $status ) then | |
100 echo "Indexing discordants in $b failed" | |
101 exit 8 | |
102 endif | |
103 | |
104 if ( ${?DSCDS} > 0 && ${%DSCDS} > 0 ) setenv DSCDS "$DSCDS,${SAMPLE}.discordants.bam" | |
105 if ( ${?DSCDS} == 0 || ${%DSCDS} == 0 ) setenv DSCDS ${SAMPLE}.discordants.bam | |
106 | |
107 if ( ${?SPLTS} > 0 && ${%SPLTS} > 0 ) setenv SPLTS "$SPLTS,${SAMPLE}.splitters.bam" | |
108 if ( ${?SPLTS} == 0 || ${%SPLTS} == 0 ) setenv SPLTS ${SAMPLE}.splitters.bam | |
109 | |
110 else | |
111 | |
112 if ( ${?SPLTOPTS} > 0 && ${%SPLTOPTS} > 0 ) setenv SPLTOPTS "$SPLTOPTS -sr id:${SAMPLE},bam_file:${SAMPLE}.splitters.bam,back_distance:10,weight:1,min_mapping_threshold:20" | |
113 if ( ${?SPLTOPTS} == 0 || ${%SPLTOPTS} == 0 ) setenv SPLTOPTS "-sr id:${SAMPLE},bam_file:${SAMPLE}.splitters.bam,back_distance:10,weight:1,min_mapping_threshold:20" | |
114 | |
115 endif | |
116 | |
117 if ( ${?BAMS} > 0 && ${%BAMS} > 0 ) setenv BAMS "$BAMS,$b" | |
118 if ( ${?BAMS} == 0 || ${%BAMS} == 0 ) setenv BAMS $b | |
119 | |
120 end | |
121 | |
122 if ( $PAIREDENDRUN ) then | |
123 | |
124 echo | |
125 echo "Running: lumpyexpress -B $BAMS -S $SPLTS -D $DSCDS -o $OUTVCF" | |
126 lumpyexpress -B $BAMS -S $SPLTS -D $DSCDS -o $OUTVCF | |
127 | |
128 if ( $status ) then | |
129 echo "lumpyexpress failed" | |
130 exit 9 | |
131 endif | |
132 | |
133 else | |
134 | |
135 echo | |
136 echo "Running lumpy: lumpy -mw 4 -tt 0 $SPLTOPTS > $OUTVCF" | |
137 lumpy -mw 4 -tt 0 $SPLTOPTS > $OUTVCF | |
138 | |
139 if ( $status ) then | |
140 echo "lumpy failed" | |
141 exit 10 | |
142 endif | |
143 | |
144 endif | |
145 | |
146 echo | |
147 echo DONE |