App-easyDifferentialGeneCoexpressionWrapper
view release on metacpan or search on metacpan
bin/easyDifferentialGeneCoexpressionWrapper view on Meta::CPAN
###################################################
# #
# SUBROUTINES BELOW #
# ----------------- #
# #
###################################################
############################ SUBROUTINE 1 #######################################################
#This subroutine prints the program details at start-up.
sub start_up {
print color ("yellow"),"
#######################################################################
# #
# easyDifferentialGeneCoexpressionWrapper v1.00 #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# #
# Author: Abbas Alameer, Kuwait University #
# abbas.alameer\@ku.edu.kw #
# #
# #
# Developed in February 2022 #
# and released under GPLv2 license #
# #
#######################################################################\n\n\n" , color("reset");
}
############################ SUBROUTINE 2 #######################################################
#various checks done before program's run execution.
sub initial_checks {
#check 1 - check that the script is installed on the system.
#Prompt user to install it, if not found in the $PATH.
my $which_path = qx{which easyDifferentialGeneCoexpressionWrapper};
$run_subdir = "/easyDifferentialGeneCoexpressionWrapper_files";
$rscript_subdir = "$run_subdir/Rscript/";
$csv_file_subdir = "$run_subdir/data/";
$results_subdir = "$run_subdir/results/";
unless ($which_path) {
print color ("red"), "easyDifferentialGeneCoexpressionWrapper is not installed on this system...\n", color("reset");
print color ("red"), "See \"README\" for installation instructions.\n", color("reset");
exit;
}
else {
my $home_dir = File::HomeDir -> my_home;
$rscript_path = $home_dir . $rscript_subdir;
$data_path = $home_dir . $csv_file_subdir;
$results_path = $home_dir . $results_subdir;
#create main directories - ignore if already present
system("mkdir -p $rscript_path $data_path $results_path");
}
#check 2 - check for the presence of curl binary in the $PATH.
#if not found, install on Ubuntu-based systems.
#if system is not Ubuntu-based systems, prompt user to install it manually.
my $check_curl = qx{which curl};
#check if current system is Ubuntu-based
my $ubuntu = qx{uname -a};
if (!$check_curl) {
if ($ubuntu=~ /.+ubuntu.+/ig) {
print color ("red"), "curl binary was not found: follow onscreen instructions/input your password for its installation...\n\n", color("reset");
system("sudo apt -y install curl"); #install curl
print "done\n";
}
else {
print color ("red"), "curl binary was not found: install it on your system.\n", color("reset");
exit;
}
}
#check 3 - check for presence of easyDifferentialGeneCoexpressionInputParameters.r and its auxiliary file && .csv file(s)
$RscriptFile = "$rscript_path" . "easyDifferentialGeneCoexpressionInputParameters.r";
unless (-e $RscriptFile) {
#The script downloads the two R scripts if they do not exist in the current folder
print color ("red"), "\"$RscriptFile\" & \"installPackages.r\" files are missing and will be downloaded...\n\n", color("reset");
system ("cd $rscript_path && { curl -O -C - https://raw.githubusercontent.com/davidechicco/easyDifferentialGeneCoexpression/main/bin/easyDifferentialGeneCoexpressionInputParameters.r ; }");
#make sure to download installPackages.r an auxiliary script used for installing/loading CRAN packages by the main R script.
system ("cd $rscript_path && { curl -O -C - https://raw.githubusercontent.com/davidechicco/easyDifferentialGeneCoexpression/main/bin/installPackages.r ; }");
}
}
############################ SUBROUTINE 3 #######################################################
#get the current date and time.
sub date_time {
my ($sec, $min, $hour, $mday, $mon, $yr, $wday, $yday, $isdst) = localtime();
my $ctime = localtime();
my $time_hour;
my $time_minutes;
#hour #minutes
if ($ctime =~ m/^\w+\s+\w+\s+\d+\s+(\d+)\:(\d+)\:\d+\s+\d+/) {
$time_hour = $1;
$time_minutes = $2;
}
my $month = $mon + 1;
my $year = $yr + 1900;
return "$year-0$month-$mday\_h$time_hour$time_minutes";
}
############################ SUBROUTINE 4 #######################################################
#This subroutine checks all command line input switches and arguments (including optional ones).
#It warns user if mandatory command line input switches and arguments are missing.
sub input_parameters_check {
my $help_message1 = "Usage: easyDifferentialGeneCoexpressionWrapper -h [-a PROBESETS_OR_GENE_SYMBOLS] [-f INPUT_FILE] [-d GEO_DATASET_CODE] [-v FEATURE_NAME] [-v1 CONDITION_1] [-v2 CONDITION_2] [-o OUTPUT_DIRECTORY]";
( run in 1.814 second using v1.01-cache-2.11-cpan-6aa56a78535 )