-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_pipeline.pl
executable file
·3304 lines (2525 loc) · 93.9 KB
/
run_pipeline.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
=pod
=head1 NAME
run_pipeline.pl - Execute GreenPhyl pipeline
=head1 SYNOPSIS
run_pipeline.pl
=head1 REQUIRES
Perl5
=head1 DESCRIPTION
This script runs the GreenPhyl phylogeny pipeline. It takes as input a
multiple sequence FASTA file and computes a phylogeny analysis.
=cut
use strict;
use Carp qw (cluck confess croak);
use warnings;
use Getopt::Long;
use Pod::Usage;
use Error qw(:try);
use Fatal qw (open close);
use Cwd qw(abs_path getcwd);
use threads;
use threads::shared;
use Bio::SeqIO;
use Bio::AlignIO;
use Bio::TreeIO;
use Bio::LocatableSeq;
use Bio::SimpleAlign;
use GreenPhylConfig;
# Script global constants
##########################
=pod
=head1 CONSTANTS
B<$GREENPHYL_NAME>: (string)
name (displayed) of the pipeline.
B<$GREENPHYL_GROUP_ID>: (integer)
Unix group ID of GreenPhyl group. The valud can be obtained using the command:
% perl -e 'print [getgrnam('greenphyl')]->[2] . "\n";'
B<$DEFAULT_ADMIN_EMAIL>: (string)
e-mail address used as sender for notification e-mails.
B<$FIRST_COLUMN_WIDTH>: (integer)
number of characters in the first column in screen reports.
B<$INDENTATION>: (integer)
number of spaces to use for indentation.
B<$INPUT_FILE_EXTENSION>: (string)
file extension used for input files.
B<$OUTPUT_FILE_EXTENSION>: (string)
file extension used by output files.
B<$DICTIONARY_FILE_EXTENSION>: (string)
file extension used by dictionaries.
B<$MAFFT_FILE_EXTENSION>: (string)
file extension for MAFFT alignment file.
B<$HMM_FILE_EXTENSION>: (string)
file extension for HMM file.
B<$CLUSTAL_FILE_EXTENSION>: (string)
file extension for CLUSTAL files.
B<$MASKING_FILE_EXTENSION>: (string)
file extension for masked alignment files.
B<$FILTERING_FILE_EXTENSION>: (string)
file extension for filtered alignment files.
B<$BSP_MASKING_FILE_EXTENSION>: (string)
file extension for bsp masked alignment files.
B<$PHYLIP_FILE_EXTENSION>: (string)
file extension for phylip alignment files.
B<$NEWICK_FILE_EXTENSION>: (string)
file extension for newick tree files.
B<$NEWICK_EXTENDED_FILE_EXTENSION>: (string)
file extension for extended newick tree files.
B<$PHYLIP_SCRIPT_FILENAME>: (string)
script file name used to issue command to PHYLIP programs.
B<$PHYLIP_OUTTREE_FILENAME>: (string)
name of the output file for tree (PHYLIP package).
B<$PHYML_TREE_FILE_SUFFIX>: (string)
suffix of the file name used by PhyML for phylogeny tree.
Note: name is imposed by PhyML program.
B<$PHYML_BOOTSTRAP_FILE_SUFFIX>: (string)
suffix of the file name used by PhyML for bootstrap trees.
Note: name is imposed by PhyML program.
B<$PHYML_DISTANCE_MATRIX_FILE_SUFFIX>: (string)
suffix of the file name used by PhyML for distance matrix.
Note: name is imposed by PhyML program.
B<$PHYLOGENY_FILE_SUFFIX>: (string)
name of phylogeny tree.
B<$SDI_OUTPUT_FILE_EXT>: (string)
SDI output file name.
B<$BOOTSTRAP_TREE_FILENAME_SEED>: (string)
seed for bootstrap filenames.
B<$RIO_OUTPUT_FILE_SEED>: (string)
RIO output file name seed used to generate other names.
B<$RIO_DATA_OUTPUT_FILE_EXTENSION>: (string)
RIO output data file extension.
B<$RIO_TREE_OUTPUT_FILE_EXTENSION>: (string)
RIO output tree file extension.
B<$STEP_ALIGNMENT>: (string)
alignment step short name.
B<$STEP_HMM>: (string)
HMM step short name.
B<$STEP_MASKING>: (string)
masking step short name.
B<$STEP_PHYLOGENY>: (string)
phylogeny step short name.
B<$STEP_TREE_ROOTING>: (string)
tree rooting step short name.
B<$STEP_RESAMPLE_INFERENCE_OF_ORTHOLOGY>: (string)
inference of orthologs step short name.
=cut
our $GREENPHYL_NAME = 'GreenPhyl';
our $GREENPHYL_GROUP_ID = 33462;
our $DEFAULT_ADMIN_EMAIL = 'guignon@cirad.fr';
our $FIRST_COLUMN_WIDTH = 30;
our $INDENTATION = 4;
our $INPUT_FILE_EXTENSION = '.src';
our $OUTPUT_FILE_EXTENSION = '.out';
our $DICTIONARY_FILE_EXTENSION = '.dic';
our $FASTA_FILE_EXTENSION = '.fasta';
our $MAFFT_FILE_EXTENSION = '.mafft';
our $HMM_FILE_EXTENSION = '.hmm';
our $CLUSTAL_FILE_EXTENSION = '.clw';
our $MASKING_FILE_EXTENSION = '.mask';
our $FILTERING_FILE_EXTENSION = '.fltr';
our $BSP_MASKING_FILE_EXTENSION = '.bsp';
our $MASKING_HTML_FILE_EXTENSION = "_masking.html";
our $FILTERED_HTML_FILE_EXTENSION = "_filtered.html";
our $FILTERED_SEQ_FILE_EXTENSION = "_filtered.seq";
our $PHYLIP_FILE_EXTENSION = '.phy';
our $NEWICK_FILE_EXTENSION = '.nwk';
our $NEWICK_EXTENDED_FILE_EXTENSION = '.nhx';
our $PHYLOXML_FILE_EXTENSION = '.xml';
our $PHYLIP_SCRIPT_FILENAME = 'phylip.script';
our $PHYLIP_OUTTREE_FILENAME = 'outtree';
our $PHYML_TREE_FILE_SUFFIX = '_phyml_tree'; # do not change: see doc
our $PHYML_BOOTSTRAP_FILE_SUFFIX = '_phyml_boot_trees'; # do not change: see doc
our $PHYML_DISTANCE_MATRIX_FILE_SUFFIX = '_phyml_dist.txt'; # do not change: see doc
our $PHYLOGENY_FILE_SUFFIX = '_phylogeny_tree' . $NEWICK_FILE_EXTENSION;
our $ROOTED_TREE_FILE_SUFFIX = '_rap_gene_tree' . $NEWICK_FILE_EXTENSION;
our $RECONCILIED_TREE_FILE_SUFFIX = '_rap_reconcilied_gene_tree' . $NEWICK_FILE_EXTENSION;
our $STATS_TREE_FILE_SUFFIX = '_rap_stats_tree.txt';
our $XML_TREE_FILE_SUFFIX = '_rap_tree.xml';
our $SDI_OUTPUT_FILE = 'sdir_outfile.xml';
our $SDI_OUTPUT_FILE_EXT = '.sdi.xml';
our $BOOTSTRAP_TREE_FILENAME_SEED = 'bootstrap_';
our $RIO_OUTPUT_FILE_SEED = 'rio_';
our $RIO_DATA_OUTPUT_FILE_EXTENSION = '.txt';
our $RIO_TREE_OUTPUT_FILE_EXTENSION = '.xml';
our $STEP_ALIGNMENT = 'alignment';
our $STEP_HMM = 'hmm';
our $STEP_MASKING = 'masking';
our $STEP_PHYLOGENY = 'phylogeny';
our $STEP_TREE_ROOTING = 'rooting';
our $STEP_RESAMPLE_INFERENCE_OF_ORTHOLOGY = 'orthology';
our $SPECIES_CODE_REGEXP = '_[A-Z0-9]{3,5}';
# Script global variables
##########################
=pod
=head1 VARIABLES
B<$g_debug>: (boolean)
debug mode flag. Set to 1 when "-debug" command line parameter is used.
Default: 0 (false)
B<$g_output_dir>: (string)
path of the output directory where computation should be operated.
B<$g_sequences_count>: (integer)
number of sequence in the source FASTA file.
B<$g_main_filename>: (string)
main file name without any extension.
B<$g_resume>: (string)
if set, resume an analyse from the specified step. Allowed steps are:
'alignment', 'masking', 'phylogeny', 'rooting', 'rio'.
B<$g_autoresume>: (string)
if set, only start a step if its outputs are missing. Default: no auto-resume.
B<$g_end>: (string)
if set, the anlyse will stop after the specified step.
=cut
our $g_debug = 1;
# working directory path
our $g_output_dir = $GreenPhylConfig::OUTPUT_PATH;
our $g_sequences_count = 0;
our $g_main_filename = '';
our $g_resume = $STEP_ALIGNMENT;
our $g_autoresume = 0;
our $g_end = $STEP_RESAMPLE_INFERENCE_OF_ORTHOLOGY;
our $gs_thread_messages :shared;
our $g_stdout = \*STDOUT;
our $g_stderr = \*STDERR;
# Script global functions
##########################
=pod
=head1 FUNCTIONS
=head2 printWarning
B<Description>: display a warning message on STDERR.
B<ArgsCount>: 1
=over 4
=item $message: (string) (R)
warning message to display.
=back
B<Example>:
printWarning("the file $filename has been replaced!\nYou have been warned!");
=cut
sub printWarning
{
my ($message) = @_;
# check arguments
if (1 != @_)
{
confess "usage: printWarning(message);";
}
# remove trailing invisible characters
$message =~ s/\s+$//s;
print {$g_stderr} "\n";
# check for multi-lines warning
if ($message =~ m/[\r\n]/)
{
# multi-lines
my @message_lines = split(/(?:\n|\r\n|\r)/, $message);
print {$g_stderr} "WARNING: " . shift(@message_lines) . "\n ";
print {$g_stderr} join("\n ", @message_lines);
print {$g_stderr} "\n";
}
else
{
# single line
print {$g_stderr} "WARNING: " . $message . "\n";
}
return;
}
=pod
=head2 printError
B<Description>: display an error message on STDERR.
B<ArgsCount>: 1
=over 4
=item $message: (string) (R)
error message to display.
=back
B<Example>:
printError("Computation failed!");
=cut
sub printError
{
my ($message) = @_;
# check arguments
if (1 != @_)
{
confess "usage: printError(message);";
}
# remove trailing invisible characters
$message =~ s/\s+$//s;
print {$g_stderr} "\n";
# check for multi-lines warning
if ($message =~ m/[\r\n]/)
{
# multi-lines
my @message_lines = split(/(?:\n|\r\n|\r)/, $message);
print {$g_stderr} "ERROR: " . shift(@message_lines) . "\n ";
print {$g_stderr} join("\n ", @message_lines);
print {$g_stderr} "\n\n";
}
else
{
# single line
print {$g_stderr} "ERROR: " . $message . "\n\n";
}
return;
}
=pod
=head2 printDebug
B<Description>: display a debug message on STDERR if debug mode is ON.
B<ArgsCount>: 1
=over 4
=item $message: (string) (R)
debug message to display.
=back
B<Example>:
printDebug("Starting the process using paramaters:!\na=25\nb=50\nc=3");
=cut
sub printDebug
{
my ($message) = @_;
# check arguments
if (1 != @_)
{
confess "usage: printDebug(message);";
}
# check if debugging is disabled
if (!$g_debug)
{
#debugging disabled, nothing to do!
return;
}
# remove trailing invisible characters
$message =~ s/\s+$//s;
print {$g_stderr} "\n";
# check for multi-lines warning
if ($message =~ m/[\r\n]/)
{
# multi-lines
my @message_lines = split(/(?:\n|\r\n|\r)/, $message);
print {$g_stderr} "DEBUG: " . shift(@message_lines) . "\n ";
print {$g_stderr} join("\n ", @message_lines);
print {$g_stderr} "\n";
}
else
{
# single line
print {$g_stderr} "DEBUG: " . $message . "\n";
}
return;
}
=pod
=head2 printStageStart
B<Description>: display the name of a stage when started.
B<ArgsCount>: 1
=over 4
=item $stage_name: (string) (R)
Name of the stage without any EOL character.
=back
B<Example>:
printStageStart('Alignment');
=cut
sub printStageStart
{
my ($stage_name) = @_;
# check arguments
if (1 != @_)
{
confess "usage: printStageStart(stage_name);";
}
# compute spaces to add
my $reminding_spaces_count = $FIRST_COLUMN_WIDTH - $INDENTATION - length($stage_name);
if (0 > $reminding_spaces_count)
{
$reminding_spaces_count = 0;
}
print {$g_stdout} ' ' x $INDENTATION . $stage_name . '.' x $reminding_spaces_count;
# in case of debug mode, add a line-feed
if ($g_debug)
{
print {$g_stderr} "\n"; #
}
}
=pod
=head2 printStageEnd
B<Description>: display the status of a stage when terminating.
B<ArgsCount>: 1
=over 4
=item $status: (string) (R)
Status of the stage execution.
=back
B<Example>:
printStageEnd('OK');
=cut
sub printStageEnd
{
my ($status) = @_;
# check arguments
if (1 != @_)
{
confess "usage: printStageEnd(status);";
}
# indent if debug mode
if ($g_debug)
{
print {$g_stdout} ' ' x $FIRST_COLUMN_WIDTH;
}
# remove trailing invisible characters
$status =~ s/\s+$//s;
print {$g_stdout} $status . "\n";
}
=pod
=head2 executeMAFFT
B<Description>: execute MAFFT alignment program on the given FASTA input
file and returns the alignment.
B<ArgsCount>: 1
=over 4
=item $input_filename: (string) (R)
the path to the input FASTA file (not aligned).
=back
B<Return>: (string)
the alignment filename.
B<Exception>:
B<Example>:
my $alignment_filename = executeMAFFT("sequences.fasta");
=cut
sub executeMAFFT
{
my ($input_filename) = @_;
# parameters check
if (1 != @_)
{
confess "usage: executeMAFFT(input_fasta_name);";
}
# check if a filename was provided
if (not $input_filename)
{
confess "Input file name is missing!";
}
# make sure the infile exists and is readable
if (not -r $input_filename)
{
confess "Unable to read file '$input_filename'!";
}
# display stage start
printStageStart("Alignment (MAFFT)");
# set up the output file name
my $alignment_filename = $g_main_filename . $MAFFT_FILE_EXTENSION;
# make sure the output file does not exist
if (-e $alignment_filename)
{
printWarning("MAFFT: existing output file \"$alignment_filename\" will be replaced!");
unlink $alignment_filename;
}
# prepare environment
$ENV{'MAFFT_BINARIES'} = $GreenPhylConfig::MAFFT_BINARY_PATH;
# adjust command line parameters
my $cmd = $GreenPhylConfig::MAFFT_CMD;
if ((2 < $g_sequences_count) && ($g_sequences_count <= 200))
{
printDebug("MAFFT parameters einsi maxiterate 1000");
$cmd = "$GreenPhylConfig::MAFFT_CMD --ep 0 --maxiterate 1000 --genafpair $input_filename >$alignment_filename 2>$g_main_filename$GreenPhylConfig::MAFFT_LOG_FILENAME";
}
elsif ((200 < $g_sequences_count) && ($g_sequences_count <= 500))
{
printDebug("MAFFT parameters einsi maxiterate 1");
$cmd = "$GreenPhylConfig::MAFFT_CMD --maxiterate 1 $input_filename >$alignment_filename 2>$g_main_filename$GreenPhylConfig::MAFFT_LOG_FILENAME";
}
elsif ((500 < $g_sequences_count) && ($g_sequences_count <= 10000))
{
printDebug("MAFFT FFTNS");
$cmd = "$GreenPhylConfig::MAFFT_FFTNS_CMD --ep 0 $input_filename >$alignment_filename 2>$g_main_filename$GreenPhylConfig::MAFFT_LOG_FILENAME";
}
# remove previous error logs
unlink "$g_output_dir/mafft_err.log";
# run MAFFT
printDebug("COMMAND: $cmd");
if (0 != system($cmd))
{
if (not $!)
{
confess "MAFFT: see logs ($g_main_filename$GreenPhylConfig::MAFFT_LOG_FILENAME) for errors.";
}
confess "MAFFT: $!";
}
# check if we got an output alignment
if (-s $alignment_filename)
{
printStageEnd("OK");
}
else
{
printStageEnd("Failed!");
if (-e $alignment_filename)
{
confess "Failed to compute alignment: alignment file '$alignment_filename' was empty!";
}
else
{
confess "Failed to compute alignment: alignment file '$alignment_filename' was missing!";
}
}
return $alignment_filename;
}
=pod
=head2 getMAFFTOutput
B<Description>: returns file names generated by MAFFT alignment program.
B<ArgsCount>: 1
=over 4
=item $input_filename: (string) (R)
the path to the input FASTA file (not aligned).
=back
B<Return>: (string)
the alignment filename.
B<Exception>:
B<Example>:
my $alignment_filename = getMAFFTOutput("sequences.fasta");
=cut
sub getMAFFTOutput
{
my ($input_filename) = @_;
# parameters check
if (1 != @_)
{
confess "usage: getMAFFTOutput(input_fasta_name);";
}
# check if a filename was provided
if (not $input_filename)
{
confess "Input file name is missing!";
}
return $g_main_filename . $MAFFT_FILE_EXTENSION;
}
=pod
=head2 executeHMMBUILD
B<Description>: execute HMMBUILD program on MAFTT output
file and returns the Hmm.
B<ArgsCount>: 2
=over 4
=item $input_filename: (string) (R)
the path to the input MAFFT file (aligned).
=back
B<Return>: (string)
the hmm filename.
B<Exception>:
B<Example>:
my $hmm_filename = executeHMMBUILD("output.mafft");
=cut
sub executeHMMBUILD
{
my ($input_filename) = @_;
# parameters check
if (1 != @_)
{
confess "usage: executeHMMBUILD(output.mafft);";
}
# check if a filename was provided
if (not $input_filename)
{
confess "Input file name is missing!";
}
# make sure the infile exists and is readable
if (not -r $input_filename )
{
confess "Unable to read file '$input_filename'!";
}
# display stage start
#printStageStart("HMM (HMMBUILD)");
# set up the output file name
my $hmm_filename = getHMMBUILDOutput($input_filename);
# make sure the output file does not exist
if (-e $hmm_filename)
{
printWarning("HMMBUILD: existing output file \"$hmm_filename\" will be replaced!");
unlink $hmm_filename;
}
# adjust command line parameters
# my $cmd = "$GreenPhylConfig::HMMBUILD_CMD --informat afa $hmm_filename $input_filename 1>$g_main_filename$GreenPhylConfig::HMMBUILD_LOG_FILENAME 2>>$g_main_filename$GreenPhylConfig::HMMBUILD_LOG_FILENAME";
my $cmd = "$GreenPhylConfig::HMMBUILD_CMD $hmm_filename $input_filename 1>$g_main_filename$GreenPhylConfig::HMMBUILD_LOG_FILENAME 2>>$g_main_filename$GreenPhylConfig::HMMBUILD_LOG_FILENAME";
# run HMMBUILD
printDebug("COMMAND: $cmd");
if (0 != system($cmd))
{
if (not $!)
{
confess "HMMBUILD: see logs ($g_main_filename$GreenPhylConfig::HMMBUILD_LOG_FILENAME) for errors.";
}
confess "HMMBUILD: $!";
}
# check if we got an hmm output
printStageStart("HMM (HMMBUILD)");
if (-s $hmm_filename)
{
printStageEnd("OK");
}
else
{
printStageEnd("Failed!");
if (-e $hmm_filename)
{
confess "Failed to compute hmm: hmm file '$hmm_filename' was empty!";
}
else
{
confess "Failed to compute hmm: hmm file '$hmm_filename' was missing!";
}
}
return $hmm_filename;
}
=pod
=head2 getHMMBUILDOutput
B<Description>: returns file names generated by HMMBUILD program.
B<ArgsCount>: 1
=over 4
=item $input_filename: (string) (R)
the path to the alignment file (mafft output).
=back
B<Return>: (string)
the hmm filename.
B<Exception>:
B<Example>:
my $hmm_filename = getHMMBUILDOutput("alignment.mafft");
=cut
sub getHMMBUILDOutput
{
my ($input_filename) = @_;
# parameters check
if (1 != @_)
{
confess "usage: getHMMBUILDOutput(input_alignment_name);";
}
# check if a filename was provided
if (not $input_filename)
{
confess "Input file name is missing!";
}
return $g_main_filename . $HMM_FILE_EXTENSION;
}
=pod
=head2 executeRefiner
B<Description>: [function description]. #+++
B<ArgsCount>: [count of arguments] #+++
=over 4
=item variable_name: ([variable nature]) ([requirements]) #+++ see below
#--- requirement can be:
#--- (R)=required,
#--- (O)=optional
#--- (U)=optional and must be undef if omitted
[variable description]. #+++
=item variable_name2: ([variable nature]) ([requirements]) #+++
[variable description]. #+++
=back
B<Return>: ([return type]) #+++
[return description]. #+++
B<Exception>:
=over 4
[=item * exception_type:
description, case when it occurs.] #+++ see below
=back
#--- Example:
#---
#---=over 4
#---
#---=item * Range error:
#---
#---thrown when "argument x" is outside the supported range, for instance "-1".
#---
#---=back
B<Example>:
my $refined_alignment_filename = executeRefiner("alignment.fasta");
=cut
sub executeRefiner
{
my ($input_filename) = @_;
# parameters check
if (1 != @_)
{
confess "usage: executeRefiner(input_alignment_name);";
}
# check if a filename was provided
if (not $input_filename)
{
confess "Input file name is missing!";
}
# make sure the infile exists and is readable
if (not -r $input_filename )
{
confess "Unable to read file '$input_filename'!";
}
printStageStart("Refiner (GBlocks)");
# my $gblocks_outfile = $input_filename . "-gb";
# $cmd = join(" ",$GreenPhylConfig::GBLOCKS_CMD, $outfile, "-t=p ", "1>$g_output_dir/mask4.log", "2>$g_output_dir/mask4_err.log"); #+val
#+val: less stringent: $cmd = join(" ",$GreenPhylConfig::GBLOCKS_CMD, $outfile, "-t=p -b4=5 -b5=h", "1>$g_output_dir/mask4.log", "2>$g_output_dir/mask4_err.log"); #+val
#+val: even less stringent: $cmd = join(" ",$GreenPhylConfig::GBLOCKS_CMD, $outfile, "-t=p -b4=2 -b5=a", "1>$g_output_dir/mask4.log", "2>$g_output_dir/mask4_err.log"); #+val
#+val: WARNING: sometimes, Gblocks does not find any relevant blocks and returns an empty alignment!
#+val: WARNING: sometimes, Gblocks selects a very small part of the original alignment and such a refined alignment may not be relevant!
#+val: therefore, the amount of selected position should be checked (above a minimum % of positions) before running into the next step and the refined alignment my have to be discarded
# my $outfile = $gblocks_outfile;
my $output_filename = $input_filename;
printStageEnd("Not implemented!");
return $output_filename;
}
=pod
=head2 executeMaskingAndFiltering
B<Description>: remove some columns of the alignment.
B<ArgsCount>: 1
=over 4
=item $input_filename: (string) (R)
input alignment file name (FASTA format).
=back
B<Return>: (list of string)
the name of the masked alignment file, the FASTA version of that file and the
name of the filtered sequence file.
...
B<Example>:
my ($output_filename, $filtered_fasta_alignment_filename, $filtered_seq_filename, $output_mask_filename1, $output_mask_filename2, $output_mask_filename3, $bsp_filename1, $bsp_filename2, $masking_html_filename1, $masking_html_filename2, $filtered_html_filename) = executeMaskingAndFiltering("alignment.fasta");
=cut
sub executeMaskingAndFiltering