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