Mercurial > repos > ktnyt > gembassy
comparison glang-galaxy-conf/kbws/acdgalaxy.pl @ 2:8947fca5f715 draft default tip
Uploaded
| author | ktnyt |
|---|---|
| date | Fri, 26 Jun 2015 05:21:44 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:84a17b3fad1f | 2:8947fca5f715 |
|---|---|
| 1 #!/usr/bin/env perl | |
| 2 use strict; | |
| 3 use warnings; | |
| 4 | |
| 5 my $progname = shift; | |
| 6 $progname =~ s/\.acd$//g; | |
| 7 my $progfile = "/usr/local/share/EMBOSS/acd/$progname.acd"; | |
| 8 open my $acdfh, "<", $progfile; | |
| 9 open my $xmlfh, ">", "$progname.xml"; | |
| 10 | |
| 11 my $tool; | |
| 12 my $description; | |
| 13 my $command; | |
| 14 my @params; | |
| 15 my @args; | |
| 16 my $help; | |
| 17 my $plot = 0+`grep -c 'toggle: plot' $progfile`; | |
| 18 my $pngout = 0+`grep -c 'string: format' $progfile`; | |
| 19 | |
| 20 while(<$acdfh>) { | |
| 21 chomp; | |
| 22 if(/\s*application\s*:\s*\w+\s*\[\s*$/../^\s*\]\s*$/) { | |
| 23 if(/\s*application\s*:\s*(\w+)\s*\[\s*$/) { | |
| 24 $tool = qq(<tool id="EMBOSS: $1" name="$1" version="1.0.2">); | |
| 25 } | |
| 26 | |
| 27 if(/\s*documentation:\s*"([^"]+)"?\s*/) { | |
| 28 my $tmp = $1; | |
| 29 if(/\s*documentation:\s*".+"\s*/) { | |
| 30 $description = qq( <description>$tmp</description>); | |
| 31 } else { | |
| 32 while(<$acdfh>) { | |
| 33 if(/\s*(.*)"/) { | |
| 34 $tmp.= " $1"; | |
| 35 last; | |
| 36 } elsif(/\s*(.*)\s*/) { | |
| 37 $tmp .= " $1"; | |
| 38 } | |
| 39 } | |
| 40 $description = qq( <description>$tmp</description>); | |
| 41 } | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 if(/\s*section\s*:\s*advanced\s*\[/../\s*endsection:\s*advanced/) { | |
| 46 if(/\s*section\s*:\s*advanced\s*\[/../\]/ or /\s*endsction:\s*advanced/) { | |
| 47 next; | |
| 48 } | |
| 49 | |
| 50 if(/\s*\w+\s*:\s*\w+\s*\[/../\s*\]/) { | |
| 51 if(/\s*(\w+)\s*:\s*(\w+)\s*\[/) { | |
| 52 my ($type, $name) = ($1, $2); | |
| 53 my $information; | |
| 54 my $default; | |
| 55 my @values; | |
| 56 | |
| 57 next if $name eq "accid"; | |
| 58 next if $name eq "plot"; | |
| 59 | |
| 60 push @args, $name; | |
| 61 | |
| 62 while(<$acdfh>) { | |
| 63 chomp; | |
| 64 if(/\]/) { | |
| 65 last; | |
| 66 } | |
| 67 if(/\s*information:\s*"([^"]+)"?\s*/) { | |
| 68 my $tmp = $1; | |
| 69 if(/\s*information:\s*".+"\s*/) { | |
| 70 $information = $tmp; | |
| 71 } else { | |
| 72 while(<$acdfh>) { | |
| 73 if(/\s*(.*)"/) { | |
| 74 $tmp.= " $1"; | |
| 75 last; | |
| 76 } elsif(/\s*(.*)\s*/) { | |
| 77 $tmp .= " $1"; | |
| 78 } | |
| 79 } | |
| 80 $information = $tmp; | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 if(/\s*default:\s*"(.+)"\s*/) { | |
| 85 $default = $1; | |
| 86 } | |
| 87 | |
| 88 if(/\s*values:\s*"(.+)"\s*/) { | |
| 89 @values = split ";", $1; | |
| 90 } | |
| 91 } | |
| 92 #print "$type\t$name\t$information"; | |
| 93 #print "\t$default" if defined $default; | |
| 94 #print "\n"; | |
| 95 my $param; | |
| 96 | |
| 97 if($default) { | |
| 98 $default = "yes" if $default eq "Y"; | |
| 99 $default = "no" if $default eq "N"; | |
| 100 $default = "[^ACDEFGHIKLMNPQRSTVWYacgtU]" if $name eq "delkey"; | |
| 101 } else { | |
| 102 $default = ""; | |
| 103 } | |
| 104 | |
| 105 if($type eq "boolean") { | |
| 106 $param = <<EOS; | |
| 107 <param name="$name" type="select" value="$default"> | |
| 108 <label>$information</label> | |
| 109 <option value="no">No</option> | |
| 110 <option value="yes">Yes</option> | |
| 111 </param> | |
| 112 EOS | |
| 113 } | |
| 114 | |
| 115 if($type =~ /(integer)|(float)|(string)/) { | |
| 116 $type =~ s/string/text/g; | |
| 117 $param = <<EOS; | |
| 118 <param name="$name" size="4" type="$type" value="$default"> | |
| 119 <label>$information</label> | |
| 120 </param> | |
| 121 EOS | |
| 122 } | |
| 123 | |
| 124 if($type =~ /selection/) { | |
| 125 my $vals = join "\n", map{ | |
| 126 " <option value=\"$_\">". ucfirst($_) ."</option>" | |
| 127 }@values; | |
| 128 $param = <<EOS | |
| 129 <param name="$name" type="select" value="$default"> | |
| 130 <label>$information</label> | |
| 131 $vals | |
| 132 </param> | |
| 133 EOS | |
| 134 } | |
| 135 | |
| 136 print "$type: $name\n"; | |
| 137 if($param && length $param) { | |
| 138 chomp($param); | |
| 139 push @params, $param; | |
| 140 } | |
| 141 } | |
| 142 } | |
| 143 } | |
| 144 } | |
| 145 close $acdfh; | |
| 146 | |
| 147 my $args = join(" ", map{"-$_ \$$_"}@args); | |
| 148 | |
| 149 my $paramstr = ""; | |
| 150 foreach my $param (@params) { | |
| 151 $paramstr .= "$param\n"; | |
| 152 } | |
| 153 | |
| 154 my $outputs; | |
| 155 | |
| 156 if($plot) { | |
| 157 $command = "<command interpreter=\"perl\">gembassy_calcandplot_wrapper.pl $progname -sequence \$input1 $args -auto \$out_file1 \$out_file2</command>"; | |
| 158 $outputs = <<EOS; | |
| 159 <data format="csv" name="out_file1" label="\${tool.name} data for \${input1.name}" /> | |
| 160 <data format="png" name="out_file2" label="\${tool.name} plot for \${input1.name}" /> | |
| 161 EOS | |
| 162 } elsif($pngout) { | |
| 163 $command = "<command interpreter=\"perl\">emboss_single_outputfile_wrapper.pl $progname -sequence \$input1 -format png -goutfile \$out_file1 -auto $args</command>"; | |
| 164 $outputs = <<EOS; | |
| 165 <data format="png" name="out_file1" label="\${tool.name} for \${input1.name}" /> | |
| 166 EOS | |
| 167 } else { | |
| 168 $command = "<command>$progname -sequence \$input1 $args -auto -outfile \$out_file1</command>"; | |
| 169 printf(STDERR "Enter output data format of $progname (1: txt 2: csv): "); | |
| 170 chomp(my $format = <>); | |
| 171 $format = $format == 1 ? "txt" : "csv"; | |
| 172 $outputs = <<EOS; | |
| 173 <data format="$format" name="out_file1" label="\${tool.name} for \${input1.name}" /> | |
| 174 EOS | |
| 175 } | |
| 176 chomp $outputs; | |
| 177 | |
| 178 print $xmlfh <<EOS; | |
| 179 $tool | |
| 180 $description | |
| 181 $command | |
| 182 <inputs> | |
| 183 <param format="data" name="input1" type="data"> | |
| 184 <label>Sequence</label> | |
| 185 </param> | |
| 186 $paramstr | |
| 187 </inputs> | |
| 188 <outputs> | |
| 189 $outputs | |
| 190 </outputs> | |
| 191 </tool> | |
| 192 EOS | |
| 193 | |
| 194 close $xmlfh; |
