Bio-App-SELEX-RNAmotifAnalysis
view release on metacpan or search on metacpan
bin/RNAmotifAnalysis view on Meta::CPAN
stock2fasta => 'selex_stock2fasta.pl',
};
$config->{Flags_for} = {
RNAalifold => '-r -cv 0.6 -nc 10 -p -d2 -noLP -color -aln',
mafft => '--preservecase --clustalout',
};
$config->write($config_filename);
warn "\nNo configuration file found. Creating new configuration file '$config_filename'\n";
warn external_dependecnies();
warn <<"MSG";
If you have problems, you may need to ensure that each executable
listed in '$config_filename' is located in a directory that is found
in your PATH environment variable.\n";
MSG
}
$config = Config::Tiny->read($config_filename);
return $config;
}
sub create_batch_files {
my $config = shift;
my $num_cpus = shift;
my $run_scripts = shift;
# Get all the file names to be processed
my @fasta_filenames = glob '*_top.fasta';
# Reduce number of cpus if there are fewer files
$num_cpus = min(scalar @fasta_filenames, $num_cpus);
# Create a batch of commands for each CPU to work on
my @workload = map { $EMPTY_STRING } 1 .. $num_cpus;
my $add_work = __add_work(
{
workload_aref => \@workload,
num_cpus => $num_cpus,
config => $config,
}
);
$add_work->($_) for @fasta_filenames;
# Execute the commands for each CPU
for my $batch_num ( 1 .. $num_cpus ){
# name script file for each batch
my $batch_filename = "batch_$batch_num";
# Create a directory for each batch
system("mkdir $batch_filename.dir");
# Move into batch directory
chdir "$batch_filename.dir";
# Write batch instruction to script file
open( my $fh, '>', $batch_filename);
print {$fh} $workload[ $batch_num - 1];
close $fh;
# Make script file executable
system("chmod u+x $batch_filename");
# Run the script, if desired
if($run_scripts){
system("./$batch_filename &");
}
# Return to directory about batch directory
chdir '..';
}
return;
}
sub __add_work {
my %opt = %{ shift() };
my $workload_aref = $opt{workload_aref} || croak "'workload_aref' required";
my $num_cpus = $opt{num_cpus} || croak "'num_cpus' required";
my $config = $opt{config} || croak "'config' required";
my $work_index = 0;
my @filenames_to_rename = _filenames_to_rename();
my $MAFFT_cmd = "$config->{executables}{mafft} $config->{Flags_for}{mafft}";
my $RNAalifold_cmd = "$config->{executables}{RNAalifold} $config->{Flags_for}{RNAalifold}";
return sub {
my $fasta_filename = shift;
my %file = file_name_hash($fasta_filename);
# Don't allow accidentally creating new keys
lock_keys %file;
# Cycle through the sets number of work orders
if ( $work_index >= $num_cpus ) {
$work_index = 0;
}
$workload_aref->[$work_index] .= join(
"\n",
# Pull fasta file into current directory
"mv ../$file{fasta} .",
# Do alignment of sequences against each other
"$MAFFT_cmd $file{fasta} > $file{aligned}",
# Calculate the secondary structure
"$RNAalifold_cmd < $file{aligned} > $file{sec_struct}",
# Rename resulting files
( map { "mv $_ $file{$_}" } @filenames_to_rename ),
# Convert secondary structure file to Stockholm format
"$config->{executables}{CreateStockholm} $file{aligned} $file{sec_struct} > $file{stock}",
# Determine covariance model
"$config->{executables}{cmbuild} $file{covar_model} $file{stock}",
) . "\n";
# Increment work index
$work_index++;
bin/RNAmotifAnalysis view on Meta::CPAN
=head1 INSTALLATION
These installation instructions assume being able to open and use a
terminal window on Linux.
(0) Some systems need several dependencies installed ahead of time.
You may be able to skip this step. However, if subsequent steps don't
work, then be sure that some basic libraries are installed, as shown
below (or ask a system administrator to take care of it). For the
applicable distribution, open a terminal and then type the commands as
indicated:
For RedHat or CentOS 5.x systems (tested on CentOS 5.5)
sudo yum install gcc
For RedHat or CentOS 6.x systems (tested on "Minimal Desktop" CentOS 6.0)
sudo yum install gcc
sudo yum install perl-devel
For Ubuntu systems (tested on Ubuntu 12-04 LTS)
sudo apt-get install curl
For Debian 5.x systems:
sudo apt-get install gcc
sudo apt-get install make
(1) Install the non-Perl dependencies:
(Versions shown are those that we've tested. Please contact us if
newer versions do not work.)
Infernal 1.0.2 (http://infernal.janelia.org/)
MAFFT 6.849b (http://mafft.cbrc.jp/alignment/software/)
RNA Vienna package 1.8.4 (http://www.tbi.univie.ac.at/~ivo/RNA/)
After installing these, make sure all of the foloowing executables are
in directories within your PATH:
cmbuild
cmcalibrate
cmsearch
cmalign
mafft
RNAalifold
(2) Use a CPAN client to install Bio::App::SELEX::RNAmotifAnalysis.
Here we demonstrate the use of cpanminus to install it to a local Perl module directory. These instructions assume absolutely no experience with cpanminus.
1. Download cpanminus
curl -LOk http://xrl.us/cpanm
2. Make it executable
chmod u+x cpanm
3. Make a local lib/perl5 directory (if it doesn't already exist)
mkdir -p ~/lib/perl5
4. Add relevant directories to your PERL5LIB and PATH environment
variables by adding the following text to your ~/.bashrc
file:
# Set PERL5LIB if it doesn't already exist
: ${PERL5LIB:=~/lib/perl5}
# Prepend to PERL5LIB if directory not already found in PERL5LIB
if ! echo $PERL5LIB | egrep -q "(^|:)~/perl5/lib/perl5($|:)"; then
export PERL5LIB=~/lib/perl5:$PERL5LIB;
fi
# Prepend to PATH if directory not already found in PATH
if ! echo $PATH | egrep -q "(^|:)~/perl5/bin($|:)"; then
export PATH=~/bin:$PATH;
fi
5. Update environment variables immediately
source ~/.bashrc
6. Install Module::Build
./cpanm Module::Build
7. Install Text::LevenshteinXS (even if you already have it installed elsewhere)
./cpanm Text::LevenshteinXS
8. Install Bio::App::SELEX::RNAmotifAnalysis
./cpanm Bio::App::SELEX::RNAmotifAnalysis
Please contact the author if, after consulting this documentation and
searching Google with error messages, you still encounter difficulties
during the installation process.
=head1 INCOMPATIBILITIES
Windows: lacks necessary *nix utilities
SGI: problems with compiled dependency Text::LevenshteinXS
Sun/Solaris: problems with compiled dependency Text::LevenshteinXS
BSD: problems with compiled dependency Text::LevenshteinXS
=head1 BUGS AND LIMITATIONS
There are no known bugs in this module.
( run in 2.086 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )