| 1 | # BioPerl module for Bio::Installer::PAML | ||
| 2 | # | ||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||
| 4 | # | ||
| 5 | # Cared for by Albert Vilella | ||
| 6 | # | ||
| 7 | # Copyright Albert Vilella | ||
| 8 | # | ||
| 9 | # You may distribute this module under the same terms as perl itself | ||
| 10 | |||
| 11 | # POD documentation - main docs before the code | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Bio::Installer::PAML - DESCRIPTION of Object | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | Give standard usage here | ||
| 20 | |||
| 21 | =head1 DESCRIPTION | ||
| 22 | |||
| 23 | Describe the object here | ||
| 24 | |||
| 25 | =head1 FEEDBACK | ||
| 26 | |||
| 27 | =head2 Mailing Lists | ||
| 28 | |||
| 29 | User feedback is an integral part of the evolution of this and other | ||
| 30 | Bioperl modules. Send your comments and suggestions preferably to | ||
| 31 | the Bioperl mailing list. Your participation is much appreciated. | ||
| 32 | |||
| 33 | bioperl-l@bioperl.org - General discussion | ||
| 34 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||
| 35 | |||
| 36 | =head2 Support | ||
| 37 | |||
| 38 | Please direct usage questions or support issues to the mailing list: | ||
| 39 | |||
| 40 | I<bioperl-l@bioperl.org> | ||
| 41 | |||
| 42 | rather than to the module maintainer directly. Many experienced and | ||
| 43 | reponsive experts will be able look at the problem and quickly | ||
| 44 | address it. Please include a thorough description of the problem | ||
| 45 | with code and data examples if at all possible. | ||
| 46 | |||
| 47 | =head2 Reporting Bugs | ||
| 48 | |||
| 49 | Report bugs to the Bioperl bug tracking system to help us keep track | ||
| 50 | of the bugs and their resolution. Bug reports can be submitted via | ||
| 51 | the web: | ||
| 52 | |||
| 53 | http://redmine.open-bio.org/projects/bioperl/ | ||
| 54 | |||
| 55 | =head1 AUTHOR - Albert Vilella | ||
| 56 | |||
| 57 | Email avilella-AT-gmail-DOT-com | ||
| 58 | |||
| 59 | Describe contact details here | ||
| 60 | |||
| 61 | =head1 CONTRIBUTORS | ||
| 62 | |||
| 63 | Additional contributors names and emails here | ||
| 64 | |||
| 65 | =head1 APPENDIX | ||
| 66 | |||
| 67 | The rest of the documentation details each of the object methods. | ||
| 68 | Internal methods are usually preceded with a _ | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | |||
| 73 | # Let the code begin... | ||
| 74 | |||
| 75 | |||
| 76 | package Bio::Installer::PAML; | ||
| 77 | use vars qw(@ISA %DEFAULTS); | ||
| 78 | use strict; | ||
| 79 | |||
| 80 | # Object preamble - inherits from Bio::Root::Root | ||
| 81 | |||
| 82 | use Bio::Root::Root; | ||
| 83 | use Bio::Installer::Generic; | ||
| 84 | |||
| 85 | @ISA = qw(Bio::Installer::Generic ); | ||
| 86 | |||
| 87 | BEGIN { | ||
| 88 | %DEFAULTS = ( 'ORIGIN_DOWNLOAD_DIR' => 'http://abacus.gene.ucl.ac.uk/software/', | ||
| 89 | 'BIN_FOLDER' => 'src', | ||
| 90 | 'DESTINATION_DOWNLOAD_DIR' => '/tmp', | ||
| 91 | 'DESTINATION_INSTALL_DIR' => "$ENV{'HOME'}", | ||
| 92 | 'PACKAGE_NAME' => 'paml4a.tar.gz', | ||
| 93 | 'DIRECTORY_NAME' => 'paml4', | ||
| 94 | 'ENV_NAME' => 'PAMLDIR', | ||
| 95 | ); | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | =head2 get_default | ||
| 100 | |||
| 101 | Title : get_default | ||
| 102 | Usage : | ||
| 103 | Function: | ||
| 104 | Example : | ||
| 105 | Returns : | ||
| 106 | Args : | ||
| 107 | |||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | sub get_default { | ||
| 112 | my $self = shift; | ||
| 113 | my $param = shift; | ||
| 114 | return $DEFAULTS{$param}; | ||
| 115 | } | ||
| 116 | |||
| 117 | |||
| 118 | =head2 install | ||
| 119 | |||
| 120 | Title : install | ||
| 121 | Usage : $installer->install(); | ||
| 122 | Function: | ||
| 123 | Example : | ||
| 124 | Returns : | ||
| 125 | Args : | ||
| 126 | |||
| 127 | |||
| 128 | =cut | ||
| 129 | |||
| 130 | sub install{ | ||
| 131 | my ($self,@args) = @_; | ||
| 132 | $self->_decompress; | ||
| 133 | $self->_tweak_paml_makefile; | ||
| 134 | $self->_execute_paml_makefile; | ||
| 135 | $self->_remember_env; | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | =head2 _execute_paml_makefile | ||
| 140 | |||
| 141 | Title : _execute_paml_makefile | ||
| 142 | Usage : | ||
| 143 | Function: | ||
| 144 | Example : | ||
| 145 | Returns : | ||
| 146 | Args : | ||
| 147 | |||
| 148 | |||
| 149 | =cut | ||
| 150 | |||
| 151 | sub _execute_paml_makefile{ | ||
| 152 | my ($self,@args) = @_; | ||
| 153 | my $call; | ||
| 154 | |||
| 155 | my $destination = $self->destination_install_dir . "/" . $self->directory_name . "/src"; | ||
| 156 | chdir $destination or $self->throw("Cant cd to $destination"); | ||
| 157 | print "\n\nCompiling now... (this might take a while)\n\n"; | ||
| 158 | if (($^O =~ /dec_osf|linux|unix|bsd|solaris|darwin/i)) { | ||
| 159 | $call = "make"; | ||
| 160 | system("$call") == 0 or $self->throw("Error when trying to run make"); | ||
| 161 | } else { | ||
| 162 | $self->throw("_execute_paml_makefile not yet implemented in this platform"); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 167 | =head2 _tweak_paml_makefile | ||
| 168 | |||
| 169 | Title : _tweak_paml_makefile | ||
| 170 | Usage : | ||
| 171 | Function: | ||
| 172 | Example : | ||
| 173 | Returns : | ||
| 174 | Args : | ||
| 175 | |||
| 176 | |||
| 177 | =cut | ||
| 178 | |||
| 179 | sub _tweak_paml_makefile{ | ||
| 180 | my ($self,@args) = @_; | ||
| 181 | my $gcc3; | ||
| 182 | my $return = qx/gcc -v 2>&1/; | ||
| 183 | if ($return =~ /version 3/) { | ||
| 184 | $return = `cat /proc/cpuinfo`; | ||
| 185 | if( ($return =~ /mmx/) || ($return =~ /3dnow/)) { | ||
| 186 | my $destination = $self->destination_install_dir . "/" . $self->directory_name . "/src"; | ||
| 187 | chdir $destination or $self->throw("Cant cd to $destination"); | ||
| 188 | my $new = "Makefile"; | ||
| 189 | open(OLD, "< Makefile.UNIX") or $self->throw("can't open Makefile.UNIX"); | ||
| 190 | open(NEW, "> $new") or $self->throw("can't open $new"); | ||
| 191 | while (<OLD>) { | ||
| 192 | # change $_, then... | ||
| 193 | $_ =~ s/CFLAGS = -O3/\# CFLAGS = -O3/g; | ||
| 194 | if( $return =~ /3dnow/ ) { | ||
| 195 | $_ =~ s/#CFLAGS = -march=athlon -mcpu=athlon -O4 -funroll-loops -fomit-frame-pointer -finline-functions/CFLAGS = -march=athlon -mcpu=athlon -O4 -funroll-loops -fomit-frame-pointer -finline-functions/g; | ||
| 196 | } elsif( $return =~ /mmx/ ) { | ||
| 197 | $_ =~ s/#CFLAGS = -march=pentiumpro -mcpu=pentiumpro -O4 -funroll-loops -fomit-frame-pointer -finline-functions/CFLAGS = -march=pentiumpro -mcpu=pentiumpro -O4 -funroll-loops -fomit-frame-pointer -finline-functions/g; | ||
| 198 | } | ||
| 199 | print NEW $_ or $self->throw("can't write $new"); | ||
| 200 | } | ||
| 201 | close(OLD) or $self->throw("can't close Makefile.UNIX"); | ||
| 202 | close(NEW) or $self->throw("can't close $new"); | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | |||
| 207 | } | ||
| 208 | |||
| 209 | |||
| 210 | 1; |