annotate tools/rdock/lib/run_rbfuncs.pl @ 3:b02d74d22d05 draft default tip

planemo upload
author marpiech
date Mon, 29 Aug 2016 08:23:52 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
1 #!/usr/bin/perl
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
2 # Perl functions for the run_rb* collection of automated docking scripts
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
3
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
4 use strict;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
5
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
6 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
7 # sub get_prm_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
8 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
9 # Purpose: return a hash table of
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
10 # key=parameter file name, value = file title
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
11 # for all .prm files in a directory
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
12 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
13 # Usage: %prm_table = get_prm_table($dir)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
14 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
15 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
16 # $prmDir - directory to search for .prm files
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
17 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
18 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
19 # %prm_table - hash table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
20 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
21 sub get_prm_table {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
22 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
23 my $prm_dir = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
24
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
25 #Local variables
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
26 my @prm_list;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
27 my %prm_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
28 my $TITLEREC = "TITLE ";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
29 my $file;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
30 my $title;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
31 my @titleLines;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
32
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
33 #Get the list of files ending in .prm
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
34 @prm_list = glob "$prm_dir/*.prm";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
35
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
36 #Read each file and extract the title record
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
37 foreach $file (@prm_list) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
38 open PRMHANDLE,$file;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
39 @titleLines = grep /^$TITLEREC/,<PRMHANDLE>;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
40 close PRMHANDLE;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
41 #Extract just the file name from the full path
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
42 my $prmName = substr($file, rindex($file,"/")+1);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
43 #Check if a title record was found
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
44 if (scalar @titleLines) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
45 $title = substr $titleLines[0],length($TITLEREC);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
46 chomp $title;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
47 $prm_table{$prmName} = $title;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
48 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
49 else {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
50 $prm_table{$prmName} = "No title";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
51 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
52 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
53 return %prm_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
54 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
55 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
56 # sub get_dock_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
57 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
58 # Purpose: Modified version of get_prm_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
59 # specific for the RBT_LIGDB docking database
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
60 # Return a hash table of
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
61 # key=docking library, value = expression for all sd files in that library
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
62 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
63 # Assumes that all subdirs within $db_dir are separate vendor libraries,
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
64 # and that each subdir contains a set of compressed .sd.gz files
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
65 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
66 # Usage: %dock_table = get_dock_table($dir)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
67 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
68 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
69 # $db_dir - directory to search for docking libraries
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
70 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
71 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
72 # %dock_table - hash table#
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
73 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
74 sub get_dock_table {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
75 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
76 my $db_dir = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
77
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
78 #Local variables
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
79 my ($lib,$sdfiles);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
80 my (@lib_list,@sd_list);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
81 my %dock_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
82
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
83 opendir DBDIR,$db_dir;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
84 @lib_list = readdir DBDIR;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
85 closedir DBDIR;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
86
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
87 foreach $lib (sort @lib_list) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
88 if (-d "$db_dir/$lib") {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
89 $sdfiles = "$db_dir/$lib/*.sd*";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
90 @sd_list = glob $sdfiles;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
91 my $n = scalar(@sd_list);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
92 if ($n > 0) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
93 $dock_table{"$lib ($n files)"} = $sdfiles;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
94 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
95 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
96 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
97
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
98 return %dock_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
99 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
100 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
101 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
102 # sub get_selection
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
103 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
104 # Purpose: allow a user to select from
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
105 # a list of parameter files.
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
106 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
107 # Usage: $receptor = get_selection(\%prm_table,"receptor")
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
108 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
109 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
110 # $prm_table_ref - reference to hash table returned by get_prm_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
111 # $name - descriptive name for items (e.g. "receptor" or "script"
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
112 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
113 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
114 # $item - selected items (key into %prm_table)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
115 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
116 sub get_selection {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
117 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
118 my $prm_table_ref = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
119 my $name = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
120
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
121 #Local variables
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
122 my @items = sort keys %$prm_table_ref;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
123 my $nItems = scalar @items;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
124 my ($i,$itemNum,$item);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
125 my $inRange;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
126
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
127 print "\n\n$name selection:\n\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
128 $i=1;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
129 foreach $item (@items) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
130 print "$i\t$item\t$$prm_table_ref{$item}\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
131 $i++;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
132 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
133 do {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
134 print "\nEnter the $name number: ";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
135 $itemNum = <STDIN>;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
136 chomp $itemNum;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
137 print "\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
138 $inRange = (($itemNum >= 1) && ($itemNum <= $nItems));
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
139 print "$itemNum is out of range\n" if (!$inRange);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
140 } until ($inRange);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
141
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
142 print "\nYou have selected the following $name\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
143 $item = $items[$itemNum-1];
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
144 print "$itemNum\t$item\t$$prm_table_ref{$item}\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
145 return $item;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
146 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
147
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
148 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
149 # sub get_multiple_selection
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
150 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
151 # Purpose: allow a user to multiply select from the docking library list
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
152 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
153 # Usage: $receptor = get_selection(\%prm_table,"receptor")
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
154 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
155 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
156 # $prm_table_ref - reference to hash table returned by get_prm_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
157 # $name - descriptive name for items (e.g. "receptor" or "script"
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
158 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
159 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
160 # $item - selected items (key into %prm_table)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
161 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
162 sub get_multiple_selection {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
163 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
164 my $prm_table_ref = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
165 my $name = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
166
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
167 #Local variables
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
168 my @items = sort keys %$prm_table_ref;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
169 my $nItems = scalar @items;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
170 my ($i,$idstring,$itemNum,$item);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
171 my @itemNums;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
172 my @selectedItems;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
173 my $inRange;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
174 my $allInRange;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
175
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
176 print "\n\n$name selection:\n\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
177 $i=1;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
178 foreach $item (@items) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
179 print "$i\t$item\t$$prm_table_ref{$item}\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
180 $i++;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
181 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
182 do {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
183 print "\nEnter the $name number(s): ";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
184 my $idstring = <STDIN>;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
185 chomp $idstring;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
186 @itemNums = get_ids($idstring);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
187 print "\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
188 $allInRange = 1;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
189 foreach $itemNum (@itemNums) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
190 $inRange = (($itemNum >= 1) && ($itemNum <= $nItems));
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
191 print "$itemNum is out of range\n" if (!$inRange);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
192 $allInRange = $allInRange && $inRange;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
193 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
194 } until ($allInRange);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
195
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
196 print "\nYou have selected the following $name(s)\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
197 foreach $itemNum (@itemNums) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
198 $item = $items[$itemNum-1];
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
199 push @selectedItems,$item;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
200 print "$itemNum\t$item\t$$prm_table_ref{$item}\n";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
201 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
202 return @selectedItems;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
203 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
204
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
205 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
206 # sub get_input
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
207 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
208 # Purpose: get user input, or returns default if no response given
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
209 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
210 # Usage: $nRuns = get_input("Enter no. of runs per ligand",10)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
211 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
212 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
213 # $question - text of question to ask
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
214 # $defResponse - default answer
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
215 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
216 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
217 # $response - user response, or default
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
218
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
219 sub get_input {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
220 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
221 my $question = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
222 my $defResponse = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
223 print "$question [$defResponse]: ";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
224 my $response = <STDIN>;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
225 chomp $response;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
226 $response = $defResponse if ($response eq "");
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
227 return $response;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
228 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
229
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
230 # Based on //depot/intranet/1.0/lib/rbt_func.pl#1
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
231 # this function converts a list of ids in one string
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
232 # in the format 1,2,4-6,8,15-20
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
233 # and returns an @array with the unique ids
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
234 sub get_ids {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
235 my $idstring = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
236 my %ids;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
237
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
238 foreach my $id (split (',',$idstring)){
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
239 if ( grep (/-/,$id)){
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
240 (my $low, my $up) = split ('-',$id);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
241 for ( my $co = $low; $co <= $up; $co++ ){
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
242 $ids{$co}=$co;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
243 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
244 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
245 else {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
246 $ids{$id}=$id;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
247 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
248 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
249
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
250 return (sort {$a<=>$b} keys %ids);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
251 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
252 ################################################################################
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
253 # sub get_filter_table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
254 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
255 # Purpose: return a hash table of
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
256 # key=filter file name, value = file title
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
257 # for all .filter files in a directory
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
258 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
259 # Usage: %filter_table = get_filter_table($dir)
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
260 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
261 # Arguments:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
262 # $filterDir - directory to search for .filter files
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
263 # $tmp - temperature for first filter
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
264 # Note:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
265 # The first two filters are not in a file, but are created here
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
266 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
267 # Return parameters:
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
268 # %filter_table - hash table
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
269 #
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
270 sub get_filter_table {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
271 #Arguments
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
272 my $filter_dir = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
273 my $tmp = shift;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
274
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
275 #Local variables
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
276 my $pwd = $ENV{"PWD"};
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
277 my @filter_list;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
278 my %filter_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
279 my $file;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
280
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
281 #Get the list of files ending in .filter
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
282 @filter_list = ((glob "$pwd/*.filter"), (glob "$filter_dir/*.filter"));
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
283 $filter_table{"1no_other_filters"} = "";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
284 # $filter_table{"1threshold"} = "\tSCORE.INTER < $tmp";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
285 # $filter_table{"2cavity"} = "\t\tSCORE.RESTR.CAVITY < 1 ";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
286
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
287 #Read each file and extract the title record
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
288 foreach $file (@filter_list) {
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
289 #Extract just the file name from the full path
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
290 my $filterName = substr($file, rindex($file,"/")+1);
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
291 #Check if a title record was found
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
292 $filter_table{$filterName} = "No title";
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
293 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
294 return %filter_table;
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
295 }
b02d74d22d05 planemo upload
marpiech
parents:
diff changeset
296 1;