-
Notifications
You must be signed in to change notification settings - Fork 28
/
annocript.pl
1618 lines (1346 loc) · 76.9 KB
/
annocript.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
#Annocript - A complete tool for transcriptomes annotation
#Copyright (C) <2015> <Francesco Musacchia>
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
=head1 NAME
Annocript - A complete tool for transcriptomes annotation
=head1 SYNOPSIS
Annocript is a tool for the annotation of transcriptomes.
Please read carefully the user Readme and User Guide before to start executing it.
You must give in input the configuration file to run Annocript:
annocript.pl config_user.txt
=cut
=head1 OPTIONS
=over 8
=item B<--help>
Shows the brief help informations
=item B<--version>
Shows the version
=back
=cut
=head1 EXAMPLES
Write the config.txt file and give it in input to this script. In the config file you have to specify the locations of the data
that you want to manage.
The following is an example of call to this script:
annocript.pl config.txt
=cut
=head1 DESCRIPTION
Here you have the descriptions of the elements that you have to write on the file config.txt
=cut
=head1 AUTHORS
Francesco Musacchia
Swaraj Basu
Remo Sanges
--
http://www.szn.it
$Id: Annocript, 2015/14/19 11:00:12 Exp $
=cut
use strict;
use warnings;
use Data::Dumper;#To print the hashes
use Cwd;#To change work directory
#USE THE GENERAL UTILITY MODULES
use File::Copy;#To manage file
use FindBin;#To search libraries
use lib $FindBin::Bin;#To search libraries
use Term::ReadKey;
use Getopt::Long;#To control the input
use Pod::Usage;#Used to write an usage
use LWP::Simple;#Functions for FTP management
use File::Path qw(make_path remove_tree);#To remove directories
use IO::Handle;#To immediately print with autoflush
#Annocript libraries
use LIB::db_creator qw( execute_db_creator );
use LIB::execute_programs qw( execute_programs );
use LIB::programs_out_parser qw(execute_programs_out_parser);
use LIB::programs_management qw(log_and_exit print_and_log checkVariable initialize_folders
checkConfigVariables configFile2Hash);
use LIB::annocript_management qw(check_annocript_integrity check_input_fasta_file
valid_analysis check_uniref_presence check_programs_presence
uniprot_db_selection detect_gff_db check_db_tables_version
getDBVersion clean_cd_name nice_printing indexed_db_present);
use LIB::html_management qw(testFTP ftp_fetch_file check_FTP_diff_sources checkLink
check_url);
use LIB::mysql_db_management qw(check_DB_user_permissions db_present);
#Using a library to manage files
use LIB::files_management qw( extract_name check_presence);
#Using a library for standard utilities
use LIB::std_lib qw(num_processors ram_memory correct_type save_hash);
use LIB::utils qw(execute_utils);
#EXTRACT PARAMETERS FROM THE CONFIG FILE
my $configHash;#This hash holds up all the life of Annocript
my $program_name = "annocript.pl";
my $version = '2.0';
my $dbTablesVersion = '0.3';
my $user_config = "";
my $dataFolder = "data";
my $logFolder = "log";
my $lib_folder = "LIB";
my $analysesFolder = "analyses";
my $outFolder ="output";
my $gffFolder = "gff";
my $statsFolder = "stats";
my $tempTableFolder = 'tables';#Folder to keep the tables while they are being generated
my $usefulFolder = 'USEFUL';#A folder with useful scripts and data
my $workingFolder = '';#Folder where Annocript has to work
my $foldersFile = "folders.txt";
my $log_file = "";
my $timesFile = "";
#Variables present also in utils.pl (IF YOU CHANGE IT HERE CHANGE ALSO IN UTILS.PL!!)
my $mainDataFolder = "data";#Folder inside Annocript with all data needed more than one time
my $utilsScript = "USEFUL/utils.pl";
#We need these variables to check if the programs are present
my @blastProgramsInUse = qw( blastx
blastp
blastn
tblastn
rpstblastn
rpsblast
makeblastdb
blastdbcmd
);
#We need these variables to check if the files of the indexed cd database are present
my @cdFilesExts = qw(.rps .psq .psi .psd .pin .phr .loo .aux);
#Admitted database in use for conserved domains
my @cdDBAdmitted = qw(cd pfam kog cog tigr smart prk);
#NEW VARIABLES
my $config_folder = "CONFIGURATION";
my $program_config = "program_config.txt";#The path to the configuration file for the program
my $license_file = "COPYRIGHT";
my $license = "";
my $variables_file = "variables.txt";#The file with all the variables that must be present in the config files
my $analysisFolder = "";
my $analysis = "";
my $session = "";
my $exec_utils = 0;
my $utils = "";
my $program_folder = "";
my $working_folder = "";
my $uniref_db_ver = "";
my $force_run = "";
my $newSession = 0;
#Database selection
my $db_version = "";
my $db_type = "";
my $niceClosure = "\n=================================================\n";
my $configClosure = "\n*************************************************\n";
my $program_title = "***********************************************************************\n".
"This program comes with ABSOLUTELY NO WARRANTY; for details http://opensource.org/licenses/GPL-3.0.
This is free software, and you are welcome to redistribute it
under certain conditions; http://opensource.org/licenses/GPL-3.0 for details.\n".
"***********************************************************************\n".
" /&&&&&& /&& /&& \n".
" /&&__ && |__/ | && \n".
"| && | &&/&&&&&&& /&&&&&&& /&&&&&& /&&&&&&& /&&&&&& /&& /&&&&&& /&&&&&& \n".
"| &&&&&&&| &&__ &| &&__ && /&&__ &&/&&_____//&&__ &| &&/&&__ &|_ &&_/ \n".
"| &&__ &| && | &| && | &| && | &| && | && |__| &| && | && | && \n".
"| && | &| && | &| && | &| && | &| && | && | &| && | && | && /&& \n".
"| && | &| && | &| && | &| &&&&&&| &&&&&&| && | &| &&&&&&&/ | &&&&/ \n".
"|__/ |__|__/ |__|__/ |__/ |______/ |_______|__/ |__| &&____/ |___/ \n".
" | &&\n".
" | &&\n".
" |__/\n".
" \nGiven a fasta file with a transcriptome, Annocript will annotate your sequences and".
" it will separate putative coding and long non-coding RNA sequences.\n".
" Reference: Musacchia F, Basu S, Petrosino G, Salvemini M, Sanges R. \n".
" Annocript: a flexible pipeline for the annotation of transcriptomes which can also identify ".
" putative long non-coding RNA.".
" Bioinformatics (2015) doi:10.1093/bioinformatics/btv106".
"\n***********************************************************************\n\n\n";
######################################################### MAIN ########################################################
#LOG FILE CREATION
#Here we take the current time to get a log name different at each computation
my $time = scalar(localtime);
$time =~ s/ /_/g;
$time =~ s/:/-/g;
STDOUT->autoflush(1);#This makes STDOUT hot in the sense that everything will be print immediately
#Annocript permits both the usage of some utilities and the run of an analysis pipeline
#we set here the log file name depending on what is doing
if ( $utils ){
$log_file = "utils_$time.log";
}else{
$log_file = "annocript_exec_$time.log";
$timesFile = "annocript_times_$time.log";
}
#open the log file
my $logFHandle;
open($logFHandle, ">$log_file") or die "ERROR [$!]: Cannot open $log_file! Check permissions.\n";
# Parse command line arguments.
parse_command_line_args();
#If there is no utility to do, go ahed and check the input configuration file
if ( -e $user_config and $user_config ne ''){
print_and_log("\n\nPRELIMINARY CONFIGURATION...\n",$log_file);#DEBUGCODE
#Sets useful directories and stores the content of the configuration files
set_global_var_and_confighash($user_config);
#Checks folder and files if they are well written
print_and_log("Checking Annocript integrity...\n",$log_file);#DEBUGCODE
check_annocript_integrity($configHash,$log_file);
#Print license
if ( $license ){
print_file($program_folder."/".$license_file);
log_and_exit("Exiting..\n",$log_file);
}
#Utilities execution
if ( $utils ){
print_and_log("Executing utilities...\n",$log_file);#DEBUGCODE
execute_utils($program_config);
}else {
print_and_log("Checking input parameters...\n",$log_file);#DEBUGCODE
#Detect the analysis to use
check_input_parameters($analysis);
#Now that we have all the parameters and the analysis name
#I check all the parameters and configuration
configure_analysis();
#Saves the hash in a file to be used later
my $hashName = "configHash";
my $configHashPath = $dataFolder."/".$hashName;
save_hash($configHashPath,$configHash, $hashName);
my $newLogFile = $logFolder."/".$log_file;#Log of Annocript goes in the log folder
print_and_log( "Your configuration has been saved! A log file will be created in $logFolder/$log_file. \nThe overall computation usually"
." depends on the number of sequences and the speed of the machine you are using. \nYou may want to check Annocript step-by-step "
."with the following command: more ".$newLogFile.".\n"
."\nYou will find all the results in the folder you chose here. Please take a look at\n"
." https://github.com/frankMusacchia/Annocript/blob/master/GUIDE/OUTPUT.md to understand the output from Annocript and the"
." organization of folders."
."\n\nPlease let us know if any problem occurs during the computation or you don't get from Annocript the expected result.\n"
."You may want to use the forum at: https://groups.google.com/forum/#!forum/annocript.\n",$log_file);#DEBUGCODE
nice_printing("STARTING ANNOCRIPT IN BACKGROUND! BYE!",$log_file);
close ( $logFHandle );
#print "moving the file now...";
move($workingFolder.'/'.$log_file, $newLogFile) or log_and_exit(" Annocript will not move $workingFolder/$log_file to $newLogFile\n");
$log_file = $newLogFile;
$timesFile = $logFolder."/".$timesFile;#File with times goes inside the log folder
#We also remove all the other remaining log file in the folder created by user's interruptions
system("rm -f $workingFolder/annocript_exec_*");
#Copying the user config from working to analysis folder
(system("cp $user_config $analysisFolder") ) == 0
or log_and_exit("ERROR: Unable to copy $user_config in $analysisFolder. Please check permissions...\n",$log_file);
#Make the user config complete path
$user_config = $analysisFolder."/".$user_config;
#Go to program folder directory
chdir $program_folder;
#This perl script will be run in background
my $runAnnocriptCmd = "nohup perl ".$configHash->{'ProgExecFolder'} ."/annocript_executor.pl $user_config $program_config $timesFile $configHashPath >> $log_file &";
( system($runAnnocriptCmd) ) == 0
or die("Unable to start annocript_executor!\n");
}
}else{
log_and_exit("Cannot open configuration file. Please give a correct parameter for user_config! Exiting...\n",$log_file);
}
#########################################NEEDED ROUTINES
=head2 configure_analysis
Title : configure_analysis
Usage : configure_analysis( - configFilePath = path of the config file
);
Function: this subroutine completes the configuration of annocript:
- checks the variables with YES, NO values
- creates needed folders
- check variables related to the three modules (DB_CREATOR, PROGRAMS_EXEC, PROGRAMS_OUT_PARSER)
- build some important variables in the configuration hash
Returns : nothing
=cut
sub configure_analysis{
#Here I put a control of the variables in the configuration file that can be YES or NO
print_and_log ("\nAnnocript is going to run:\n",$log_file);
checkVariable($configHash->{'doDbCreation'},'doDbCreation', "\t-Database Creation.\n");
checkVariable($configHash->{'doExecutePrograms'},'doExecutePrograms', "\t-Execution of programs:\n");
if ($configHash->{'doExecutePrograms'} eq 'YES'){
checkVariable($configHash->{'doBlastxSP'},'doBlastxSP',"\t\tBLASTX against SwissProt.\n");
checkVariable($configHash->{'doBlastxTRorUf'},'doBlastxTRorUf',"\t\tBLASTX against TrEMBL/UniRef.\n");
checkVariable($configHash->{'doRpstblastn'},'doRpstblastn',"\t\tRPSBLAST against conserved domains database.\n");
checkVariable($configHash->{'doBlastn'},'doBlastn',"\t\tBLASTN against ncRNA.\n");
checkVariable($configHash->{'doLNCPrediction'},'doLNCPrediction',"\t\tlncRNA prediction. \n");
checkVariable($configHash->{'doDna2Pep'},'doDna2Pep',"\t\tLongest ORF search.\n");
}
checkVariable($configHash->{'doBuildOutput'},'doBuildOutput', "\tCreation of the final tabular output.\n");
checkVariable($configHash->{'extractStatistics'},'extractStatistics',"\tGeneration of statistics.\n\n");
checkVariable($configHash->{'useGFFDB'},'useGFFDB',"\tGFF3 database will be generated.\n");
checkVariable($configHash->{'printGFFOutput'},'printGFFOutput',"\tGFF3 files will be printed.\n");
#Checks everything regarding the query file. If session is new, the file is put in the session folder
$configHash->{'name'} = check_input_fasta_file($configHash->{'fastaSeqs'},\$configHash,$newSession,$workingFolder,$analysisFolder);
$dataFolder = $analysisFolder."/".$configHash-> {'dataFolder'};
#Check if directory DATA exists, otherwise it creates it
unless(-d $dataFolder){
print_and_log ("Creating folder $dataFolder...\n",$log_file);
mkdir $dataFolder or log_and_exit("ERROR: can't create folder $dataFolder. Check permissions. \n",$log_file);
}
$logFolder = $analysisFolder."/".$configHash-> {'logFolder'};
#Check if directory LOG exists, otherwise it creates it
unless(-d $logFolder){
print_and_log ("Creating folder $logFolder...\n",$log_file);
mkdir $logFolder or log_and_exit("ERROR: can't create folder $logFolder. Check permissions. \n",$log_file);
}
$outFolder = $analysisFolder."/".$configHash->{'outFolder'};
#Check if directory OUTPUT exists, otherwise it creates it
unless(-d $outFolder){
print_and_log ("Creating folder $outFolder....\n",$log_file);
mkdir $outFolder or log_and_exit("ERROR: can't create folder $outFolder. Check permissions. \n",$log_file);
}
$statsFolder = $analysisFolder."/".$configHash->{'statsFolder'};#Statistics folder
#Creation of a folder for the statistics
unless(-d $statsFolder){
print_and_log ("Creating folder $statsFolder...\n",$log_file);
mkdir $statsFolder or log_and_exit("ERROR: can't create folder $statsFolder. Check permissions. \n",$log_file);
}#else{print_and_log ("Folder $statsFolder already exists. Continuing...\n ",$log_file);}
$gffFolder = $analysisFolder."/".$configHash->{'gffFolder'};
#Check if directory for GFF files exists, otherwise it creates it
unless(-d $gffFolder){
print_and_log ("Creating folder ".$gffFolder."...\n",$log_file);
mkdir $gffFolder or log_and_exit( "ERROR : can't create folder $gffFolder. Check permissions. \n",$log_file);
}
#Check if directory for BLASTX output exists, otherwise it creates it
unless(-d $outFolder."/blastx"){
print_and_log ("Creating folder ".$outFolder."/blastx...\n",$log_file);
mkdir $outFolder."/blastx" or log_and_exit( "ERROR : can't create folder $outFolder /blastx. Check permissions. \n",$log_file);
}
#Check if directory for RPSTBLASTN output exists, otherwise it creates it
unless(-d $outFolder."/rpstblastn"){
print_and_log ("Creating folder ".$outFolder."/rpstblastn...\n",$log_file);
mkdir $outFolder."/rpstblastn" or log_and_exit( "ERROR : can't create folder $outFolder /rpstblastn . Check permissions. \n",$log_file);
}
#Check if directory for BLASTN output exists, otherwise it creates it
unless(-d $outFolder."/blastn"){
print_and_log ("Creating folder ".$outFolder."/blastn...\n",$log_file);
mkdir $outFolder."/blastn" or log_and_exit( "ERROR : can't create folder $outFolder /blastn. Check permissions. \n",$log_file);
}
#print_and_log (Dumper\$configHash,$log_file); #DEBUGCODE
$configHash->{'force_run'} = $force_run;
#The version of Annocript
$configHash->{'AnnocriptVer'} = $version;
$configHash->{'dbTablesVersion'} = $dbTablesVersion;
$configHash->{'usefulFolder'} = $usefulFolder;
$configHash->{'faSomeRecords'} = $program_folder."/$usefulFolder/".$configHash->{'faSomeRecords'};
#print_and_log ("\n>>> Database settings (it will need a while):\n",$log_file);
checkDB_CREATION();
#print_and_log ("\n>>> Programs settings:\n",$log_file);
checkPROGRAMS_EXEC();
#print_and_log ("\n>>> Setting final statistics and outputs\n",$log_file);
checkPROGRAMS_OUT_PARSER();
print_and_log ("...DONE!\n",$log_file);
my $dbDataFolder = $configHash->{'dbDataFolder'};
#Adding some variables for blast out types. This is done
#because if a day we want to add more types, nothing is to change in gff3_manager.pm
$configHash->{'blastxSPOutType'} = $configHash->{'blastOutType'};
$configHash->{'blastxTROutType'} = $configHash->{'blastOutType'};
$configHash->{'blastxUnirefOutType'} = $configHash->{'blastOutType'};
$configHash->{'rpstblastnOutType'} = $configHash->{'blastOutType'};
$configHash->{'blastnOutType'} = $configHash->{'blastOutType'};
#Writing the complete path (with datafolder) of the databases
$configHash->{'ncDB'} = "$dbDataFolder/".$configHash->{'ncDB'};
if ( $configHash->{'dbInUse'} eq "uniprotkb" ){
$configHash->{'swissProtDB'} = "$dbDataFolder/".$configHash->{'swissProtDB'};
$configHash->{'tremblDB'} = "$dbDataFolder/".$configHash->{'tremblDB'};
$configHash->{'uniprotKBDB'} = "$dbDataFolder/".$configHash->{'uniprotKBDB'};
}elsif ( $configHash->{'dbInUse'} eq "uniref" ){
$configHash->{'swissProtDB'} = "$dbDataFolder/".$configHash->{'swissProtDB'};
$configHash->{'unirefDB'} = "$dbDataFolder/".$configHash->{'unirefDB'};
}
#Now give to the output the names with the input fasta file name
my $preamble = $configHash->{'name'}.'_'.$configHash->{'dbInUse'}.'_'.$configHash->{'dbVersion'}.'_';
$configHash->{'outFileName'} = $preamble.$configHash->{'outFileName'};
$configHash->{'outFiltered'} = $preamble.$configHash->{'outFiltered'};
$configHash->{'ORFFastaFileName'} = $preamble.$configHash->{'ORFFastaFileName'};
$configHash->{'NCOutFile'} = $preamble.$configHash->{'NCOutFile'};
$configHash->{'codingOutFile'} = $preamble.$configHash->{'codingOutFile'};
#Setting paths for the stats image folder and the html pages
$configHash->{'imgDir'} = $preamble."statspage";
$configHash->{'imgPath'} = $statsFolder."/".$configHash->{'imgDir'};
#Check dependencies
check_dependencies();
}
=head2 check_dependencies
Title : check_dependencies
Usage : check_dependencies( - local folder = the folder where actually is the PROGRAMS_EXEC script
);
Function: Execute a set of controls on the output and presence of programs depending from the user choices
done in the configuration file.
Returns : nothing
=cut
sub check_dependencies {
#If the programs have to be executed paths are controlled and is checked if some outputs are present
if ($configHash->{'doExecutePrograms'} eq 'YES'){
#We check if in the blast out folders there is some BLAST output
if( ((scalar <$outFolder/rpstblastn/*>) or (scalar <$outFolder/blastx/*>) or (scalar <$outFolder/blastn/*>)) and ($force_run eq '')) {
log_and_exit("\n WARNING: Some output files already exist! If you will run a program (BLAST, lncRNAPrediction, DNA2PEP) the corresponding ".
"output must be overwritten. Please use the --force_run parameter then.... Exiting\n",$log_file);
}
#If programs will not be run and the user wants to print the final output table then a check is needed if outputs of programs
#are present
}elsif ( ($configHash->{'doExecutePrograms'} ne 'YES') and ($configHash->{'doBuildOutput'} eq 'YES') ){
if( !(scalar <$outFolder/rpstblastn/*>) and !(scalar <$outFolder/blastx/*>) and !(scalar <$outFolder/blastn/*>)) {
log_and_exit("Output folders are empty. The output from Annocript cannot be obtained without that.".
"Please chose doExecutePrograms = YES in the configuration file. Exiting...\n",$log_file);
}
#If only db creation is active we only check the presence of the makeblastdb program
}elsif ( $configHash->{'doDbCreation'} eq 'YES'){
if (!check_presence($configHash->{'makeblastdbPath'})){
log_and_exit("You miss makeblastdb. Please check the links in the configuration file or re-install the BLAST program. Exiting...\n",$log_file);
}
}
#If nothing is there in the folders we cannot start the output and stats creation
if ( ($configHash->{'extractStatistics'} eq 'YES') and (($configHash->{'doBuildOutput'} ne 'YES')) ){
if (!check_presence($outFolder.'/'.$configHash->{'outFiltered'})){
log_and_exit("You cannot start the statistics without the filtered ouput of Annocript. Please restart with doBuildOutput = YES\n",$log_file);
}
}
}
###############################Modules Execution checks
=head2 checkDB_CREATION
Title : checkDB_CREATION
Usage : checkDB_CREATION( - configHash = the piece of the config hash for DB_CREATION
- local folder = the folder where actually is the DB_CREATION script
);
Function: Checks the config hash parameters regardin the database creation and user. How they are written, if they are present and so on..
Returns : nothing
=cut
sub checkDB_CREATION {
my $wrongLinks = 0;
##########################CHECKING THE LINKS
if ($configHash->{'doDbCreation'} eq 'YES'){
#Check permissions. If the user does not have, he/she cannot create database or perform analyses
if (!check_DB_user_permissions($configHash->{'platform'},$configHash->{'host'},
$configHash->{'port'},$configHash->{'mySqlUser'},$configHash->{'mySqlPass'})) {
log_and_exit("ERROR: You do not have enough privileges to create the DB. Please ask your adiministrator. Annocript will close...\n",$log_file);
}
# print_and_log (Dumper\$configHash,$log_file);
#A check on email address
if ( !($configHash->{'uniprotWebPass'} =~ /@/) or !($configHash->{'uniprotWebPass'} =~ /\.[a-zA-Z]+?/) ){
log_and_exit( "ERROR : ".$configHash->{'uniprotWebPass'}." is not a correct email address. Please check it in config file \n",$log_file);
}
#Triple controls on the links. We need it three times because it can fail.
print_and_log ("Checking the links for the databases to download...(it may take a while)...\n",$log_file);
if (!check_url($configHash->{'swissprotDBLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'swissprotDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'swissprotDBLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'swissprotDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
}
if (!check_url($configHash->{'tremblDBLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'tremblDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'tremblDBLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'tremblDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
$wrongLinks++;
}
}
if (!check_url($configHash->{'uniprotVerLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'uniprotVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'uniprotVerLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'uniprotVerLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
}
if (!check_url($configHash->{'unirefDBLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'unirefDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'unirefDBLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'unirefDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
}
if (!check_url($configHash->{'unirefVerLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'unirefVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'unirefVerLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'unirefVerLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
}
if (!check_url($configHash->{'GODBLink'}) ) {
my $new_link = check_FTP_diff_sources($configHash->{'GODBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
if ( $new_link ne ''){
$configHash->{'GODBLink'} = $new_link;
}else{
print_and_log ("Please check if [".$configHash->{'GODBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
$wrongLinks++;
}
}
if (!check_url($configHash->{'enzymeDBLink'}) ) {
print_and_log ("Please check if [".$configHash->{'enzymeDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);#
$wrongLinks++;
}
if (!check_url($configHash->{'cdDBLink'})) {
annoPrint ("Please check if [".$configHash->{'cdDBLink'}."] is a correct URL. Annocript will continue...\n"); #
$wrongLinks++;
}
if (!check_url($configHash->{'cdTableLink'})) {
print_and_log ("Please check if [".$configHash->{'cdDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
if (!check_url($configHash->{'ncRNADBLink'})) {
print_and_log ("Please check if [".$configHash->{'ncRNADBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
$wrongLinks++;
}
if (!check_url($configHash->{'pathwaysTableLink'})) {
print_and_log ("Please check if [".$configHash->{'pathwaysTableLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
$wrongLinks++;
}
##This IFs contain the check of the links to the databases. Two types of check are present for links to the Uniprot data.
##LWP::Simple::Head and NET::Ftp
##print "Swiss-prot DB link...";
#if (!head($configHash->{'swissprotDBLink'}) ) {
#if (testFTP($configHash->{'swissprotDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'swissprotDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'swissprotDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'swissprotDBLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'swissprotDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#}
##print "Trembl DB link...";
#if (!head($configHash->{'tremblDBLink'}) ) {
#if (testFTP($configHash->{'tremblDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'tremblDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'tremblDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'tremblDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'tremblDBLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'tremblDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
#$wrongLinks++;
#}
#}
#}
#}
#}
##print "Uniprot DB version link...";
#if (!head($configHash->{'uniprotVerLink'}) ) {
#if (testFTP($configHash->{'uniprotVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'uniprotVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'uniprotVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'uniprotVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'uniprotVerLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'uniprotVerLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#}
#}
##print "UniRef DB link...";
#if (!head($configHash->{'unirefDBLink'}) ) {
#if (testFTP($configHash->{'unirefDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'unirefDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'unirefDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'unirefDBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'unirefDBLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'unirefDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#}
#}
##print "Uniref DB version link...";
#if (!head($configHash->{'unirefVerLink'}) ) {
#if (testFTP($configHash->{'unirefVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'unirefVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'unirefVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'unirefVerLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'unirefVerLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'unirefVerLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#}
#}
##print "Uniprot idmapping link...";
#if (!head($configHash->{'GODBLink'}) ) {
#if (testFTP($configHash->{'GODBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'GODBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#if (testFTP($configHash->{'GODBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'}) != 1) {
#my $new_link = check_FTP_diff_sources($configHash->{'GODBLink'}, $configHash->{'uniprotWebUser'}, $configHash->{'uniprotWebPass'});
#if ( $new_link ne ''){
#$configHash->{'GODBLink'} = $new_link;
#}else{
#print_and_log ("Please check if [".$configHash->{'GODBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
#$wrongLinks++;
#}
#}
#}
#}
#}
##Links that are not to Uniprot will use double time he Head function and finally the Net::FTP check
##NOT UNIPROT
#if (!head($configHash->{'enzymeDBLink'}) ) {
#if (!head($configHash->{'enzymeDBLink'})) {
#if (testFTP($configHash->{'enzymeDBLink'})!= 1) {
#print_and_log ("Please check if [".$configHash->{'enzymeDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);#
#$wrongLinks++;
#}
#}
#}
#if (!head($configHash->{'cdDBLink'})) {
#if (!head($configHash->{'cdDBLink'})) {
#if (testFTP($configHash->{'cdDBLink'}) != 1) {
#print_and_log ("Please check if [".$configHash->{'cdDBLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
##This link always has some more troubles... let's add one more check!
#if (!head($configHash->{'cdTableLink'})) {
#if (!head($configHash->{'cdTableLink'})) {
#if (!head($configHash->{'cdTableLink'})) {
#if (testFTP($configHash->{'cdTableLink'}) != 1) {
#print_and_log ("Please check if [".$configHash->{'cdTableLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#}
#if (!head($configHash->{'ncRNADBLink'})) {
#if (!head($configHash->{'ncRNADBLink'})) {
#if (testFTP($configHash->{'ncRNADBLink'}) != 1) {
#print_and_log ("Please check if [".$configHash->{'ncRNADBLink'}."] is a correct URL. Annocript will continue...\n",$log_file);
#$wrongLinks++;
#}
#}
#}
#if (!head($configHash->{'pathwaysTableLink'})) {
#if (!head($configHash->{'pathwaysTableLink'})) {
#if ( testFTP($configHash->{'pathwaysTableLink'}) != 1 ) {
#print_and_log ("Please check if [".$configHash->{'pathwaysTableLink'}."] is a correct URL. Annocript will continue...\n",$log_file); #
#$wrongLinks++;
#}
#}
#}
#If some check went wrong
if ($wrongLinks > 0){
my $text = "Since there is a problem with the connection, Annocript will try different kinds of downloads. Please try on a browser if the links above work".
" and then press y to continue.\n";
print_and_log($text,$log_file);#Print on the log file
}else{
print_and_log ("Everything is ok!\n",$log_file);
}
}
#This is a simple control that is done even if the database is not created. It is more simple and faster.
elsif (! (checkLink($configHash->{'ncRNADBLink'}) and checkLink($configHash->{'cdDBLink'}) and checkLink($configHash->{'enzymeDBLink'}) and
checkLink($configHash->{'GOTermsLink'}) and checkLink($configHash->{'GODBLink'})
and checkLink($configHash->{'unirefVerLink'}) and checkLink($configHash->{'uniprotkbVerLink'}) and checkLink($configHash->{'uniprotVerLink'})
# and checkLink($configHash->{'silvaLSULink'}) and checkLink($configHash->{'silvaSSULink'}) ) )
and checkLink($configHash->{'tremblDBLink'}) and checkLink($configHash->{'swissprotDBLink'}) ) ){
print_and_log ("Pay attention... you did some error in writing links in the configuration file. Please check it...\n",$log_file);
}elsif ( ($configHash->{'doBuildOutput'} eq 'YES') or ($configHash->{'doBuildOutput'} eq 'YES' )){
#The first check is on the permissions. If the user does not have, he cannot create database or perform analysis
if (!check_DB_user_permissions($configHash->{'platform'},$configHash->{'host'},
$configHash->{'port'},$configHash->{'mySqlUser'},$configHash->{'mySqlPass'})) {
log_and_exit("ERROR: You do not have enough privileges to create the DB. Please ask your adiministrator. Annocript will close...\n",$log_file);
}
}
# print_and_log ("Checking CD db..\n",$log_file);#DEBUGCODE
#Check if the database chose for the mostly expressed domains is correct
my $cdName4Expression = $configHash->{'cdName4Expression'};
#print "cdName4Expression : $cdName4Expression\n";
if ( !(grep {/$cdName4Expression/ } @cdDBAdmitted) ){
log_and_exit("Can't find CD database $cdName4Expression. You should "
."choose one among:\n ".print_array(\@cdDBAdmitted)."\nAnnocript will exit...\n",$log_file);
}
#Check on the log file for
# print_and_log ("Checking log files..\n",$log_file);#DEBUGCODE
if ( !($configHash->{'headParsNAValues'} =~ /\.log?/)){
log_and_exit( $configHash->{'headParsNAValues'}." is not a correct log file name. It must be something like: file.log\n",$log_file);
}
if ( !($configHash->{'uniprotGenesNotPresent'} =~ /\.log?/)){
log_and_exit( $configHash->{'uniprotGenesNotPresent'}." is not a correct log file name. It must be something like: file.log\n",$log_file);
}
#print_and_log ("Checking userid and pwd..\n",$log_file);#DEBUGCODE
#A check on the user-id and password: it can be of every type of character so
#it don't needs a particular control
if ( !(defined ($configHash->{'mySqlUser'})) or !(defined ($configHash->{'mySqlPass'}) ) ){
log_and_exit( "ERROR: You need to set an user-id and password for MySQL. Please contact your adiministrator".
" if you can't. Annocript will exit...\n",$log_file);
}#else{print_and_log ("MYSQL account: ".$configHash->{'mySqlUser'}." and pwd: ".$configHash->{'mySqlPass'}."\n",$log_file);}#DEBUGCODE
#A check on the parsing file path
if ( -e $dataFolder.$configHash->{'parsingFilePath'} ){
log_and_exit( "ERROR : File ".$configHash->{'parsingFilePath'}." already exists.\n",$log_file); #Please change the parsingFilePath in ".$configFilePath."\n";
}
#print_and_log ("Checking configuration..\n",$log_file);#DEBUGCODE
#If the user sets the config file to not execute the DB_CREATION, this means that nothing will
#be downloaded: the user has already a database.
my $dbDataFolder;
if ( $configHash->{'doDbCreation'} ne "YES"){
if( !(scalar <$mainDataFolder/*>) ){
log_and_exit( "ERROR: data folder is empty... You must run Annocript with doDbCreation = YES. Closing",$log_file);
}else{
#In the first case Annocript will ask to the user what folder to use as database
print_and_log ("DB Creation not active: Database will not be downloaded and installed.\n",$log_file);
$configHash->{'dbVersion'} = '';
#If the user wants to use a previous execution of softwares, then the database used can be
#only the one used before
if ( ($configHash->{'doExecutePrograms'} eq "NO") and
( ($configHash->{'doBuildOutput'} eq "YES") or ($configHash->{'extractStatistics'} eq "YES") ) ){
my $versions_file = $dataFolder."/".$configHash->{'versions_file'};
print "Checking versions used previously in file $versions_file\n";
#The database version is present in the version file
open (VER_F,"<$versions_file")
or die "Cannot open $versions_file. Maybe programs have not been executed before..\n";
while (my $row = <VER_F>){
if ( $row =~ /UniProt version/){
chomp($row);
$configHash->{'dbVersion'} = (split(":",$row))[1];
print_and_log("Version of the database used previously is ".$configHash->{'dbVersion'}.".\n",1,$log_file);
}
if ( $row =~ /UniProt database used/){
chomp($row);
$configHash->{'dbInUse'} = (split(":",$row))[1];
print_and_log( "UniProt database used previously is ".$configHash->{'dbInUse'}.".\n",$log_file);
}
if ( $row =~ /Domains database used/){
chomp($row);
$configHash->{'cdDB'} = (split(":",$row))[1];
print_and_log( "Domains database used previously is ".$configHash->{'cdDB'}.".\n",$log_file);
}
if ( $row =~ /UniRef type used/){
chomp($row);
$configHash->{'unirefDB'} = (split(":",$row))[1];
print_and_log( "UniRef version used is ".$configHash->{'unirefDB'}.".\n",$log_file);
}
}
close(VER_F);
if ( $configHash->{'dbInUse'} eq "uniref" ){
$configHash->{'versionDBLink'} = $configHash->{'unirefVerLink'};
}else{
$configHash->{'versionDBLink'} = $configHash->{'uniprotVerLink'};
}
#Check if database used is present
$configHash->{'database'} = $configHash->{'dbInUse'}.'_'.$configHash->{'dbVersion'};#Gives the name to the database
log_and_exit("Annocript cannot find the mysql database".$configHash->{'database'}."\n",$log_file) unless ( db_present($configHash->{'database'},$configHash->{'platform'},$configHash->{'host'},
$configHash->{'port'},$configHash->{'mySqlUser'},$configHash->{'mySqlPass'}) > 0);
print_and_log( "MySQL database in use is: ".$configHash->{'database'}."\n",$log_file);
$dbDataFolder = $mainDataFolder."/".$configHash->{'dbVersion'};
}elsif ( ($configHash->{'doExecutePrograms'} eq "NO") and
($configHash->{'doBuildOutput'} eq "NO") and ($configHash->{'extractStatistics'} eq "NO") ){
log_and_exit("You are running nothing! Please use the user guide to learn how to use Annocript.\n",$log_file);
}
#The user wants to execute the programs, therefore he can choose the database
if ($configHash->{'dbVersion'} eq ''){
if ( $db_version ne '' and $db_type ne ''){
my $dbName = "$db_type\_$db_version";
#Here we access the mysql system to see if the database is present
my $dbPresent = db_present($dbName,$configHash->{'platform'},$configHash->{'host'},
$configHash->{'port'},$configHash->{'mySqlUser'},$configHash->{'mySqlPass'});
if ( $dbPresent > 0){
#Gives the name to the database
$configHash->{'database'} = $dbName;
$configHash->{'dbInUse'} = $db_type;
$configHash->{'dbVersion'} = $db_version;
#The CD database if it is present
$configHash->{'cdDB'} = "Cdd";#choose_CD_database($dbDataFolder);
if ( $configHash->{'dbInUse'} eq "uniref" ){
$configHash->{'versionDBLink'} = $configHash->{'unirefVerLink'};
}else{
$configHash->{'versionDBLink'} = $configHash->{'uniprotVerLink'};
}
$dbDataFolder = $mainDataFolder."/".$configHash->{'dbVersion'};
if ($uniref_db_ver eq ''){
$uniref_db_ver = extract_name($configHash->{'unirefDBLink'},1);
$configHash->{'unirefDB'} = $uniref_db_ver.".fasta";
}else{
$configHash->{'unirefDB'} = $db_type.$uniref_db_ver.".fasta";
}
}
}else{
log_and_exit("WARNING: You must choose an UniProt version of database among those you already have with --db_version. Exiting\n",$log_file);
}
}
#We store the names for all the database. They will not be downloaded but we need them later
$configHash->{'tremblDB'} = extract_name($configHash->{'tremblDBLink'},'gz');
$configHash->{'swissProtDB'} = extract_name($configHash->{'swissprotDBLink'},'gz');
$configHash->{'cdDBPath'} = $dbDataFolder."/".$configHash->{'cdDB'};
$configHash->{'uniprotKBDB'} = "uniprot_kb_".$configHash->{'dbVersion'}.".fasta";#Creates the name for the uniprot kb
#Here I do a cross check. If the version of the database used does not correspond
#with the database chosen to use, it will give an error
my $dsn = "dbi:".$configHash->{'platform'}.":".$configHash->{'database'}.":".$configHash->{'host'}.":".$configHash->{'port'};
check_db_tables_version($dsn,$configHash->{'mySqlUser'},$configHash->{'mySqlPass'},$dbTablesVersion)
or log_and_exit( "The version of the database you selected is not compatible with this version of Annocript ($version) ".
" Please choose another or create a completely new database. Exiting...\n",$log_file);
#Then do many checks on the indexed databases and on the choose of a single or many organisms but only
#if the user wants to execute analyses, otherwise it does not matter
if ($configHash->{'doExecutePrograms'} eq 'YES'){
#Changing the database name if a single organism is to be used, only when using TrEMBL
if ( ($configHash->{'blastedOrganism'} ne 'all') and ($configHash->{'dbInUse'} eq "uniprotkb") ){
#If the file with the sequences exists in the working folder...
if (-e $workingFolder.'/'.$configHash->{'blastedOrganism'}){
my $blOrg = extract_name($configHash->{'blastedOrganism'},0);
$configHash->{'tremblDB'} = "TR_$blOrg.fasta";
$configHash->{'swissProtDB'} = "SP_$blOrg.fasta";
#check if there is a file named in same way in the folder. if it is there, the user is alerted
if (-e $dbDataFolder."/".$configHash->{'tremblDB'}){
print_and_log( "The indexed database named ".$configHash->{'tremblDB'}." is present in".
" $dbDataFolder. Annocript will use it or overwrite if not complete...\n",$log_file);
}
if (-e $dbDataFolder."/".$configHash->{'swissProtDB'}){
print_and_log( "The indexed database named ".$configHash->{'swissProtDB'}." is present in".
" $dbDataFolder. Annocript will use it or overwrite if not complete...\n",$log_file);
}
copy($workingFolder.'/'.$configHash->{'blastedOrganism'},$dbDataFolder.'/'.$configHash->{'blastedOrganism'});
}else{
log_and_exit("There is no file named ".$configHash->{'blastedOrganism'}." in $workingFolder. Please".
" check you wrote a correct name in the config file and that the file with organisms names is in your".
" working folder. If you want to blast against all organisms please change the value with 'all'. \n",$log_file);
}
}elsif( ($configHash->{'blastedOrganism'} ne 'all') and ($configHash->{'dbInUse'} eq "uniref")){
log_and_exit("When using UniRef all the organisms will be evalutated for the blast. If you want to blast against ".
" specific organisms you should use TrEMBL.\n",$log_file);
}
#Check on the databases. The index file should be present, otherwise the user will be alerted that
#he should start dbCreation procedure
if ($configHash->{'dbInUse'} eq "uniprotkb"){
if ( (indexed_db_present($configHash->{'tremblDB'}, "blastIndexedExts",$dbDataFolder) == 0) ){
log_and_exit("Database ".$configHash->{'tremblDB'}." is not indexed. Please restart annocript with doDbCreation=YES".
"or change the parameter blastedOrganism in your configuration file if you want to use a previously created ".
" database of organisms\n",$log_file);
}
}
if ($configHash->{'dbInUse'} eq "uniref"){