Mercurial > repos > simon-gladman > velvet_optimiser
comparison velvet_optimiser_wrapper_vlsci.pl @ 2:28d2dd0f048b draft
Uploaded
author | simon-gladman |
---|---|
date | Tue, 05 Feb 2013 19:19:37 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:94dbee11c8a9 | 2:28d2dd0f048b |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # velvet_optimiser_vlsci.pl | |
4 # | |
5 # Copyright 2012 Simon <simon@Hyperion> | |
6 # | |
7 # This program is free software; you can redistribute it and/or modify | |
8 # it under the terms of the GNU General Public License as published by | |
9 # the Free Software Foundation; either version 2 of the License, or | |
10 # (at your option) any later version. | |
11 # | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU General Public License for more details. | |
16 # | |
17 # You should have received a copy of the GNU General Public License | |
18 # along with this program; if not, write to the Free Software | |
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
20 # MA 02110-1301, USA. | |
21 # | |
22 # | |
23 | |
24 use strict; | |
25 use warnings; | |
26 use File::Copy; | |
27 | |
28 my @stuff = @ARGV; | |
29 my %counts; | |
30 my %shortMPs; | |
31 my @reads; | |
32 my $threadsToUse = 2; #According to Enis, this is the default number of threads that multithreaded programs use.. | |
33 | |
34 #TO DO! get velvet compile parameters! | |
35 | |
36 foreach my $param (@stuff){ | |
37 if($param =~ m/galaxy\.datatypes/){ | |
38 $param =~m/datatypes\..+\.(.+)\s+object/; | |
39 my $type = lc($1); | |
40 print "$type\n"; | |
41 } | |
42 else { | |
43 print $param . "\n"; | |
44 } | |
45 } | |
46 | |
47 #try and split some of it up.. | |
48 #kmer stuff | |
49 my $sk = shift @stuff; | |
50 my $ek = shift @stuff; | |
51 my $xk = shift @stuff; | |
52 | |
53 #TO DO! do checks etc on this stuff here! | |
54 | |
55 #get the read file stuff | |
56 my $i = 0; | |
57 | |
58 while(!($stuff[0] =~ m/other:/)){ | |
59 my $index = shift @stuff; | |
60 my $read_type = shift @stuff; | |
61 my $sep = shift @stuff; | |
62 my $file_type = shift @stuff; | |
63 $file_type =~m/datatypes\..+\.(.+)\s+object/; | |
64 $file_type = lc($1); | |
65 $file_type = "fastq" if $file_type =~ m/fastq/i; | |
66 $counts{$read_type} ++; | |
67 my $ffile = shift @stuff; | |
68 my $rfile = shift @stuff if $sep eq "True"; | |
69 my $sMP = shift @stuff; | |
70 $reads[$i] = "-$read_type"; | |
71 $reads[$i] .= $counts{$read_type} if $counts{$read_type} > 1; | |
72 if ($sMP eq "shortMP_lib"){ | |
73 my $temp = "-shortMatePaired"; | |
74 $temp .= $counts{$read_type} if $counts{$read_type} > 1; | |
75 $shortMPs{$temp} = 1; | |
76 } | |
77 $reads[$i] .= " -$file_type"; | |
78 $reads[$i] .= " -separate" if $sep eq "True"; | |
79 $reads[$i] .= " $ffile"; | |
80 $reads[$i] .= " $rfile" if $sep eq "True"; | |
81 $i ++; | |
82 } | |
83 | |
84 #get the other stuff | |
85 shift @stuff if $stuff[0] =~ m/other:/; | |
86 my $amos = shift @stuff; | |
87 my $verbose = shift @stuff; | |
88 | |
89 #get the advanced stuff if it exists! | |
90 my ($oFK, $oFC, $vgO, $minC, $maxC); | |
91 if ($stuff[0] =~ m/advanced:/) { | |
92 shift @stuff; | |
93 $oFK = shift @stuff; | |
94 $oFC = shift @stuff; | |
95 $vgO = shift @stuff; | |
96 $minC = shift @stuff; | |
97 $maxC = shift @stuff; | |
98 } | |
99 | |
100 #get the output file names! | |
101 my $contigs_outfile = shift @stuff; | |
102 my $stats_outfile = shift @stuff; | |
103 my $afg_outfile = shift @stuff if $amos eq "amos"; | |
104 my $logfile = shift @stuff; | |
105 my $stderr = shift @stuff; | |
106 my $lgraph = shift @stuff; | |
107 | |
108 #build the command line... | |
109 | |
110 my $cmd = "VelvetOptimiser.pl -d temp_vgo_files -s $sk -e $ek -x $xk"; | |
111 $cmd .= " -a" if($amos eq "amos"); | |
112 $cmd .= " -v" if($verbose eq "verbose"); | |
113 | |
114 $cmd .= " -f '"; | |
115 foreach my $line (@reads){ | |
116 $cmd .= " $line"; | |
117 } | |
118 $cmd .= "'"; | |
119 | |
120 my $vgopt = $vgO; | |
121 foreach my $key(keys %shortMPs){ | |
122 $vgopt .= " $key" if $key; | |
123 } | |
124 | |
125 $cmd .= " -o '$vgopt'" if $vgopt; | |
126 | |
127 $cmd .= " -k $oFK" if $oFK; | |
128 $cmd .= " -c $oFC" if $oFC; | |
129 $cmd .= " -m $minC" if $minC; | |
130 $cmd .= " -z $maxC" if $maxC; | |
131 $cmd .= " -t $threadsToUse"; | |
132 | |
133 $cmd .= " 2> $stderr"; | |
134 | |
135 print "\n$cmd\n"; | |
136 | |
137 print "about to run the command!"; | |
138 | |
139 if(system($cmd) == 0) { | |
140 #copy the files to the new places and delete the directory.. | |
141 print "Copying output\n"; | |
142 copy("temp_vgo_files/contigs.fa", $contigs_outfile); | |
143 copy("temp_vgo_files/stats.txt", $stats_outfile); | |
144 copy(glob("temp_vgo_files/*Logfile.txt"), $logfile); | |
145 copy("temp_vgo_files/velvet_asm.afg", $afg_outfile) if $amos eq "amos"; | |
146 copy("temp_vgo_files/LastGraph", $lgraph); | |
147 system("rm -rf temp_vgo_files") == 0 or die "Couldn't delete temporary directory. $!"; | |
148 } | |
149 else { | |
150 print "There was a velvet optimiser error\n"; | |
151 exit(1); | |
152 } | |
153 | |
154 exit(0); |