ensembl-hive  2.8.1
generate_timeline_example_key_transform_file.pl
Go to the documentation of this file.
1 # See the NOTICE file distributed with this work for additional information
2 # regarding copyright ownership.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 use strict;
17 use warnings;
18 
19 # Transform a Compara resource class into a category name according to the
20 # memory requirement.
21 
22 sub get_key_name {
23  my $resource_class = shift;
24 
25  my $display_name = $resource_class->display_name;
26  my $memory_req = $display_name;
27 
28  # Convert special names to the standard nomenclature
29  $memory_req = '250Mb_job' if $display_name eq 'default';
30  $memory_req = '250Mb_job' if $display_name eq 'urgent';
31  $memory_req = '2Gb_job' if $display_name eq 'msa';
32  $memory_req = '8Gb_job' if $display_name eq 'msa_himem';
33 
34  # Remove stuff we don't need
35  $memory_req =~ s/_(job|mpi|big_tmp)//g;
36  $memory_req =~ s/_\d+(_hour|min|c$)//g;
37 
38  # Convert to GBs
39  $memory_req =~ s/Gb$//;
40  if ($memory_req =~ /^(\d+)Mb$/) {
41  $memory_req = $1/1000;
42  } elsif ($memory_req =~ /^mem(\d+)$/) {
43  $memory_req = $1/1000;
44  }
45 
46  if ($memory_req < 1) {
47  return '<1';
48  } elsif ($memory_req <= 4) {
49  return '1-4';
50  } elsif ($memory_req <= 8) {
51  return '5-8';
52  } elsif ($memory_req <= 16) {
53  return '9-16';
54  } elsif ($memory_req <= 32) {
55  return '17-32';
56  } elsif ($memory_req <= 128) {
57  return '33-128';
58  } else {
59  return 'bigmem';
60  }
61 }
62 
63 =head1 LICENSE
64 
65 See the NOTICE file distributed with this work for additional information
66 regarding copyright ownership.
67 
68 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
69 You may obtain a copy of the License at
70 
71  http://www.apache.org/licenses/LICENSE-2.0
72 
73 Unless required by applicable law or agreed to in writing, software distributed under the License
74 is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75 See the License for the specific language governing permissions and limitations under the License.
76 
77 =head1 CONTACT
78 
79 Please subscribe to the eHive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss eHive-related questions or to be notified of our updates
80 
81 =cut
82 
83 1;
get_key_name
public get_key_name()