Repository navigation
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·861 lines (731 loc) · 23.2 KB
/
Copy pathconfigure
File metadata and controls
executable file
·861 lines (731 loc) · 23.2 KB
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
#!/usr/bin/env perl
##---------------------------------------------------------------------------##
## File:
## @(#) configure
## Author:
## Robert Hubley <rhubley@systemsbiology.org>
## Description:
## Configuration utility for the RepeatModeler package.
##
#******************************************************************************
#* Copyright (C) Institute for Systems Biology 2003-2025 Developed by
#* Arian Smit and Robert Hubley.
#*
#* This work is licensed under the Open Source License v2.1. To view a copy
#* of this license, visit http://www.opensource.org/licenses/osl-2.1.php or
#* see the license.txt file contained in this distribution.
#*
###############################################################################
=head1 NAME
configure - Configure the RepeatModeler package
=head1 SYNOPSIS
perl ./configure [options]
=head1 DESCRIPTION
Interactive configuration script for RepeatModeler.
Run from inside the RepeatModeler installation directory.
=head1 OPTIONS
=over 4
=item -perlbin <path>
Path to the perl interpreter to embed in script headers.
=item -repeatmasker_dir <path>
Path to the RepeatMasker installation directory.
=item -famdb_dir <path>
Path to the FamDB installation directory (containing famdb.py).
=item -rmblast_dir <path>
Path to the RMBlast bin directory.
=item -rscout_dir <path>
Path to the RepeatScout installation directory.
=item -recon_dir <path>
Path to the RECON installation directory.
=item -repeatafterme_dir <path>
Path to the RepeatAfterMe installation directory.
=item -trf_dir <path>
Path to the directory containing the trf executable.
=item -cdhit_dir <path>
Path to the CD-HIT installation directory.
=item -ucsctools_dir <path>
Path to the UCSC TwoBit tools directory.
=item -genometools_dir <path>
Path to the GenomeTools bin directory (optional, for LTR pipeline).
=item -ltr_retriever_dir <path>
Path to the LTR_Retriever installation directory (optional, for LTR pipeline).
=item -mafft_dir <path>
Path to the MAFFT bin directory (optional, for LTR pipeline).
=item -ninja_dir <path>
Path to the Ninja installation directory (optional, for LTR pipeline).
=item -no_prompt
Non-interactive mode. Never prompts for input. Succeeds silently when all
required values are supplied via command-line options or already configured.
Dies with an error message if any required value is missing or invalid, or
if a partial LTR pipeline specification is supplied.
=back
=head1 SEE ALSO
RepeatModeler
=head1 COPYRIGHT
Copyright 2003-2025 Robert Hubley, Institute for Systems Biology
=head1 AUTHOR
Robert Hubley <rhubley@systemsbiology.org>
=cut
use strict;
use warnings;
use Config;
use Cwd;
use FindBin;
use File::Basename;
use File::Path qw(make_path rmtree);
use File::Spec;
use Getopt::Long;
use Pod::Text;
use lib $FindBin::Bin;
use RepModelConfig;
$| = 1;
my $version = $RepModelConfig::VERSION;
my $INSTALL_DIR = $FindBin::RealBin;
##
## Command-line option processing
##
my @getopt_args = ( 'version', 'perlbin=s', 'no_prompt' );
push @getopt_args, RepModelConfig::getCommandLineOptions();
my %opts;
Getopt::Long::config( "noignorecase", "bundling_override" );
GetOptions( \%opts, @getopt_args ) or usage();
my $no_prompt = $opts{no_prompt} ? 1 : 0;
if ( $opts{version} ) {
print "RepeatModeler $version\n";
exit 0;
}
##
## Must be run from the installation directory
##
if ( getcwd() ne $INSTALL_DIR ) {
die "\n ERROR: configure must be run from inside the RepeatModeler\n"
. " installation directory:\n\n"
. " cd $INSTALL_DIR\n"
. " ./configure\n\n";
}
## Apply command-line overrides before any validation
RepModelConfig::resolveConfiguration( \%opts );
my $config = $RepModelConfig::configuration;
##
## Phase 1: Dependency checks (non-interactive)
##
check_dependencies();
##
## Phase 2: Fix perl shebang lines in all RepeatModeler scripts
##
my $perl = resolve_perl( $opts{perlbin} );
update_shebangs( $perl );
##
## Phase 3: Interactive configuration
##
print_banner();
configure_repeatmasker();
configure_famdb();
configure_rmblast();
configure_repeatscout();
configure_recon();
configure_repeatafterme();
configure_trf();
configure_cdhit();
configure_ucsctools();
configure_ltr_pipeline();
##
## Phase 4: Save configuration and summarise
##
RepModelConfig::updateConfigFile();
print_summary();
exit 0;
###########################################################################
## Subroutines
###########################################################################
sub usage {
my $p = Pod::Text->new( sentence => 0, width => 78 );
$p->output_fh(*STDOUT);
$p->parse_file($0);
exit 1;
}
sub print_banner {
my $w = 62;
print "=" x $w . "\n";
printf " %-*s\n", $w - 2, " RepeatModeler v$version -- Configuration";
print "=" x $w . "\n\n";
}
sub section_header {
my ($title) = @_;
print "\n" . "-" x 62 . "\n";
print " $title\n";
print "-" x 62 . "\n";
}
sub status_ok { printf " [ OK ] %s\n", $_[0] }
sub status_info { printf " [ ] %s\n", $_[0] }
sub status_warn { printf " [WARN] %s\n", $_[0] }
##
## Read a line from STDIN, strip newline, return $default if blank.
##
sub prompt {
my ( $message, $default ) = @_;
if ( defined $default && $default ne "" ) {
print " $message [$default]: ";
}
else {
print " $message: ";
}
my $answer = <STDIN> // "";
$answer =~ s/[\r\n]+$//;
return ( $answer eq "" && defined $default ) ? $default : $answer;
}
##
## Prompt for Y/N. Returns 1 for yes, 0 for no.
##
sub prompt_yn {
my ( $message, $default ) = @_;
$default //= "n";
if ( $no_prompt ) {
return lc($default) eq "y" ? 1 : 0;
}
my $hint = ( lc($default) eq "y" ) ? "[Y/n]" : "[y/N]";
my $answer;
do {
print " $message $hint: ";
$answer = <STDIN> // "";
$answer =~ s/[\r\n]+$//;
$answer = $default if $answer eq "";
} while ( $answer !~ /^[YyNn]$/i );
return $answer =~ /^[Yy]$/i ? 1 : 0;
}
##
## Search PATH for an executable. Returns full path or "".
##
sub find_in_path {
my ($name) = @_;
for my $dir ( split /:/, ( $ENV{PATH} // "" ) ) {
my $full = "$dir/$name";
return $full if -f $full && -x $full;
}
return "";
}
##
## Resolve the perl interpreter to use for shebang lines.
##
sub resolve_perl {
my ($perlbin) = @_;
my $perl = $^X;
if ( $perlbin ) {
if ( -d $perlbin ) {
for my $candidate ( "$perlbin/perl", "$perlbin/bin/perl" ) {
if ( -f $candidate && -x $candidate ) {
$perl = $candidate;
last;
}
}
}
elsif ( -f $perlbin && -x $perlbin ) {
$perl = $perlbin;
}
else {
die "\n ERROR: -perlbin '$perlbin' does not point to a perl executable.\n\n";
}
}
unless ( File::Spec->file_name_is_absolute($perl) ) {
$perl = $Config{perlpath} . ( $Config{_exe} // "" );
}
die "\n ERROR: Cannot determine an absolute path for the perl interpreter.\n"
. " Try: ./configure -perlbin /path/to/perl\n\n"
unless File::Spec->file_name_is_absolute($perl) && -x $perl;
return $perl;
}
##
## Check required Perl modules.
##
sub check_dependencies {
section_header("Checking Dependencies");
if ( $] < 5.008 ) {
printf " [FAIL] Perl %s -- version 5.8 or higher is required.\n\n", $];
exit 1;
}
status_ok( "Perl " . sprintf( "%vd", $^V ) );
my @required = qw( Tie::File Getopt::Long POSIX File::Copy File::Path
Data::Dumper Cwd Storable JSON );
my @missing;
for my $mod ( @required ) {
push @missing, $mod unless eval "require $mod; 1";
}
if ( @missing ) {
print " [FAIL] Missing Perl modules: " . join( ", ", @missing ) . "\n";
print "\n Install via CPAN or your system package manager, "
. "then re-run configure.\n\n";
exit 1;
}
status_ok("Required Perl modules present");
unless ( eval "use Scalar::Util qw(weaken); 1" ) {
print " [FAIL] Scalar::Util is not compiled with XS support.\n";
print "\n Please reinstall Scalar::Util from CPAN and re-run configure.\n\n";
exit 1;
}
status_ok("Scalar::Util (XS)");
}
##
## Rewrite the perl shebang line in every RepeatModeler script.
##
sub update_shebangs {
my ($perl) = @_;
section_header("Perl Interpreter");
status_ok($perl);
my @scripts = qw(
BuildDatabase
Refiner
RepeatClassifier
RepeatModeler
TRFMask
LTRPipeline
util/align.pl
util/Linup
util/CntSubst
util/alignAndCallConsensus.pl
util/AutoRunBlocker.pl
util/bestwindow.pl
util/Blocker.pl
util/ClusterPartialMatchingSubs.pl
util/extendFlankingSeqs.pl
util/extend-stk.pl
util/fasta-trf-filter.pl
util/generateSeedAlignments.pl
util/renameIds.pl
util/rmblast.pl
util/TSD.pl
util/viewMSA.pl
util/viewMultipleMSA.pl
util/visualizeAlignPNG.pl
);
my $perlEsc = $perl;
$perlEsc =~ s/\//\\\//g;
for my $script ( @scripts ) {
if ( -s $script ) {
system( qq($perl -i -0pe 's/^#\\!.*perl.*/#\\!$perlEsc/g;' $script) );
}
}
}
##
## General helper: configure a required directory-type tool.
## Named args: key, label, desc, url, version_check (optional coderef).
##
sub _configure_dir {
my (%args) = @_;
my $key = $args{key};
my $label = $args{label};
my $opt_key = $config->{$key}->{'command_line_override'};
section_header($label);
print "\n $args{desc}\n";
print " $args{url}\n\n" if $args{url};
# Non-interactive: valid path supplied on command line
if ( $opts{$opt_key} ) {
if ( RepModelConfig::validateParam($key) ) {
status_ok( "$label: " . $config->{$key}->{'value'} );
$args{version_check}->() if $args{version_check};
return;
}
if ( $no_prompt ) {
die "\n ERROR: $label path '$opts{$opt_key}' is not valid.\n"
. " Could not find required binaries.\n\n";
}
status_warn("Specified $label path is not valid: $opts{$opt_key}");
print "\n";
}
my $current = $config->{$key}->{'value'} // "";
# Seed from PATH if not currently valid
if ( !$current || !RepModelConfig::validateParam($key) ) {
if ( my $binary = ( $config->{$key}->{'expected_binaries'} // [] )->[0] ) {
my $found = find_in_path($binary);
$current = dirname($found) if $found;
}
}
# Offer to keep if already valid
if ( $current && RepModelConfig::validateParam($key) ) {
print " Currently configured: $current\n\n";
if ( prompt_yn( "Keep this $label configuration?", "y" ) ) {
status_ok("$label: $current");
$args{version_check}->() if $args{version_check};
return;
}
print "\n";
}
my $expected = join( ", ",
@{ $config->{$key}->{'expected_binaries'} // [] } );
while (1) {
if ( $no_prompt ) {
die "\n ERROR: $label is not configured and no -$opt_key was supplied.\n"
. " Please specify -$opt_key on the command line.\n\n";
}
my $dir = prompt( "Path to $label directory", $current );
$config->{$key}->{'value'} = $dir;
if ( RepModelConfig::validateParam($key) ) {
status_ok("$label: $dir");
$args{version_check}->() if $args{version_check};
return;
}
print "\n Could not find required binaries in '$dir'.\n";
print " Expected: $expected\n\n" if $expected;
$current = $dir;
}
}
##
## Configure RepeatMasker (required).
##
sub configure_repeatmasker {
_configure_dir(
key => 'REPEATMASKER_DIR',
label => 'RepeatMasker',
desc => 'RepeatMasker performs initial masking and is required for '
. "RepeatModeler's\n classification pipeline. (4.2.4 or higher)",
url => 'https://www.repeatmasker.org/',
version_check => sub {
my $val = $config->{'REPEATMASKER_DIR'}->{'value'};
my $ver = `$val/RepeatMasker -v 2>&1`;
if ( $ver =~ /version\s+(\d+)\.(\d+)\.(\d+)/ ) {
my ( $maj, $min, $rev ) = ( $1, $2, $3 );
unless ( $maj > 4 || ( $maj == 4 && $min > 2 )
|| ( $maj == 4 && $min == 2 && $rev >= 4 ) ) {
die "\n ERROR: RepeatMasker $maj.$min.$rev is too old. "
. "Please use 4.2.4 or higher.\n\n";
}
status_info("Version: $maj.$min.$rev");
}
},
);
}
##
## Configure FamDB (required for RepeatClassifier).
##
sub configure_famdb {
my $key = 'FAMDB_DIR';
my $label = 'FamDB';
section_header("FamDB");
print "\n FamDB provides access to the Dfam TE protein and consensus\n";
print " libraries used by RepeatClassifier. (V3.0.0 or higher)\n";
print " https://github.com/Dfam-consortium/FamDB\n\n";
my $opt_key = $config->{$key}->{'command_line_override'};
if ( $opts{$opt_key} ) {
if ( RepModelConfig::validateParam($key) ) {
status_ok( "FamDB: " . $config->{$key}->{'value'} );
return;
}
if ( $no_prompt ) {
die "\n ERROR: FamDB path '$opts{$opt_key}' is not valid.\n"
. " famdb.py must exist and be executable in that directory.\n\n";
}
status_warn("Specified FamDB path is not valid: $opts{$opt_key}");
print " famdb.py must exist and be executable in that directory.\n\n";
}
my $current = $config->{$key}->{'value'} // "";
my $currently_valid = $current && RepModelConfig::validateParam($key);
if ( $currently_valid ) {
print " Currently configured: $current\n\n";
if ( prompt_yn( "Keep this FamDB configuration?", "y" ) ) {
status_ok("FamDB: $current");
return;
}
print "\n";
}
while (1) {
if ( $no_prompt ) {
die "\n ERROR: FamDB is not configured and no -famdb_dir was supplied.\n"
. " Please specify -famdb_dir on the command line.\n\n";
}
my $dir = prompt(
"Path to FamDB installation (directory containing famdb.py)",
$current );
$config->{$key}->{'value'} = $dir;
if ( RepModelConfig::validateParam($key) ) {
status_ok("FamDB: $dir");
return;
}
print "\n famdb.py not found or not executable in '$dir'.\n\n";
$current = $dir;
}
}
##
## Configure RMBlast (required).
##
sub configure_rmblast {
_configure_dir(
key => 'RMBLAST_DIR',
label => 'RMBlast',
desc => 'RMBlast provides the alignment engine for RepeatModeler. '
. '(2.17.1 or higher)',
url => 'https://www.repeatmasker.org/rmblast/',
version_check => sub {
my $val = $config->{'RMBLAST_DIR'}->{'value'};
my $ver = `$val/rmblastn -version 2>&1`;
if ( $ver =~ /rmblastn:\s+(\d+)\.(\d+)\.(\d+)/ ) {
my ( $maj, $min, $rev ) = ( $1, $2, $3 );
unless ( $maj > 2 || ( $maj == 2 && $min > 17 )
|| ( $maj == 2 && $min == 17 && $rev >= 1 ) ) {
die "\n ERROR: RMBlast $maj.$min.$rev is too old. "
. "Please use 2.17.1 or higher.\n\n";
}
status_info("Version: $maj.$min.$rev");
}
},
);
}
##
## Configure RepeatScout (required).
##
sub configure_repeatscout {
_configure_dir(
key => 'RSCOUT_DIR',
label => 'RepeatScout',
desc => 'RepeatScout performs de novo repeat discovery. (1.0.7 or higher)',
url => 'https://github.com/mmcco/RepeatScout',
version_check => sub {
my $val = $config->{'RSCOUT_DIR'}->{'value'};
my $ver = `$val/RepeatScout -blah 2>&1`;
if ( $ver =~ /Version\s+(\d+)\.(\d+)\.(\d+)/ ) {
my ( $maj, $min, $rev ) = ( $1, $2, $3 );
unless ( $maj > 1 || ( $maj == 1 && $min > 0 )
|| ( $maj == 1 && $min == 0 && $rev >= 7 ) ) {
die "\n ERROR: RepeatScout $maj.$min.$rev is too old. "
. "Please use 1.0.7 or higher.\n\n";
}
status_info("Version: $maj.$min.$rev");
}
},
);
}
##
## Configure RECON (required).
##
sub configure_recon {
_configure_dir(
key => 'RECON_DIR',
label => 'RECON',
desc => 'RECON performs automated de novo repeat element definition.',
url => 'https://github.com/dfam-consortium/RECON',
);
}
##
## Configure RepeatAfterMe (required).
##
sub configure_repeatafterme {
_configure_dir(
key => 'REPEATAFTERME_DIR',
label => 'RepeatAfterMe',
desc => 'RepeatAfterMe extends repeat model boundaries. (0.0.7 or higher)',
url => 'https://github.com/Dfam-consortium/RepeatAfterMe',
);
}
##
## Configure TRF (required).
##
sub configure_trf {
_configure_dir(
key => 'TRF_DIR',
label => 'TRF',
desc => 'Tandem Repeat Finder identifies tandem repeats. '
. 'The executable must be named "trf". (4.0.9 or higher)',
url => 'https://github.com/Benson-Genomics-Lab/TRF',
);
}
##
## Configure CD-HIT (required).
##
sub configure_cdhit {
_configure_dir(
key => 'CDHIT_DIR',
label => 'CD-HIT',
desc => 'CD-HIT clusters sequences to reduce redundancy.',
url => 'https://github.com/weizhongli/cdhit',
);
}
##
## Configure UCSC TwoBit tools (required).
##
sub configure_ucsctools {
_configure_dir(
key => 'UCSCTOOLS_DIR',
label => 'UCSC TwoBit Tools',
desc => 'UCSC TwoBit tools (twoBitToFa, faToTwoBit, twoBitInfo) '
. 'handle 2bit genome files.',
url => 'https://hgdownload.soe.ucsc.edu/admin/exe/',
);
}
##
## Optionally configure the LTR structural identification pipeline.
##
sub configure_ltr_pipeline {
section_header("LTR Structural Identification Pipeline (optional)");
my @ltr_keys = qw( GENOMETOOLS_DIR LTR_RETRIEVER_DIR MAFFT_DIR NINJA_DIR );
my @ltr_opts = qw( genometools_dir ltr_retriever_dir mafft_dir ninja_dir );
my @ltr_labels = ( 'GenomeTools', 'LTR_Retriever', 'MAFFT', 'NINJA' );
my $n_provided = grep { $opts{$_} } @ltr_opts;
# Partial specification is always an error
if ( $n_provided > 0 && $n_provided < 4 ) {
my @missing = map { "-$ltr_opts[$_]" }
grep { !$opts{$ltr_opts[$_]} } 0..$#ltr_opts;
die "\n ERROR: Partial LTR pipeline specification. "
. "Supply all four options or none.\n"
. " Missing: " . join(", ", @missing) . "\n\n";
}
# All four CLI opts provided: validate and configure non-interactively
if ( $n_provided == 4 ) {
my @invalid;
for my $i ( 0..$#ltr_keys ) {
push @invalid, " $ltr_labels[$i] (-$ltr_opts[$i]): $opts{$ltr_opts[$i]}"
unless RepModelConfig::validateParam($ltr_keys[$i]);
}
if ( @invalid ) {
die "\n ERROR: The following LTR pipeline paths are not valid:\n"
. join("\n", @invalid) . "\n\n";
}
for my $k ( @ltr_keys ) {
status_ok( "$k: " . $config->{$k}->{'value'} );
}
return;
}
# None provided: fall back to interactive (or no_prompt auto-default) flow
print "\n RepeatModeler can use an LTR structural pipeline to identify\n";
print " LTR retrotransposons with greater sensitivity. Requires:\n";
print " GenomeTools, LTR_Retriever (v2.9.0), MAFFT, and NINJA.\n\n";
my $all_valid = !grep { !RepModelConfig::validateParam($_) } @ltr_keys;
if ( $all_valid ) {
print " LTR pipeline currently configured:\n";
for my $k ( @ltr_keys ) {
printf " %-18s %s\n", $k, $config->{$k}->{'value'};
}
print "\n";
if ( prompt_yn( "Keep this LTR pipeline configuration?", "y" ) ) {
for my $k ( @ltr_keys ) {
status_ok( "$k: " . $config->{$k}->{'value'} );
}
return;
}
print "\n";
}
unless ( prompt_yn( "Configure the LTR pipeline?", "n" ) ) {
status_info("LTR pipeline not configured (optional).");
return;
}
print "\n";
_configure_dir(
key => 'GENOMETOOLS_DIR',
label => 'GenomeTools',
desc => 'GenomeTools provides structural LTR detection (gt ltrharvest).',
url => 'http://genometools.org/',
);
_configure_dir(
key => 'LTR_RETRIEVER_DIR',
label => 'LTR_Retriever',
desc => 'LTR_Retriever identifies and classifies LTR elements. (v2.9.0)',
url => 'https://github.com/oushujun/LTR_retriever',
version_check => sub {
my $val = $config->{'LTR_RETRIEVER_DIR'}->{'value'};
my $ver = "";
if ( open( my $fh, "<", "$val/LTR_retriever" ) ) {
while ( <$fh> ) {
if ( /^my\s+\$version\s*=\s*"(\S+)"/ ) { $ver = $1; last; }
}
close $fh;
}
if ( $ver ) {
unless ( $ver eq "v2.9.0" ) {
die "\n ERROR: LTR_Retriever $ver is not the required version. "
. "Please use v2.9.0.\n\n";
}
status_info("Version: $ver");
}
},
);
_configure_dir(
key => 'MAFFT_DIR',
label => 'MAFFT',
desc => 'MAFFT performs multiple sequence alignment.',
url => 'https://mafft.cbrc.jp/alignment/software/',
);
_configure_dir(
key => 'NINJA_DIR',
label => 'NINJA',
desc => 'NINJA performs rapid phylogenetic analysis.',
url => 'https://github.com/TravisWheelerLab/NINJA',
);
}
##
## Extract FamDB libraries and build BLAST databases in Libraries/.
## Called once at configure time so RepeatClassifier can rely on them.
##
## Print a final summary of the installed configuration.
##
sub print_summary {
my $w = 62;
print "\n" . "=" x $w . "\n";
printf " %-*s\n", $w - 2, " Configuration Summary";
print "=" x $w . "\n\n";
my @core = (
[ 'REPEATMASKER_DIR', 'RepeatMasker' ],
[ 'FAMDB_DIR', 'FamDB' ],
[ 'RMBLAST_DIR', 'RMBlast' ],
[ 'RSCOUT_DIR', 'RepeatScout' ],
[ 'RECON_DIR', 'RECON' ],
[ 'REPEATAFTERME_DIR','RepeatAfterMe' ],
[ 'TRF_DIR', 'TRF' ],
[ 'CDHIT_DIR', 'CD-HIT' ],
[ 'UCSCTOOLS_DIR', 'UCSC TwoBit' ],
);
for my $item ( @core ) {
my ( $key, $label ) = @$item;
my $val = $config->{$key}->{'value'} // "";
if ( $val && RepModelConfig::validateParam($key) ) {
printf " %-16s %s\n", "$label:", $val;
}
else {
printf " %-16s (not configured)\n", "$label:";
}
}
# FamDB database details from famdb.py info
if ( RepModelConfig::validateParam('FAMDB_DIR') ) {
my $famdb_dir = $config->{'FAMDB_DIR'}->{'value'};
my $info = `$famdb_dir/famdb.py info 2>/dev/null` // "";
if ( $info ) {
my ( $db_name, $db_ver, $db_date, $db_count );
$db_name = $1 if $info =~ /^Database\s*:\s*(\S.*)/m;
$db_ver = $1 if $info =~ /^Version\s*:\s*(\S.*)/m;
$db_date = $1 if $info =~ /^Date\s*:\s*(\S.*)/m;
$db_count = $1 if $info =~ /^Total consensus sequences present\s*:\s*(\d+)/m;
$db_count = $1 if !$db_count && $info =~ /^Total HMMs present\s*:\s*(\d+)/m;
if ( $db_name ) {
printf " %-16s %s %s (%s)\n", "",
$db_name, $db_ver // "", $db_date // "";
printf " %-16s %s families\n", "",
_commify($db_count) if $db_count;
}
}
}
# Optional LTR pipeline tools
my @ltr_keys = qw( GENOMETOOLS_DIR LTR_RETRIEVER_DIR MAFFT_DIR NINJA_DIR );
my $any_ltr = 0;
for my $k ( @ltr_keys ) {
$any_ltr = 1 if RepModelConfig::validateParam($k);
}
if ( $any_ltr ) {
my %ltr_labels = (
GENOMETOOLS_DIR => 'GenomeTools',
LTR_RETRIEVER_DIR => 'LTR_Retriever',
MAFFT_DIR => 'MAFFT',
NINJA_DIR => 'NINJA',
);
print "\n LTR Pipeline:\n";
for my $k ( @ltr_keys ) {
if ( RepModelConfig::validateParam($k) ) {
printf " %-16s %s\n", " $ltr_labels{$k}:", $config->{$k}->{'value'};
}
}
}
print "\n" . "=" x $w . "\n";
printf " %-*s\n", $w - 2, " RepeatModeler v$version is configured and ready.";
print "=" x $w . "\n\n";
}
sub _commify {
my $n = reverse( $_[0] // 0 );
$n =~ s/(\d{3})(?=\d)/$1,/g;
return scalar reverse $n;
}
1;